1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

static baseline warnings

This commit is contained in:
Robin Appelman 2022-04-18 19:44:47 +02:00
commit 00610a9a95
3 changed files with 41 additions and 3 deletions

View file

@ -45,7 +45,6 @@ steamid-ng = "1"
schemars = { version = "0.8", optional = true } schemars = { version = "0.8", optional = true }
tracing = "0.1" tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
criterion = "0.3.5"
[features] [features]
schema = ["schemars", "bitbuffer/schemars"] schema = ["schemars", "bitbuffer/schemars"]
@ -54,6 +53,7 @@ schema = ["schemars", "bitbuffer/schemars"]
pretty_assertions = "1" pretty_assertions = "1"
test-case = "2.0.2" test-case = "2.0.2"
iai = "0.1" iai = "0.1"
criterion = "0.3.5"
[profile.release] [profile.release]
lto = true lto = true

View file

@ -51,6 +51,12 @@ impl From<ClassId> for u16 {
} }
} }
impl PartialEq<u16> for ClassId {
fn eq(&self, other: &u16) -> bool {
self.0 == *other
}
}
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(BitRead, BitWrite, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, Display)] #[derive(BitRead, BitWrite, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, Display)]
pub struct ServerClassName(String); pub struct ServerClassName(String);
@ -73,6 +79,26 @@ impl From<&str> for ServerClassName {
} }
} }
impl PartialEq<&str> for ServerClassName {
fn eq(&self, other: &&str) -> bool {
self.as_str() == *other
}
}
impl AsRef<str> for ServerClassName {
fn as_ref(&self) -> &str {
self.0.as_ref()
}
}
impl Deref for ServerClassName {
type Target = str;
fn deref(&self) -> &Self::Target {
self.0.deref()
}
}
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(BitRead, BitWrite, Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(BitRead, BitWrite, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ServerClass { pub struct ServerClass {

View file

@ -106,7 +106,13 @@ impl<'a> ParserState {
let props = static_baseline.parse(send_table)?; let props = static_baseline.parse(send_table)?;
cached.entry(class_id).or_insert(props).clone() cached.entry(class_id).or_insert(props).clone()
} }
None => Vec::with_capacity(8), None => {
warn!(
class_id = display(class_id),
"class without static baseline"
);
Vec::with_capacity(8)
}
}, },
}) })
} }
@ -125,7 +131,13 @@ impl<'a> ParserState {
} }
_ => match self.static_baselines.get(&class_id) { _ => match self.static_baselines.get(&class_id) {
Some(_static_baseline) => self.get_static_baseline(class_id, send_table), Some(_static_baseline) => self.get_static_baseline(class_id, send_table),
None => Ok(Vec::with_capacity(8)), None => {
warn!(
class_id = display(class_id),
"class without static baseline"
);
Ok(Vec::with_capacity(8))
}
}, },
} }
} }