espers/fields/
full.rs

1use crate::error::Error;
2use binrw::{binrw, io::Cursor, BinRead, NullString};
3use serde_derive::{Deserialize, Serialize};
4
5#[binrw]
6#[brw(little, magic = b"FULL")]
7#[derive(Debug, Clone, Deserialize, Serialize)]
8pub struct FULL {
9    pub size: u16,
10
11    #[br(count = size)]
12    pub data: Vec<u8>,
13}
14
15impl TryInto<String> for FULL {
16    type Error = Error;
17
18    fn try_into(self) -> Result<String, Error> {
19        Ok(NullString::read_le(&mut Cursor::new(&self.data))?.to_string())
20    }
21}
22
23impl TryInto<u32> for FULL {
24    type Error = Error;
25
26    fn try_into(self) -> Result<u32, Error> {
27        let mut cursor = Cursor::new(&self.data);
28        Ok(BinRead::read_le(&mut cursor)?)
29    }
30}