Crate scale_bits
source ·Expand description
This small utility crate provides two separate things:
- A
Bits
type that can be SCALE encoded and decoded, and is fully SCALE compatible with aBitVec<u8, Lsb0>
. It’s a deliberately simple type that is conceptually just a sequence of bools, and can be used as a replacement forBitVec
when you don’t need the additional complexity and functionality that it comes with. See thebits
module for more. - Utility methods to help encode and decode arbitrary bit sequences from their
SCALE representation, or skip over the corresponding bytes entirely, with zero
allocations. These bypass the need to first go via some
BitVec
with the right store/order type, and are WASM compatible (unlikeBitVec
’su64
store type). See thescale
module for more.
These things play nicely together (ie you can encode and decode arbitrary bit
sequences directly into the Bits
type), but don’t need to be used together.
Re-exports§
pub use bits::Bits;
pub use scale::decode_using_format_from;
pub use scale::encode_using_format;
pub use scale::encode_using_format_to;
pub use scale::format::Format;
Modules§
- This module exposes a
Bits
type, which is a small, simple bit store which is SCALE compatible withBitVec<u8, Lsb0>
. - This module exposes some utilities for working with SCALE bit sequences, namely:
Macros§
- This macro makes it trivial to construct
Bits
from either 0 and 1 bit literals, or booleans.