Struct bs58::encode::EncodeBuilder
[−]
[src]
pub struct EncodeBuilder<'a, I: AsRef<[u8]>> { /* fields omitted */ }
A builder for setting up the alphabet and output of a base58 encode.
Methods
impl<'a, I: AsRef<[u8]>> EncodeBuilder<'a, I>
[src]
fn new(input: I, alpha: &'a [u8; 58]) -> EncodeBuilder<'a, I>
Setup encoder for the given string using the given alphabet.
Preferably use bs58::encode
instead of this
directly.
fn with_alphabet<'b>(self, alpha: &'b [u8; 58]) -> EncodeBuilder<'b, I>
Change the alphabet that will be used for encoding.
Examples
let input = [0x60, 0x65, 0xe7, 0x9b, 0xba, 0x2f, 0x78]; assert_eq!( "he11owor1d", bs58::encode(input) .with_alphabet(bs58::alphabet::RIPPLE) .into_string());
fn into_string(self) -> String
Encode into a new owned string.
Examples
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58]; assert_eq!("he11owor1d", bs58::encode(input).into_string());
fn into(self, output: &mut String)
Encode into the given string, any existing data will be cleared.
If the given string does not have enough capacity for the encoded version of the data it will be reallocated as necessary.
Examples
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58]; let mut output = "goodbye world".to_owned(); bs58::encode(input).into(&mut output); assert_eq!("he11owor1d", output);