pub struct Decoder<W, A, const PAD: bool>where
A: Alphabet,{ /* private fields */ }Expand description
A streaming Base64 decoder for std::io::Write.
Like any Write implementation, Write::write may accept only
part of the provided input. Accepted input may be held as decoded
output until Write::flush, Self::try_finish, Self::finish,
or a later write drains the wrapped writer. Use Write::write_all
when the whole input slice must be consumed.
Implementations§
Source§impl<W, A, const PAD: bool> Decoder<W, A, PAD>where
A: Alphabet,
impl<W, A, const PAD: bool> Decoder<W, A, PAD>where
A: Alphabet,
Sourcepub const fn pending_len(&self) -> usize
pub const fn pending_len(&self) -> usize
Returns the number of encoded input bytes currently buffered until a complete 4-byte Base64 decode quantum is available.
Sourcepub const fn has_pending_input(&self) -> bool
pub const fn has_pending_input(&self) -> bool
Returns whether this decoder currently holds a partial input quantum.
Sourcepub const fn pending_input_needed_len(&self) -> usize
pub const fn pending_input_needed_len(&self) -> usize
Returns how many additional input bytes are needed to complete the currently buffered decode quantum.
Returns 0 when no partial input quantum is buffered.
Sourcepub const fn buffered_output_len(&self) -> usize
pub const fn buffered_output_len(&self) -> usize
Returns the number of decoded bytes buffered for the wrapped writer after a previous write or flush could not fully drain them.
Sourcepub const fn buffered_output_capacity(&self) -> usize
pub const fn buffered_output_capacity(&self) -> usize
Returns the maximum number of decoded bytes this adapter can buffer before returning bytes to the caller.
Sourcepub const fn buffered_output_remaining_capacity(&self) -> usize
pub const fn buffered_output_remaining_capacity(&self) -> usize
Returns how many more decoded bytes can be buffered before this adapter must drain the wrapped writer.
Sourcepub const fn has_buffered_output(&self) -> bool
pub const fn has_buffered_output(&self) -> bool
Returns whether this decoder has decoded output waiting to be written to the wrapped writer.
Sourcepub const fn has_terminal_padding(&self) -> bool
pub const fn has_terminal_padding(&self) -> bool
Returns whether this decoder has processed a terminal padded block.
Once this returns true, later calls to Write::write with
additional input return an error because strict Base64 does not
permit trailing payload bytes after padding.
Sourcepub const fn is_finalized(&self) -> bool
pub const fn is_finalized(&self) -> bool
Returns whether this decoder has been finalized.
Once this returns true, later non-empty writes return an error.
Sourcepub const fn is_failed(&self) -> bool
pub const fn is_failed(&self) -> bool
Returns whether this decoder has rejected malformed Base64 input.
Once this returns true, later writes, flushes, and finalization
attempts return an error. The unchecked Self::into_inner method
can still be used for explicit recovery of the wrapped writer.
Sourcepub const fn can_into_inner(&self) -> bool
pub const fn can_into_inner(&self) -> bool
Returns whether Self::try_into_inner can recover the wrapped
writer without discarding pending encoded input.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the decoder without flushing pending input.
Prefer Self::finish when the decoded output must be complete.
Sourcepub fn try_into_inner(self) -> Result<W, Self>
pub fn try_into_inner(self) -> Result<W, Self>
Consumes the decoder only when no partial input quantum is buffered.
This does not flush or finalize the wrapped writer. It is a checked
alternative to Self::into_inner for callers that want to avoid
accidentally discarding pending encoded input bytes.
Source§impl<W, A, const PAD: bool> Decoder<W, A, PAD>
impl<W, A, const PAD: bool> Decoder<W, A, PAD>
Sourcepub fn try_finish(&mut self) -> Result<()>
pub fn try_finish(&mut self) -> Result<()>
Validates any final pending input and flushes the wrapped writer without consuming this decoder.
After this succeeds, Self::pending_len returns 0, later
writes are rejected, and Self::finish can still be used to
recover the wrapped writer.
If the final buffered input is malformed, an error is returned and
the caller still owns the decoder for diagnostics or explicit
recovery.
Trait Implementations§
Source§impl<W, A, const PAD: bool> Write for Decoder<W, A, PAD>
impl<W, A, const PAD: bool> Write for Decoder<W, A, PAD>
Source§fn write(&mut self, input: &[u8]) -> Result<usize>
fn write(&mut self, input: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)