1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

add derive macro for Read

This commit is contained in:
Robin Appelman 2019-02-27 23:53:17 +01:00
commit 8a19225d61
8 changed files with 251 additions and 5 deletions

View file

@ -83,7 +83,7 @@ where
fn read_usize(&self, position: usize, count: usize) -> Result<usize> {
if position + count > self.bit_len {
if position > self.bit_len {
return Err(ReadError::IndexOutOfBounds{
return Err(ReadError::IndexOutOfBounds {
pos: position,
size: self.bit_len,
});

View file

@ -49,6 +49,7 @@ use std::fmt;
use std::fmt::Display;
pub use std::string::FromUtf8Error;
pub use bitstream_reader_derive::Read;
pub use buffer::BitBuffer;
pub use endianness::*;
pub use read::{Read, ReadSized};
@ -114,7 +115,7 @@ impl Error for ReadError {
fn cause(&self) -> Option<&Error> {
match self {
ReadError::Utf8Error(err) => Some(err),
_ => None
_ => None,
}
}
}

View file

@ -528,4 +528,4 @@ impl<E: Endianness> From<Vec<u8>> for BitStream<E> {
fn from(bytes: Vec<u8>) -> Self {
BitStream::new(BitBuffer::from(bytes))
}
}
}