Add raw bytes functions

Part of #45875
This commit is contained in:
Wesley Wiser 2017-12-19 22:31:15 -05:00
parent 72176cf96c
commit fc2424b988

View File

@ -27,6 +27,10 @@ impl<'a> Encoder<'a> {
pub fn new(cursor: &'a mut io::Cursor<Vec<u8>>) -> 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 {