diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index 99557659b29..4b2549a1aed 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -27,6 +27,10 @@ impl<'a> Encoder<'a> { pub fn new(cursor: &'a mut io::Cursor>) -> Encoder<'a> { Encoder { cursor: cursor } } + + pub fn emit_raw_bytes(&mut self, s: &[u8]) -> EncodeResult { + self.cursor.write_all(s) + } } @@ -169,6 +173,16 @@ impl<'a> Decoder<'a> { pub fn advance(&mut self, bytes: usize) { self.position += bytes; } + + pub fn read_raw_bytes(&mut self, s: &mut [u8]) -> Result<(), String> { + let len = s.len(); + + self.position += len; + + s.copy_from_slice(&self.data[0..len]); + + Ok(()) + } } macro_rules! read_uleb128 {