Struct const_decoder::Encoding

source ·
pub struct Encoding { /* private fields */ }
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("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 2, 4, 8, 16, 32 or 64.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.