logo
pub struct Decoder<'i, E: Variant> { /* 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.

Internally it uses a sealed Variant trait which is an implementation detail of this crate, and leverages a blanket impl of Encoding.

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

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.