Trait bs58::encode::EncodeTarget

source ·
pub trait EncodeTarget {
    // Required method
    fn encode_with(
        &mut self,
        max_len: usize,
        f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize>
    ) -> Result<usize>;
}
Expand description

Represents a buffer that can be encoded into. See EncodeBuilder::onto and the provided implementations for more details.

Required Methods§

source

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

Encodes into this buffer, provides the maximum length for implementations that wish to preallocate space, along with a function that will encode ASCII bytes into the buffer and return the length written to it.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl EncodeTarget for str

source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl EncodeTarget for String

Available on crate feature alloc only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl EncodeTarget for Vec<u8>

Available on crate feature alloc only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl EncodeTarget for SliceVec<'_, u8>

Available on crate feature tinyvec only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl EncodeTarget for [u8]

source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl<A: Array<Item = u8>> EncodeTarget for SmallVec<A>

Available on crate feature smallvec only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

Encodes data into a smallvec::SmallVec.

Note that even if the encoded value fits into vector’s inline buffer, this may result in allocation if max_len is greater than vector’s inline size. To make sure that the inline buffer is enough for N-byte buffer encoded in base58, use smallvec with ⌈N*1.5⌉-byte long inline buffer (or ⌈(N+5)*1.5⌉ if version and checksum are included).

source§

impl<A: Array<Item = u8>> EncodeTarget for TinyVec<A>

Available on crate features tinyvec and alloc only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl<A: Array<Item = u8>> EncodeTarget for ArrayVec<A>

Available on crate feature tinyvec only.
source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

source§

impl<T: EncodeTarget + ?Sized> EncodeTarget for &mut T

source§

fn encode_with( &mut self, max_len: usize, f: impl for<'a> FnOnce(&'a mut [u8]) -> Result<usize> ) -> Result<usize>

Implementors§