1
0
Fork 0
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:
Robin Appelman 2020-12-05 22:49:39 +01:00
commit fed1da5cb0
4 changed files with 10 additions and 13 deletions

View file

@ -1,5 +1,5 @@
use crate::ReadResult;
use bitbuffer::{BitReadBuffer, BitReadStream, LittleEndian, ReadError};
use bitbuffer::{BitError, BitReadBuffer, BitReadStream, LittleEndian};
pub mod gameevent_gen;
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 {
ReadError::Utf8Error(_) => Ok("-- Malformed utf8 --".into()),
BitError::Utf8Error(_) => Ok("-- Malformed utf8 --".into()),
_ => Err(error),
}
}

View file

@ -2,14 +2,14 @@ use crate::demo::gamevent::GameEventValueType;
use crate::demo::message::gameevent::GameEventTypeId;
use crate::demo::message::packetentities::EntityId;
use crate::demo::packet::datatable::{ClassId, SendTableName};
use bitbuffer::{FromUtf8Error, ReadError};
use bitbuffer::{BitError, FromUtf8Error};
use err_derive::Error;
/// Errors that can occur during parsing
#[derive(Debug, Error)]
pub enum ParseError {
#[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")]
MalformedUTF8(#[error(source)] FromUtf8Error),
#[error(display = "Unexpected type of compressed data: {}", _0)]
@ -100,10 +100,10 @@ pub enum GameEventError {
UnknownType(GameEventTypeId),
}
impl From<ReadError> for ParseError {
fn from(err: ReadError) -> ParseError {
impl From<BitError> for ParseError {
fn from(err: BitError) -> ParseError {
match err {
ReadError::Utf8Error(utf8_error) => ParseError::MalformedUTF8(utf8_error),
BitError::Utf8Error(utf8_error) => ParseError::MalformedUTF8(utf8_error),
_ => ParseError::ReadError(err),
}
}