added put_u8 vector ref
This commit is contained in:
parent
561580aac1
commit
336dee5103
1 changed files with 8 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ use byteorder::{BigEndian, ByteOrder};
|
||||||
/// - fixed size
|
/// - fixed size
|
||||||
/// - big endian only
|
/// - big endian only
|
||||||
pub struct ByteBuffer {
|
pub struct ByteBuffer {
|
||||||
data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
pub fw_position: usize,
|
pub fw_position: usize,
|
||||||
pub bw_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
|
/// backward put unsigned byte array
|
||||||
pub fn put_u8a_bw(&mut self, bytes: &[u8]) {
|
pub fn put_u8a_bw(&mut self, bytes: &[u8]) {
|
||||||
self.bw_position -= bytes.len();
|
self.bw_position -= bytes.len();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue