Files
wotbreplay-parser/src/models/data/entity_method.rs
T

35 lines
792 B
Rust
Raw Normal View History

2023-04-29 22:17:12 +02:00
use byteorder::{LittleEndian, ReadBytesExt};
use serde::Serialize;
use serde_with::serde_as;
2023-04-29 22:17:12 +02:00
use crate::result::Result;
#[serde_as]
2023-04-29 22:17:12 +02:00
#[derive(Debug, Serialize)]
pub enum EntityMethod {
/// TODO: team composition.
Subtype2F,
/// Default variant when subtype is not known.
Unknown {
sub_type: u32,
#[serde_as(as = "serde_with::hex::Hex")]
payload: Vec<u8>,
},
2023-04-29 22:17:12 +02:00
}
impl EntityMethod {
pub fn new(payload: Vec<u8>) -> Result<Self> {
let mut reader = payload.as_slice();
reader.read_u32::<LittleEndian>()?;
let sub_type = reader.read_u32::<LittleEndian>()?;
let this = match sub_type {
0x2F => Self::Subtype2F,
_ => Self::Unknown { sub_type, payload },
};
Ok(this)
}
}