Compare commits

...
Author SHA1 Message Date
eigenein 1fb4bea267 Fix: include raw payload in Payload::Unknown as well 2023-04-29 22:32:46 +02:00
eigenein 705280fc19 Fix: serialize EntityMethod::Unknown::payload as hex 2023-04-29 22:29:52 +02:00
eigenein 3f557e33bf Fix: doctests 2023-04-29 22:20:46 +02:00
3 changed files with 22 additions and 4 deletions

No files matched your search

+2 -1
View File
@@ -14,7 +14,8 @@ World of Tanks Blitz replay parser in Rust.
use std::fs::File;
use anyhow::Result;
use wotbreplay_parser::prelude::*;
use wotbreplay_parser::models::battle_results::TeamNumber;
use wotbreplay_parser::replay::Replay;
fn main() -> Result<()> {
let battle_results = Replay::open(File::open("tests/replays/battle_results.wotbreplay")?)?
+9 -1
View File
@@ -1,15 +1,23 @@
use byteorder::{LittleEndian, ReadBytesExt};
use serde::Serialize;
use serde_with::serde_as;
use crate::result::Result;
#[serde_as]
#[derive(Debug, Serialize)]
pub enum EntityMethod {
/// TODO: team composition.
Subtype2F,
/// Default variant when subtype is not known.
Unknown { sub_type: u32, payload: Vec<u8> },
Unknown {
sub_type: u32,
/// Whole packet payload (including the sub-type).
#[serde_as(as = "serde_with::hex::Hex")]
payload: Vec<u8>,
},
}
impl EntityMethod {
+11 -2
View File
@@ -15,7 +15,13 @@ pub enum Payload {
EntityMethod(EntityMethod),
/// Default payload when type is not known.
Unknown(#[serde_as(as = "serde_with::hex::Hex")] Vec<u8>),
Unknown {
type_: u32,
/// Whole packet payload.
#[serde_as(as = "serde_with::hex::Hex")]
raw: Vec<u8>,
},
}
impl Payload {
@@ -44,7 +50,10 @@ impl Payload {
8 => Self::EntityMethod(EntityMethod::new(payload)?),
_ => Self::Unknown(payload),
_ => Self::Unknown {
raw: payload,
type_,
},
};
Ok(this)
}