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:
parent
523f7a3253
commit
8a19225d61
8 changed files with 251 additions and 5 deletions
|
|
@ -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,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,4 +528,4 @@ impl<E: Endianness> From<Vec<u8>> for BitStream<E> {
|
|||
fn from(bytes: Vec<u8>) -> Self {
|
||||
BitStream::new(BitBuffer::from(bytes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue