#![allow(clippy::needless_range_loop)]
pub trait GetParameterValue: Sized {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String>;
fn from_bytes_as_string(bytes: &[u8]) -> Result<Self, String>;
}
impl GetParameterValue for bool {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
Ok(bytes[0] != 0)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
Ok(i8::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
Ok(u8::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
Ok(i16::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
Ok(u16::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
Ok(i32::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
Ok(u32::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
Ok(i64::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
Ok(u64::from_le_bytes(bytes.try_into().unwrap()) != 0)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
Ok(f32::from_le_bytes(bytes.try_into().unwrap()) != 0.0)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
Ok(f64::from_le_bytes(bytes.try_into().unwrap()) != 0.0)
}
fn from_bytes_as_string(bytes: &[u8]) -> Result<Self, String> {
Ok(!bytes.is_empty() && bytes.iter().any(|&b| b != 0))
}
}
impl GetParameterValue for String {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
Ok(if bytes[0] != 0 {
"true".to_string()
} else {
"false".to_string()
})
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
Ok(i8::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
Ok(u8::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
Ok(i16::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
Ok(u16::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
Ok(i32::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
Ok(u32::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
Ok(i64::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
Ok(u64::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
Ok(f32::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
Ok(f64::from_le_bytes(bytes.try_into().unwrap()).to_string())
}
fn from_bytes_as_string(bytes: &[u8]) -> Result<Self, String> {
String::from_utf8(bytes.to_vec()).map_err(|e| e.to_string())
}
}
macro_rules! impl_get_parameter_value {
($t:ty) => {
impl GetParameterValue for $t {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
let value = if bytes[0] != 0 { 1u8 } else { 0u8 };
Ok(value as Self)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
Ok(i8::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
Ok(u8::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
Ok(i16::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
Ok(u16::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
Ok(i32::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
Ok(u32::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
Ok(i64::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
Ok(u64::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
Ok(f32::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
Ok(f64::from_le_bytes(bytes.try_into().unwrap()) as Self)
}
fn from_bytes_as_string(_: &[u8]) -> Result<Self, String> {
Err("Not supported: string -> numeric".to_string())
}
}
};
}
impl_get_parameter_value!(i8);
impl_get_parameter_value!(u8);
impl_get_parameter_value!(i16);
impl_get_parameter_value!(u16);
impl_get_parameter_value!(i32);
impl_get_parameter_value!(u32);
impl_get_parameter_value!(i64);
impl_get_parameter_value!(u64);
impl_get_parameter_value!(f32);
impl_get_parameter_value!(f64);
macro_rules! impl_get_parameter_array {
($t:ty) => {
impl<const N: usize> GetParameterValue for [$t; N] {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = (if chunk[0] != 0 { 1u8 } else { 0u8 }) as $t;
}
Ok(result)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = i8::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = u8::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = i16::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = u16::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = i32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = u32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = i64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = u64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = f32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = f64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_string(_: &[u8]) -> Result<Self, String> {
Ok([Default::default(); N])
}
}
};
}
impl_get_parameter_array!(i8);
impl_get_parameter_array!(u8);
impl_get_parameter_array!(i16);
impl_get_parameter_array!(u16);
impl_get_parameter_array!(i32);
impl_get_parameter_array!(u32);
impl_get_parameter_array!(i64);
impl_get_parameter_array!(u64);
impl_get_parameter_array!(f32);
impl_get_parameter_array!(f64);
impl<const N: usize> GetParameterValue for [bool; N] {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = chunk[0] != 0;
}
Ok(result)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = i8::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = u8::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = i16::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = u16::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = i32::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = u32::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = i64::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = u64::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = f32::from_le_bytes(chunk.try_into().unwrap()) != 0.0;
}
Ok(result)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
let mut result: Self = [Default::default(); N];
for i in 0..N {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = f64::from_le_bytes(chunk.try_into().unwrap()) != 0.0;
}
Ok(result)
}
fn from_bytes_as_string(_: &[u8]) -> Result<Self, String> {
Ok([Default::default(); N])
}
}
macro_rules! impl_get_parameter_vec {
($t:ty) => {
impl GetParameterValue for Vec<$t> {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = (if chunk[0] != 0 { 1u8 } else { 0u8 }) as $t;
}
Ok(result)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = i8::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = u8::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 2;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = i16::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 2;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = u16::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = i32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = u32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = i64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = u64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = f32::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = f64::from_le_bytes(chunk.try_into().unwrap()) as $t;
}
Ok(result)
}
fn from_bytes_as_string(bytes: &[u8]) -> Result<Self, String> {
Ok(vec![Default::default(); bytes.len()])
}
}
};
}
impl_get_parameter_vec!(i8);
impl_get_parameter_vec!(u8);
impl_get_parameter_vec!(i16);
impl_get_parameter_vec!(u16);
impl_get_parameter_vec!(i32);
impl_get_parameter_vec!(u32);
impl_get_parameter_vec!(i64);
impl_get_parameter_vec!(u64);
impl_get_parameter_vec!(f32);
impl_get_parameter_vec!(f64);
impl GetParameterValue for Vec<bool> {
fn from_bytes_as_bool(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = chunk[0] != 0;
}
Ok(result)
}
fn from_bytes_as_i8(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = i8::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u8(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len();
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i;
let end = start + 1;
let chunk = &bytes[start..end]; result[i] = u8::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i16(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 2;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = i16::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u16(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 2;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 2;
let end = start + 2;
let chunk = &bytes[start..end]; result[i] = u16::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = i32::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = u32::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_i64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = i64::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_u64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = u64::from_le_bytes(chunk.try_into().unwrap()) != 0;
}
Ok(result)
}
fn from_bytes_as_f32(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 4;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 4;
let end = start + 4;
let chunk = &bytes[start..end]; result[i] = f32::from_le_bytes(chunk.try_into().unwrap()) != 0.0;
}
Ok(result)
}
fn from_bytes_as_f64(bytes: &[u8]) -> Result<Self, String> {
let len = bytes.len() / 8;
let mut result = vec![Default::default(); len];
for i in 0..len {
let start = i * 8;
let end = start + 8;
let chunk = &bytes[start..end]; result[i] = f64::from_le_bytes(chunk.try_into().unwrap()) != 0.0;
}
Ok(result)
}
fn from_bytes_as_string(bytes: &[u8]) -> Result<Self, String> {
Ok(vec![false; bytes.len()])
}
}