pub struct EncodeBuilder<'a, I>{ /* private fields */ }Expand description
A builder for setting up the alphabet and output of a base58 encode.
Implementationsยง
Sourceยงimpl<'a, I> EncodeBuilder<'a, I>
impl<'a, I> EncodeBuilder<'a, I>
Sourcepub fn new(input: I, alpha: &'a Alphabet) -> EncodeBuilder<'a, I>
pub fn new(input: I, alpha: &'a Alphabet) -> EncodeBuilder<'a, I>
Setup encoder for the given string using the given alphabet.
Preferably use bs58::encode instead of this
directly.
Sourcepub fn with_alphabet(self, alpha: &'a Alphabet) -> EncodeBuilder<'a, I>
pub fn with_alphabet(self, alpha: &'a Alphabet) -> EncodeBuilder<'a, 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());Sourcepub fn into_string(self) -> String
pub 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());Sourcepub fn into_vec(self) -> Vec<u8> โ
pub fn into_vec(self) -> Vec<u8> โ
Encode into a new owned vector.
ยงExamples
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58];
assert_eq!(b"he11owor1d", &*bs58::encode(input).into_vec());Sourcepub fn into(self, output: impl EncodeTarget) -> Result<usize, Error>
pub fn into(self, output: impl EncodeTarget) -> Result<usize, Error>
Encode into the given buffer.
Returns the length written into the buffer.
If the buffer is resizeable it will be reallocated to fit the encoded data and truncated to size.
If the buffer is not resizeable bytes after the final character will be left alone, except
up to 3 null bytes may be written to an &mut str to overwrite remaining characters of a
partially overwritten multi-byte character.
See the documentation for bs58::encode for an
explanation of the errors that may occur.
ยงExamples
ยงVec<u8>
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58];
let mut output = "goodbye world".to_owned().into_bytes();
bs58::encode(input).into(&mut output)?;
assert_eq!(b"he11owor1d", &*output);ยง&mut [u8]
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58];
let mut output = Vec::from("goodbye world");
bs58::encode(input).into(&mut output[..])?;
assert_eq!(b"he11owor1drld", &*output);ยงString
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);ยง&mut str
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58];
let mut output = "goodbye world".to_owned();
bs58::encode(input).into(output.as_mut_str())?;
assert_eq!("he11owor1drld", output);ยงClearing partially overwritten characters
let input = [0x04, 0x30, 0x5e, 0x2b, 0x24, 0x73, 0xf0, 0x58];
let mut output = "goodbye wยฎld".to_owned();
bs58::encode(input).into(output.as_mut_str())?;
assert_eq!("he11owor1d\0ld", output);Auto Trait Implementationsยง
impl<'a, I> Freeze for EncodeBuilder<'a, I>where
I: Freeze,
impl<'a, I> RefUnwindSafe for EncodeBuilder<'a, I>where
I: RefUnwindSafe,
impl<'a, I> Send for EncodeBuilder<'a, I>where
I: Send,
impl<'a, I> Sync for EncodeBuilder<'a, I>where
I: Sync,
impl<'a, I> Unpin for EncodeBuilder<'a, I>where
I: Unpin,
impl<'a, I> UnwindSafe for EncodeBuilder<'a, I>where
I: UnwindSafe,
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงimpl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Sourceยงfn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self to a value of a Properties struct.Sourceยงimpl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Sourceยงfn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self to a value of a Properties struct.