1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 10:34:11 +02:00

update to new bitreader

This commit is contained in:
Robin Appelman 2019-02-28 21:55:53 +01:00
commit e7b9f5ecbb
25 changed files with 378 additions and 590 deletions

View file

@ -1,41 +1,16 @@
use bitstream_reader::BitRead;
use crate::{Parse, ParseError, ParserState, Result, Stream};
#[derive(Debug)]
#[derive(BitRead, Debug)]
pub struct Vector {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Parse<'_> for Vector {
fn parse(stream: &mut Stream, _state: &ParserState) -> Result<Self> {
Ok(Vector {
x: stream.read_float()?,
y: stream.read_float()?,
z: stream.read_float()?,
})
}
fn skip(stream: &mut Stream) -> Result<()> {
stream.skip(32 * 3).map_err(ParseError::from)
}
}
#[derive(Debug)]
#[derive(BitRead, Debug)]
pub struct VectorXY {
pub x: f32,
pub y: f32,
}
impl Parse<'_> for VectorXY {
fn parse(stream: &mut Stream, _state: &ParserState) -> Result<Self> {
Ok(VectorXY {
x: stream.read_float()?,
y: stream.read_float()?,
})
}
fn skip(stream: &mut Stream) -> Result<()> {
stream.skip(32 * 2).map_err(ParseError::from)
}
}