mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
non buffered bitbuffer
This commit is contained in:
parent
e5f9b0c9ed
commit
fed1da5cb0
4 changed files with 10 additions and 13 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
|
@ -70,10 +70,9 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitbuffer"
|
name = "bitbuffer"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "6007718437539bc4564d96742ad7a86adf1244b5fb6e0381b426034f957edb7f"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitbuffer_derive",
|
"bitbuffer_derive",
|
||||||
|
"err-derive",
|
||||||
"memchr",
|
"memchr",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
@ -81,8 +80,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitbuffer_derive"
|
name = "bitbuffer_derive"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d481746ea558a93cdbd62cd9766ab7f56789dcb2605b8344727c5ee92007070"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ name = "parse_demo"
|
||||||
path = "src/bin/main.rs"
|
path = "src/bin/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitbuffer = "0.7"
|
bitbuffer = { version = "0.7", path = "../../bitbuffer" }
|
||||||
num_enum = "0.5"
|
num_enum = "0.5"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
enumflags2 = "0.6"
|
enumflags2 = "0.6"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::ReadResult;
|
use crate::ReadResult;
|
||||||
use bitbuffer::{BitReadBuffer, BitReadStream, LittleEndian, ReadError};
|
use bitbuffer::{BitError, BitReadBuffer, BitReadStream, LittleEndian};
|
||||||
|
|
||||||
pub mod gameevent_gen;
|
pub mod gameevent_gen;
|
||||||
pub mod gamevent;
|
pub mod gamevent;
|
||||||
|
|
@ -30,9 +30,9 @@ impl Demo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn handle_utf8_error(error: ReadError) -> ReadResult<String> {
|
pub(crate) fn handle_utf8_error(error: BitError) -> ReadResult<String> {
|
||||||
match error {
|
match error {
|
||||||
ReadError::Utf8Error(_) => Ok("-- Malformed utf8 --".into()),
|
BitError::Utf8Error(_) => Ok("-- Malformed utf8 --".into()),
|
||||||
_ => Err(error),
|
_ => Err(error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@ use crate::demo::gamevent::GameEventValueType;
|
||||||
use crate::demo::message::gameevent::GameEventTypeId;
|
use crate::demo::message::gameevent::GameEventTypeId;
|
||||||
use crate::demo::message::packetentities::EntityId;
|
use crate::demo::message::packetentities::EntityId;
|
||||||
use crate::demo::packet::datatable::{ClassId, SendTableName};
|
use crate::demo::packet::datatable::{ClassId, SendTableName};
|
||||||
use bitbuffer::{FromUtf8Error, ReadError};
|
use bitbuffer::{BitError, FromUtf8Error};
|
||||||
use err_derive::Error;
|
use err_derive::Error;
|
||||||
|
|
||||||
/// Errors that can occur during parsing
|
/// Errors that can occur during parsing
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum ParseError {
|
pub enum ParseError {
|
||||||
#[error(display = "Error while reading bits from stream: {}", _0)]
|
#[error(display = "Error while reading bits from stream: {}", _0)]
|
||||||
ReadError(#[error(source, no_from)] ReadError),
|
ReadError(#[error(source, no_from)] BitError),
|
||||||
#[error(display = "Malformed utf8 while reading string")]
|
#[error(display = "Malformed utf8 while reading string")]
|
||||||
MalformedUTF8(#[error(source)] FromUtf8Error),
|
MalformedUTF8(#[error(source)] FromUtf8Error),
|
||||||
#[error(display = "Unexpected type of compressed data: {}", _0)]
|
#[error(display = "Unexpected type of compressed data: {}", _0)]
|
||||||
|
|
@ -100,10 +100,10 @@ pub enum GameEventError {
|
||||||
UnknownType(GameEventTypeId),
|
UnknownType(GameEventTypeId),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ReadError> for ParseError {
|
impl From<BitError> for ParseError {
|
||||||
fn from(err: ReadError) -> ParseError {
|
fn from(err: BitError) -> ParseError {
|
||||||
match err {
|
match err {
|
||||||
ReadError::Utf8Error(utf8_error) => ParseError::MalformedUTF8(utf8_error),
|
BitError::Utf8Error(utf8_error) => ParseError::MalformedUTF8(utf8_error),
|
||||||
_ => ParseError::ReadError(err),
|
_ => ParseError::ReadError(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue