Expand description
Encoding and decoding of the Bech32 format.
Bech32 is an encoding scheme that is easy to use for humans and efficient to encode in QR codes.
A Bech32 string consists of a human-readable part (HRP), a separator (the character '1'
), and
a data part. A checksum at the end of the string provides error detection to prevent mistakes
when the string is written off or read out loud.
The original description in BIP-0173 has more details. See also BIP-0350.
Re-exports
pub use crate::primitives::checksum::Checksum;
pub use crate::primitives::gf32::Fe32;
pub use crate::primitives::hrp::Hrp;
pub use crate::primitives::iter::ByteIterExt;
pub use crate::primitives::iter::Fe32IterExt;
pub use crate::primitives::Bech32;
pub use crate::primitives::Bech32m;
pub use primitives::gf32::Fe32 as u5;
Modules
- Provides the internal nuts and bolts that enable bech32 encoding/decoding.
- Segregated Witness API - enables typical usage for encoding and decoding segwit addresses.
Macros
- Formats error.
Structs
- Allocationless Bech32 writer that accumulates the checksum data internally and writes them out in the end.
Enums
- Error types for Bech32 encoding / decoding.
- Error return when
TryFrom<T>
fails for T -> u5 conversion. - Used for encode/decode operations for the two variants of Bech32.
Traits
- Interface to calculate the length of the base32 representation before actually serializing.
- A trait to convert between u8 arrays and u5 arrays without changing the content of the elements, but checking that they are in range.
- Parses/converts base32 slice to
Self
. - A trait for converting a value to a type
T
that represents au5
slice. - Interface to write
u5
s into a sink. - Interface to write
u8
s into a sink
Functions
- Converts between bit sizes.
- Convert between bit sizes without allocating
- Decodes a bech32 string into the raw HRP and the data bytes.
- Decode a lowercase bech32 string into the raw HRP and the data bytes.
- Decodes a bech32 string into the raw HRP and the data bytes, assuming no checksum.
- Encodes a bech32 payload to string.
- Encodes a bech32 payload to a writer (
fmt::Write
) using lowercase. - Encode a bech32 payload to an fmt::Write, but with any case. This method is intended for implementing traits from core::fmt without std.
- Encodes a bech32 payload to string without the checksum.
- Encodes a bech32 payload without a checksum to a writer (
fmt::Write
).