diff --git a/src/ebml.rs b/src/ebml.rs index e4b07b3..691c5f6 100644 --- a/src/ebml.rs +++ b/src/ebml.rs @@ -197,10 +197,10 @@ pub fn encode_tag_header(tag: u64, size: Varint, output: &mut T) -> Io encode_varint(size, output) } -/// Tries to write a simple EBML tag with a string value -pub fn encode_string(tag: u64, string: &str, output: &mut T) -> IoResult<()> { - encode_tag_header(tag, Varint::Value(string.len() as u64), output)?; - output.write_all(string.as_ref()) +/// Tries to write a simple EBML tag with a string or binary value +pub fn encode_bytes(tag: u64, bytes: &[u8], output: &mut T) -> IoResult<()> { + encode_tag_header(tag, Varint::Value(bytes.len() as u64), output)?; + output.write_all(bytes) } /// Tries to write a simple EBML tag with an integer value diff --git a/src/webm.rs b/src/webm.rs index 9868e49..03b2c96 100644 --- a/src/webm.rs +++ b/src/webm.rs @@ -83,7 +83,7 @@ fn decode_simple_block(bytes: &[u8]) -> Result { pub fn encode_webm_element(element: WebmElement, output: &mut T) -> IoResult<()> { match element { WebmElement::EbmlHead => encode_element(EBML_HEAD_ID, output, |output| { - encode_string(DOC_TYPE_ID, "webm", output) + encode_bytes(DOC_TYPE_ID, "webm".as_bytes(), output) }), WebmElement::Segment => encode_tag_header(SEGMENT_ID, Varint::Unknown, output), WebmElement::SeekHead => Ok(()),