Struct const_decoder::Encoding [−][src]
pub struct Encoding { /* fields omitted */ }
Expand description
Custom encoding scheme based on a certain alphabet (mapping between a subset of ASCII chars
and digits in 0..P
, where P
is a power of 2).
Examples
// Decoder for Bech32 encoding as specified in
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki.
const BECH32: Decoder = Decoder::Custom(
Encoding::new("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),
);
// Sample address from the Bech32 spec excluding the `tb1q` prefix
// and the checksum suffix.
const SAMPLE_ADDR: [u8; 32] =
BECH32.decode(b"rp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q");
Implementations
Creates an encoding based on the provided alphabet
: a sequence of ASCII chars
that correspond to digits 0, 1, 2, etc.
Panics
- Panics if
alphabet
does not consist of distinct ASCII chars. - Panics if
alphabet
length is not a power of 2 (i.e., 2, 4, 8, 16, 32 or 64).