[][src]Struct bech32::Bech32

pub struct Bech32 { /* fields omitted */ }

Grouping structure for the human-readable part and the data part of decoded Bech32 string.

Please note that in contrast to the standard this library does not enforce a maximum length for bech32 encoded data. Please make sure to stay inside the parameters to ensure error detection.

Methods

impl Bech32
[src]

pub fn new(hrp: String, data: Vec<u5>) -> Result<Bech32, Error>
[src]

Constructs a Bech32 struct if the result can be encoded as a bech32 string.

Errors

  • MixedCase: if the HRP contains upper case letters. Encoders must use lower case.
  • InvalidChar: if the HRP contains any non-ASCII characters (outside 33..=126)
  • InvalidLength: if the HRP is outside 1..83 characters long

Deviations from standard

  • No length limits are enforced for the data part

pub fn new_check_data(hrp: String, data: Vec<u8>) -> Result<Bech32, Error>
[src]

Constructs a Bech32 struct if the result can be encoded as a bech32 string. It uses data that is not range checked yet and as a result may return Err(Error::InvalidData).

This function currently allocates memory for the checked data part. See issue #19.

pub fn hrp(&self) -> &str
[src]

Returns the human readable part

pub fn data(&self) -> &[u5]
[src]

Returns the data part as [u8] but only using 5 bits per byte

pub fn into_parts(self) -> (String, Vec<u5>)
[src]

Destructures the Bech32 struct into its parts

Trait Implementations

impl Eq for Bech32
[src]

impl PartialOrd<Bech32> for Bech32
[src]

impl PartialEq<Bech32> for Bech32
[src]

impl Clone for Bech32
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Ord for Bech32
[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Debug for Bech32
[src]

impl Display for Bech32
[src]

impl Hash for Bech32
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl FromStr for Bech32
[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Bech32, Error>
[src]

Decode from a string

Auto Trait Implementations

impl Send for Bech32

impl Sync for Bech32

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]