[][src]Struct bs58::decode::DecodeBuilder

pub struct DecodeBuilder<'a, I: AsRef<[u8]>> { /* fields omitted */ }

A builder for setting up the alphabet and output of a base58 decode.

See the documentation for bs58::decode for a more high level view of how to use this.

Implementations

impl<'a, I: AsRef<[u8]>> DecodeBuilder<'a, I>[src]

pub fn new(input: I, alpha: &'a Alphabet) -> DecodeBuilder<'a, I>[src]

Setup decoder for the given string using the given alphabet. Preferably use bs58::decode instead of this directly.

pub fn with_alphabet(self, alpha: &'a Alphabet) -> DecodeBuilder<'a, I>[src]

Change the alphabet that will be used for decoding.

Examples

assert_eq!(
    vec![0x60, 0x65, 0xe7, 0x9b, 0xba, 0x2f, 0x78],
    bs58::decode("he11owor1d")
        .with_alphabet(bs58::Alphabet::RIPPLE)
        .into_vec()?);

pub fn with_check(self, expected_ver: Option<u8>) -> DecodeBuilder<'a, I>[src]

This is supported on crate feature check only.

Expect and check checksum using the Base58Check algorithm when decoding.

Optional parameter for version byte. If provided, the version byte will be used in verification.

Examples

assert_eq!(
    vec![0x2d, 0x31],
    bs58::decode("PWEu9GGN")
        .with_check(None)
        .into_vec()?);

pub fn into_vec(self) -> Result<Vec<u8>>[src]

This is supported on crate features alloc or std only.

Decode into a new vector of bytes.

See the documentation for bs58::decode for an explanation of the errors that may occur.

Examples

assert_eq!(
    vec![0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58],
    bs58::decode("he11owor1d").into_vec()?);

pub fn into<O: AsMut<[u8]>>(self, output: O) -> Result<usize>[src]

Decode into the given buffer.

Returns the length written into the buffer, the rest of the bytes in the buffer will be untouched.

See the documentation for bs58::decode for an explanation of the errors that may occur.

Examples

let mut output = [0xFF; 10];
assert_eq!(8, bs58::decode("he11owor1d").into(&mut output)?);
assert_eq!(
    [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58, 0xFF, 0xFF],
    output);

Auto Trait Implementations

impl<'a, I> RefUnwindSafe for DecodeBuilder<'a, I> where
    I: RefUnwindSafe

impl<'a, I> Send for DecodeBuilder<'a, I> where
    I: Send

impl<'a, I> Sync for DecodeBuilder<'a, I> where
    I: Sync

impl<'a, I> Unpin for DecodeBuilder<'a, I> where
    I: Unpin

impl<'a, I> UnwindSafe for DecodeBuilder<'a, I> where
    I: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.