Format

Trait Format 

Source
pub trait Format: Sized {
    type EncodedBytes<'a>: AsRef<[u8]>
       where Self: 'a;

    const HRP: Hrp;

    // Required methods
    fn to_bytes(&self) -> Self::EncodedBytes<'_>;
    fn decode_bytes(bytes: &[u8]) -> Result<Self, DecodeError>;

    // Provided methods
    fn encode(&self) -> String { ... }
    fn decode(string: impl AsRef<str>) -> Result<Self, DecodeError> { ... }
}
Expand description

Format to string with bech32m

Required Associated Constants§

Source

const HRP: Hrp

Human-readable part

Required Associated Types§

Source

type EncodedBytes<'a>: AsRef<[u8]> where Self: 'a

Encoded bytes representation of Self.

Required Methods§

Source

fn to_bytes(&self) -> Self::EncodedBytes<'_>

Encode Self to bytes

Source

fn decode_bytes(bytes: &[u8]) -> Result<Self, DecodeError>

Try to decode Self from bytes

Provided Methods§

Source

fn encode(&self) -> String

Encode Self to a string

Source

fn decode(string: impl AsRef<str>) -> Result<Self, DecodeError>

Try to decode Self from a string

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§