Complete encode

This commit is contained in:
Ondrej Babec
2022-02-21 15:08:56 +01:00
parent 6f0d2d5de4
commit 963040026a
19 changed files with 162 additions and 116 deletions

View File

@@ -13,24 +13,28 @@ impl<'a> BuffWriter<'a> {
pub fn insert<const LEN: usize>(& mut self, array: [u8; LEN]) {
let mut x: usize = 0;
loop {
self.buffer[self.position] = array[x];
self.increment_position(1);
x = x + 1;
if x == LEN {
break;
if LEN != 0 {
loop {
self.buffer[self.position] = array[x];
self.increment_position(1);
x = x + 1;
if x == LEN {
break;
}
}
}
}
pub fn insert_ref(& mut self, len: usize, array: &[u8]) {
let mut x: usize = 0;
loop {
self.buffer[self.position] = array[x];
self.increment_position(1);
x = x + 1;
if x == len {
break;
if len != 0 {
loop {
self.buffer[self.position] = array[x];
self.increment_position(1);
x = x + 1;
if x == len {
break;
}
}
}
}
@@ -107,12 +111,13 @@ impl<'a> BuffWriter<'a> {
pub fn encode_properties<const LEN: usize>(& mut self, properties: & Vec<Property<'a>, LEN>) {
let mut i = 0;
if properties.len() != 0 {
let len = properties.len();
if len != 0 {
loop {
let prop: &Property = properties.get(i).unwrap();
self.encode_property(prop);
i = i + 1;
if i == LEN {
if i == len {
break;
}
}