Struct Encoder
pub struct Encoder<'a> { /* private fields */ }
Encodes fragmented input to an output
It is equivalent to use an Encoder with multiple calls to [Encoder::append()] than to
first concatenate all the input and then use [Encoding::encode_append()]. In particular, this
function will not introduce padding or wrapping between inputs.
Examples
// This is a bit inconvenient but we can't take a long-term reference to data_encoding::BASE64
// because it's a constant. We need to use a static which has an address instead. This will be
// fixed in version 3 of the library.
static BASE64: Encoding = BASE64;
let mut output = Stringnew;
let mut encoder = BASE64.new_encoder;
encoder.append;
encoder.append;
encoder.finalize;
assert_eq!;
Implementations
impl<'a> Encoder<'a>
fn append(&mut self, input: &[u8])Encodes the provided input fragment and appends the result to the output
fn finalize(self)Makes sure all inputs have been encoded and appended to the output
This is equivalent to dropping the encoder and required for correctness, otherwise some encoded data may be missing at the end.
Trait Implementations
impl Drop for Encoder<'_>
fn drop(&mut self)
impl<'a> Debug for Encoder<'a>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'a> !UnwindSafe for Encoder<'a>
impl<'a> Freeze for Encoder<'a>
impl<'a> RefUnwindSafe for Encoder<'a>
impl<'a> Send for Encoder<'a>
impl<'a> Sync for Encoder<'a>
impl<'a> Unpin for Encoder<'a>
impl<'a> UnsafeUnpin for Encoder<'a>
Blanket Implementations
impl<T> Any for Encoder<'a>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Encoder<'a>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Encoder<'a>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Encoder<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Encoder<'a>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Encoder<'a>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Encoder<'a>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>