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
This is supported on crate feature alloc only.

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

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read the exact number of bytes required to fill buf. Read more

Like read, except that it reads into a slice of buffers. Read more

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

Determines if this Reader has an efficient read_vectored implementation. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

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

Pull some bytes from this source into the specified buffer. Read more

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

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. 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

🔬 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.