pub struct Engine { /* private fields */ }Expand description
A Base58 Encoder/Decoder Engine.
Implementations§
Source§impl Engine
impl Engine
Sourcepub const fn new(alphabet: &[u8; 58]) -> Result<Self, Error>
pub const fn new(alphabet: &[u8; 58]) -> Result<Self, Error>
Constructs a new Engine with a custom alphabet. Returns Error::WrongAlphabet if the alphabet contains duplicates.
Sourcepub const fn encoded_len(&self, input_len: usize) -> usize
pub const fn encoded_len(&self, input_len: usize) -> usize
Returns the maximum possible length of the encoded data. Base58 expansion is ~137%. We add padding for safety.
Sourcepub const fn decoded_len(&self, input_len: usize) -> usize
pub const fn decoded_len(&self, input_len: usize) -> usize
Returns the maximum possible length of the decoded data. Base58 ’1’s map 1:1 to bytes. We cannot assume compression. The worst-case decoded size is equal to the input string length.
Sourcepub fn encode_into<T: AsRef<[u8]>>(
&self,
input: T,
output: &mut [u8],
) -> Result<usize, Error>
pub fn encode_into<T: AsRef<[u8]>>( &self, input: T, output: &mut [u8], ) -> Result<usize, Error>
Encodes input into the output buffer.
Returns the actual number of bytes written.
Sourcepub fn decode_into<T: AsRef<[u8]>>(
&self,
input: T,
output: &mut [u8],
) -> Result<usize, Error>
pub fn decode_into<T: AsRef<[u8]>>( &self, input: T, output: &mut [u8], ) -> Result<usize, Error>
Decodes input into the output buffer.
Returns the actual number of bytes written.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
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
Mutably borrows from an owned value. Read more