Opt: extract BattleResultsDat::from_reader

This commit is contained in:
Pavel Perestoronin committed 2022-12-03 17:59:04 +01:00
1 parent 679b0ddadf
commit 6fb70da06f
2 files changed
+15 -4

No files matched your search

+11
View File
@@ -1,6 +1,17 @@
use std::io::Read;
use serde::Deserialize;
use serde_bytes::ByteBuf;
use crate::{Error, Result};
/// Represents un-pickled `battle_results.dat`.
#[derive(Debug, Deserialize)]
pub struct BattleResultsDat(pub(crate) u64, pub(crate) ByteBuf);
impl BattleResultsDat {
/// Try and parse the pickled structure from the reader which contains `battle_results.dat`.
pub fn from_reader(reader: impl Read) -> Result<Self> {
serde_pickle::from_reader(reader, Default::default()).map_err(Error::UnpickleFailed)
}
}