cleaned up code, condensed code and fixed a couple of things
This commit is contained in:
parent
40ca10651f
commit
38bcad37bd
10 changed files with 178 additions and 95 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::io::{Read, Seek};
|
||||
use std::io::{Read, Seek, Write};
|
||||
use crate::endianness::{IS_BIG_ENDIAN, ReadExtensions};
|
||||
use super::{string, Result};
|
||||
use super::{string, Result, RmcSerialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Any{
|
||||
|
|
@ -8,21 +8,26 @@ pub struct Any{
|
|||
pub data: Vec<u8>
|
||||
}
|
||||
|
||||
pub fn read(reader: &mut (impl Read + Seek)) -> Result<Any>{
|
||||
let name = string::read(reader)?;
|
||||
impl RmcSerialize for Any{
|
||||
fn serialize(&self, writer: &mut dyn Write) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
fn deserialize(mut reader: &mut dyn Read) -> Result<Self> {
|
||||
let name = String::deserialize(reader)?;
|
||||
|
||||
// also length ?
|
||||
let len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
let length: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
// also length ?
|
||||
let len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
let length: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
|
||||
let mut data = vec![0; length as usize];
|
||||
let mut data = vec![0; length as usize];
|
||||
|
||||
reader.read_exact(&mut data)?;
|
||||
reader.read_exact(&mut data)?;
|
||||
|
||||
Ok(
|
||||
Any{
|
||||
name,
|
||||
data
|
||||
}
|
||||
)
|
||||
Ok(
|
||||
Any{
|
||||
name,
|
||||
data
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue