use alloc::vec::Vec;
pub fn find_min_size(val: u64) -> usize {
if val == 0 {
return 1;
}
if val >> 8 == 0 {
return 1;
}
if val >> 16 == 0 {
return 2;
}
if val >> 32 == 0 {
return 4;
}
8
}
pub fn write_minified_val(val: u64, output: &mut Vec<u8>) {
let new_size = find_min_size(val);
output.extend_from_slice(&val.to_le_bytes()[0..new_size]);
}
pub fn find_fcs_field_size(val: u64, single_segment: bool) -> usize {
if single_segment && val <= 255 {
return 1;
}
if (256..=65791).contains(&val) {
return 2;
}
if val <= u32::MAX as u64 {
return 4;
}
8
}
#[cfg(test)]
mod tests;