Expand description
Utilities for implementing Willow’s various encodings.
Modules§
Structs§
- U8BE
- A
u8
wrapper that implementscrate::Encodable
andcrate::Decodable
by encoding as a big-endian fixed-width integer. - U16BE
- A
u16
wrapper that implementscrate::Encodable
andcrate::Decodable
by encoding as a big-endian fixed-width integer. - U32BE
- A
u32
wrapper that implementscrate::Encodable
andcrate::Decodable
by encoding as a big-endian fixed-width integer. - U64BE
- A
u64
wrapper that implementscrate::Encodable
andcrate::Decodable
by encoding as a big-endian fixed-width integer.
Enums§
- Compact
Width - A minimum width of bytes needed to represent a unsigned integer.
- Decode
Error - Everything that can go wrong when decoding a value.
Traits§
- Decodable
- A type that can be decoded from a bytestring, ensuring that every valid encoding maps to exactly one member of
Self
. - Encodable
- A type that can be encoded to a bytestring, ensuring that any value of
Self
maps to exactly one bytestring. - Relative
Decodable - A type that can be used to decode
T
from a bytestring encoded relative toSelf
. This can be used to decode a compact encoding frow whichT
can be derived by anyone withR
. - Relative
Encodable - A type that can be used to encode
T
to a bytestring encoded relative toR
. This can be used to create more compact encodings from whichT
can be derived by anyone withR
.
Functions§
- decode_
compact_ width_ be - Decode the bytes representing a
CompactWidth
-bytes integer into ausize
. - decode_
max_ power - Decode a
u64
fromn
-width bytestring, wheren
is the least number of bytes needed to representmax_size
. - encode_
compact_ width_ be - Encode a
u64
integer as acompact_width(value)
-byte big-endian integer, and consume that with aBulkConsumer
. - encode_
max_ power - Encode a
usize
to an
-width unsigned integer, wheren
is the least number of bytes needed to representmax_size
. - is_
bitflagged - Return whether a bit at the given position is
1
or not. - max_
power - Return the least natural number such that 256^
n
is greater than or equal ton
. - produce_
byte - Have
Producer
produce a single byte, or return an error if the final value was produced or the producer experienced an error.