Skip to main content

FromBech32Str

Trait FromBech32Str 

Source
pub trait FromBech32Str {
    // Required methods
    fn try_from_bech32(&self) -> Result<(String, Vec<u8>), Bech32Error>;
    fn try_from_bech32_expect_hrp(
        &self,
        expected_hrp: &str,
    ) -> Result<Vec<u8>, Bech32Error>;
}
Expand description

Extension trait for decoding Bech32 strings to byte data.

Input should be treated as untrusted; use fallible methods.

§Security Warning

Decoding input from untrusted sources should use fallible try_ methods. Invalid input may indicate tampering or errors.

Required Methods§

Source

fn try_from_bech32(&self) -> Result<(String, Vec<u8>), Bech32Error>

Fallibly decode a Bech32 string to (HRP, bytes).

Source

fn try_from_bech32_expect_hrp( &self, expected_hrp: &str, ) -> Result<Vec<u8>, Bech32Error>

Fallibly decode a Bech32 string, expecting the specified HRP, returning bytes.

Implementors§

Source§

impl<T: AsRef<str> + ?Sized> FromBech32Str for T

Available on crate feature encoding-bech32 only.