Expand description
This small utility crate provides two separate things:
- A
Bitstype 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 forBitVecwhen you don’t need the additional complexity and functionality that it comes with. See thebitsmodule 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
BitVecwith the right store/order type, and are WASM compatible (unlikeBitVec’su64store type). See thescalemodule 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.
Modules§
- bits
- This module exposes a
Bitstype, which is a small, simple bit store which is SCALE compatible withBitVec<u8, Lsb0>. - scale
- This module exposes some utilities for working with SCALE bit sequences, namely:
Macros§
Structs§
- Bits
- This represents a sequence of boolean values, packed into bits.
- Format
- A description of the format used to SCALE encode some bits.
Functions§
- decode_
using_ format_ from - SCALE decode a bit sequence using the given format, handing back an iterator of booleans.
- encode_
using_ format - This is a convenience wrapper around
encode_using_format_to. - encode_
using_ format_ to - SCALE encode an iterator of booleans with a known size into a bit sequence using the given format.