1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +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

@ -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))]
#[derive(BitRead, BitWrite, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, Display)]
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))]
#[derive(BitRead, BitWrite, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ServerClass {

View file

@ -106,7 +106,13 @@ impl<'a> ParserState {
let props = static_baseline.parse(send_table)?;
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) {
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))
}
},
}
}