mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 10:44:07 +02:00
generic Entity parse
Allow multiple entity implementations to enabled simultaneously, select which one to use with generics.
This commit is contained in:
parent
bfc70d63cd
commit
265cf21caf
2 changed files with 2 additions and 2 deletions
|
|
@ -7,7 +7,7 @@ fn main() -> Result<(), vbsp::BspError> {
|
||||||
let data = std::fs::read(args.next().expect("No demo file provided"))?;
|
let data = std::fs::read(args.next().expect("No demo file provided"))?;
|
||||||
let bsp = vbsp::Bsp::read(&data)?;
|
let bsp = vbsp::Bsp::read(&data)?;
|
||||||
for prop in bsp.entities.iter() {
|
for prop in bsp.entities.iter() {
|
||||||
match prop.parse() {
|
match prop.parse::<vbsp::Entity>() {
|
||||||
Ok(prop) => {
|
Ok(prop) => {
|
||||||
println!("{:#?}", prop)
|
println!("{:#?}", prop)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ impl<'a> RawEntity<'a> {
|
||||||
Some(T::parse(self.prop(key)?))
|
Some(T::parse(self.prop(key)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(&self) -> Result<Entity<'a>, VdfError> {
|
pub fn parse<E: Deserialize<'a>>(&self) -> Result<E, VdfError> {
|
||||||
vdf_reader::from_str(self.buf)
|
vdf_reader::from_str(self.buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue