Struct base64ct::Decoder

source ·
pub struct Decoder<'i, E: Encoding> { /* private fields */ }
Expand description

Stateful Base64 decoder with support for buffered, incremental decoding.

The E type parameter can be any type which impls Encoding such as Base64 or Base64Unpadded.

Implementations§

Create a new decoder for a byte slice containing contiguous (non-newline-delimited) Base64-encoded data.

Returns
  • Ok(decoder) on success.
  • Err(Error::InvalidLength) if the input buffer is empty.

Create a new decoder for a byte slice containing Base64 which line wraps at the given line length.

Trailing newlines are not supported and must be removed in advance.

Newlines are handled according to what are roughly RFC7468 conventions:

[parsers] MUST handle different newline conventions

RFC7468 allows any of the following as newlines, and allows a mixture of different types of newlines:

eol        = CRLF / CR / LF
Returns
  • Ok(decoder) on success.
  • Err(Error::InvalidLength) if the input buffer is empty or the line width is zero.

Fill the provided buffer with data decoded from Base64.

Enough Base64 input data must remain to fill the entire buffer.

Returns
  • Ok(bytes) if the expected amount of data was read
  • Err(Error::InvalidLength) if the exact amount of data couldn’t be read

Decode all remaining Base64 data, placing the result into buf.

If successful, this function will return the total number of bytes decoded into buf.

Get the length of the remaining data after Base64 decoding.

Decreases every time data is decoded.

Has all of the input data been decoded?

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.