[][src]Crate bitbuffer

Tools for reading data types of arbitrary bit length and might not be byte-aligned in the source data

The main way of handling with the binary data is to first create a BitBuffer ,wrap it into a BitStream and then read from the stream.

Once you have a BitStream, there are 2 different approaches of reading data

The BitRead and BitReadSized traits can be used with #[derive] if all fields implement BitRead or BitReadSized.

Examples

use bitbuffer::{BitReadBuffer, LittleEndian, BitReadStream, BitRead};

#[derive(BitRead)]
struct ComplexType {
    first: u8,
    #[size = 15]
    second: u16,
    third: bool,
}

let bytes = vec![
    0b1011_0101, 0b0110_1010, 0b1010_1100, 0b1001_1001,
    0b1001_1001, 0b1001_1001, 0b1001_1001, 0b1110_0111
];
let buffer = BitReadBuffer::new(bytes, LittleEndian);
let mut stream = BitReadStream::new(buffer);
let value: u8 = stream.read_int(7)?;
let complex: ComplexType = stream.read()?;

Structs

BigEndian

Marks the buffer or stream as big endian

BitReadBuffer

Buffer that allows reading integers of arbitrary bit length and non byte-aligned integers

BitReadStream

Stream that provides an easy way to iterate trough a BitBuffer

FromUtf8Error

A possible error value when converting a String from a UTF-8 byte vector.

LazyBitRead

Struct that lazily reads it's contents from the stream

LazyBitReadSized

Struct that lazily reads it's contents from the stream

LittleEndian

Marks the buffer or stream as little endian

Enums

ReadError

Errors that can be returned when trying to read from a buffer

Traits

BitRead

Trait for types that can be read from a stream without requiring the size to be configured

BitReadSized

Trait for types that can be read from a stream, requiring the size to be configured

Endianness

Trait for specifying endianness of bit buffer

Functions

bit_size_of

Get the number of bits required to read a type from stream

bit_size_of_sized

Get the number of bits required to read a type from stream

Type Definitions

Result

Either the read bits in the requested format or a ReadError

Derive Macros

BitRead

See the crate documentation for details

BitReadSized

See the crate documentation for details