Expand description
Utilities for implementing Willow’s various encodings.
Modules§
Structs§
- U8BE
- A
u8wrapper that implementscrate::Encodableandcrate::Decodableby encoding as a big-endian fixed-width integer. - U16BE
- A
u16wrapper that implementscrate::Encodableandcrate::Decodableby encoding as a big-endian fixed-width integer. - U32BE
- A
u32wrapper that implementscrate::Encodableandcrate::Decodableby encoding as a big-endian fixed-width integer. - U64BE
- A
u64wrapper that implementscrate::Encodableandcrate::Decodableby 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
Selfmaps to exactly one bytestring. - Relative
Decodable - A type that can be used to decode
Tfrom a bytestring encoded relative toSelf. This can be used to decode a compact encoding frow whichTcan be derived by anyone withR. - Relative
Encodable - A type that can be used to encode
Tto a bytestring encoded relative toR. This can be used to create more compact encodings from whichTcan 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
u64fromn-width bytestring, wherenis the least number of bytes needed to representmax_size. - encode_
compact_ width_ be - Encode a
u64integer as acompact_width(value)-byte big-endian integer, and consume that with aBulkConsumer. - encode_
max_ power - Encode a
usizeto an-width unsigned integer, wherenis the least number of bytes needed to representmax_size. - is_
bitflagged - Return whether a bit at the given position is
1or not. - max_
power - Return the least natural number such that 256^
nis greater than or equal ton. - produce_
byte - Have
Producerproduce a single byte, or return an error if the final value was produced or the producer experienced an error.