added put_u8 vector ref

This commit is contained in:
Sander Hautvast 2022-10-28 14:52:30 +02:00
parent 561580aac1
commit 336dee5103

View file

@ -5,7 +5,7 @@ use byteorder::{BigEndian, ByteOrder};
/// - fixed size
/// - big endian only
pub struct ByteBuffer {
data: Vec<u8>,
pub data: Vec<u8>,
pub fw_position: usize,
pub bw_position: usize,
}
@ -27,6 +27,13 @@ impl ByteBuffer {
}
}
pub fn put_u8v(&mut self, bytes: &Vec<u8>) {
for v in bytes {
self.data[self.fw_position] = *v;
self.fw_position += 1;
}
}
/// backward put unsigned byte array
pub fn put_u8a_bw(&mut self, bytes: &[u8]) {
self.bw_position -= bytes.len();