Expand description
§Bits & Bobs. No-std/No-alloc bit/byte manipulation of streams.
The main traits provided by this crate are Bits (analogous to std::io::Read),
and MutBits (analogous to std::io::Write).
Also included are multi-OS wrappers SeekRead and SeekWrite, and a
more organic UTF-8 encoding/decoding setup for chars.
This is an Irox foundational crate, it has no external dependencies, is no-std/no-alloc by
default (but can be augmented by using the std and alloc features), and many other irox
crates extend and augment the functionality contained herein. [irox_structs] is notable as
it provides a derivable way to encode/decode structs as a sequence of bytes.
§Features
alloc:- Enables the implementation of
BitsandMutBitson the types from thealloccrate: - Enables the following additional methods:
Bits::read_u8_blob()->Vec<u8>Bits::read_be_u16_blob()/Bits::read_le_u16_blob()->Vec<u16>Bits::read_be_u32_blob()/Bits::read_le_u32_blob()->Vec<u32>Bits::read_be_u64_blob()/Bits::read_le_u64_blob()->Vec<u64>Bits::read_all_vec()->Vec<u8>Bits::read_exact_vec()->Vec<u8>Bits::read_all_str_lossy()->alloc::string::StringBits::read_str_sized_lossy()->alloc::string::StringBits::read_str_u32_blob()->alloc::string::StringBits::read_until()->Vec<u8>Bits::consume_until()->()
- Enables the implementation of
std:- Enables the implementation of
BitsandMutBitson the types from thestdcrate: - Also enables the
SeekReadandSeekWritetraits, which wrap and normalize:- [
std::os::windows::fs::FileExt::seek_read] and [std::os::windows::fs::FileExt::seek_write] - [
std::os::unix::fs::FileExt:read_at] andstd::os::unix::fs::FileExt::write_at
- [
- Enables the implementation of
Modules§
- utf
- UTF-8 Encoding & Decoding
Structs§
- BitStream
Decoder - BitStream
Encoder - Bits
Array - This struct wraps a provided borrowed static array in a MutBits impl. Operates like a slice, walking through the array filling it up.
- Bits
Error - Error returned from the various Bits methods.
- Format
Bits - Wraps a borrowed
MutBits, providing an implementation ofcore::fmt::Writeto permit the use of thecore::write!macro with a target of&mutMutBits - MutBits
Array - This struct wraps a provided borrowed static array in a MutBits impl. Operates like a slice, walking through the array filling it up.
- Shared
Counting Bits alloc - A struct to count the number of bytes moving through it.
- SharedRO
Counter alloc - A Read-Only counter that can be shared between threads. The owner of the underlying counter is free to update the value, but users of this object alone may not.
- Tee
- Simple output stream splitter. Writes the output value to both streams simultaneously.
Enums§
- Bits
Error Kind - Enum originally modelled after
std::io::ErrorKind, used to indicate the type of the error encountered. - Bits
Wrapper - Wraps a borrowed value and provides implementations of [
Bits] and [MutBits] where applicable. - Byte
Order - Seek
From - Enum to indicate how to move a read/write pointer.
Traits§
- Bits
- Read methods for the primitive types
- BufBits
- Buffered bits - semantically equivalent to BufRead
- FromBE
Bytes - Converts to the value from a constant number of bytes
- FromLE
Bytes - Converts to the value from a constant number of bytes
- MutBits
- Write methods for the primitive types
- Read
FromBE Bits - Read
FromLE Bits - Seek
- Trait to move the current read/write position of a stream.
- Seek
Read - Trait to permit an atomic Seek+Read operation
- Seek
Write - Trait to permit an atomic Seek+Write operation
- ToBE
Bytes - Converts the value into a constant number of bytes
- ToLE
Bytes - Converts the value into a constant number of bytes
- Write
ToBE Bits - Writes ‘self’ to the provided
MutBitsimpl in big endian order. - Write
ToLE Bits - Writes ‘self’ to the provided
MutBitsimpl in little endian order.
Functions§
- array_
concat_ 1 - Splits the input into two equal sized arrays.
- array_
concat_ 2 - Splits the input into two equal sized arrays.
- array_
concat_ 4 - Splits the input into two equal sized arrays.
- array_
concat_ 8 - Splits the input into two equal sized arrays.
- array_
concat_ 16 - Splits the input into two equal sized arrays.
- array_
split_ 1 - Splits the input into two equal sized arrays.
- array_
split_ 2 - Splits the input into two equal sized arrays.
- array_
split_ 4 - Splits the input into two equal sized arrays.
- array_
split_ 8 - Splits the input into two equal sized arrays.
- array_
split_ 16 - Splits the input into two equal sized arrays.
- read_
be_ u32 - Calls
Bits::read_be_u32(). Provided for type-elusion purposes. - read_
be_ u64 - Calls
Bits::read_be_u64(). Provided for type-elusion purposes. - read_
f32 - Calls
Bits::read_f32(). Provided for type-elusion purposes. - read_
f64 - Calls
Bits::read_f64(). Provided for type-elusion purposes. - u16_
to_ u32 - compile time u16x2 to u32 conversion
- u16_
to_ u64 - compile time u16 to u64 conversion
- u16_
to_ u128 - compile time u16 to u128 conversion
- u32_
to_ u16 - compile time u32 to u16 conversion
- u32_
to_ u64 - compile time u32x2 to u64 conversion
- u32_
to_ u128 - compile time u32x4 to u128 conversion
- u64_
to_ u16 - compile time u64 to u16 conversion
- u64_
to_ u32 - compile time u64 to u32 conversion
- u64_
to_ u128 - compile time u64x2 to u128 conversion
- u128_
to_ u16 - compile-time u128 to u16 conversion
- u128_
to_ u32 - compile time u128 to u32 conversion
- u128_
to_ u64 - compile time u128 to u64 conversion
Type Aliases§
- Error
- Type alias to
BitsError - Error
Kind - Type alias to
BitsErrorKind