2025-02-01 17:31:13 +01:00
|
|
|
use std::io::{Read, Write};
|
2025-01-26 12:09:56 +01:00
|
|
|
use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions};
|
2025-02-01 17:31:13 +01:00
|
|
|
use super::{Result, RmcSerialize};
|
2025-01-26 12:09:56 +01:00
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Any{
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub data: Vec<u8>
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-26 23:21:35 +01:00
|
|
|
impl RmcSerialize for Any{
|
2025-02-01 17:31:13 +01:00
|
|
|
fn serialize(&self, _writer: &mut dyn Write) -> Result<()> {
|
2025-01-26 23:21:35 +01:00
|
|
|
todo!()
|
|
|
|
|
}
|
|
|
|
|
fn deserialize(mut reader: &mut dyn Read) -> Result<Self> {
|
|
|
|
|
let name = String::deserialize(reader)?;
|
2025-01-26 12:09:56 +01:00
|
|
|
|
2025-01-26 23:21:35 +01:00
|
|
|
// also length ?
|
2025-02-01 17:31:13 +01:00
|
|
|
let _len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
2025-01-26 23:21:35 +01:00
|
|
|
let length: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
2025-01-26 12:09:56 +01:00
|
|
|
|
2025-01-26 23:21:35 +01:00
|
|
|
let mut data = vec![0; length as usize];
|
2025-01-26 12:09:56 +01:00
|
|
|
|
2025-01-26 23:21:35 +01:00
|
|
|
reader.read_exact(&mut data)?;
|
2025-01-26 12:09:56 +01:00
|
|
|
|
2025-01-26 23:21:35 +01:00
|
|
|
Ok(
|
|
|
|
|
Any{
|
|
|
|
|
name,
|
|
|
|
|
data
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2025-01-26 12:09:56 +01:00
|
|
|
}
|