From b5bbf952b0583f09374c55e1efa667bbbbc0b957 Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Wed, 2 Aug 2017 01:30:14 -0400 Subject: [PATCH] Stub some EBML encoding funcs --- src/ebml.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ebml.rs b/src/ebml.rs index 14248a9..23d24d1 100644 --- a/src/ebml.rs +++ b/src/ebml.rs @@ -157,6 +157,19 @@ pub fn encode_varint(varint: Varint, output: &mut T) -> IoResult(tag: u64, size: Varint, output: &mut T) -> IoResult { + let id_size = encode_varint(Varint::Value(tag), output)?; + let size_size = encode_varint(size, output)?; + Ok(id_size + size_size) +} + +/// Tries to write a simple EBML tag with a string value +pub fn encode_string(tag: u64, string: &str, output: &mut T) -> IoResult { + let tag_size = encode_tag_header(tag, Varint::Value(string.len() as u64), output)?; + let string_size = output.write_all(string.as_ref()).map(|()| string.len())?; + Ok(tag_size + string_size) +} + #[derive(Debug, PartialEq)] pub struct Ebml(pub S, pub T);