pub struct Encoder<W, A, const PAD: bool>where
A: Alphabet,{ /* private fields */ }Expand description
A streaming Base64 encoder for std::io::Write.
Like any Write implementation, Write::write may accept only
part of the provided input. Accepted input may be held as encoded
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> Encoder<W, A, PAD>where
A: Alphabet,
impl<W, A, const PAD: bool> Encoder<W, A, PAD>where
A: Alphabet,
Sourcepub const fn pending_len(&self) -> usize
pub const fn pending_len(&self) -> usize
Returns the number of raw input bytes currently buffered until a complete 3-byte Base64 encode quantum is available.
Sourcepub const fn has_pending_input(&self) -> bool
pub const fn has_pending_input(&self) -> bool
Returns whether this encoder 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 encode 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 encoded 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 encoded 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 encoded 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 encoder has encoded output waiting to be written to the wrapped writer.
Sourcepub const fn is_finalized(&self) -> bool
pub const fn is_finalized(&self) -> bool
Returns whether this encoder has been finalized.
Once this returns true, later non-empty writes return an error.
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 input.
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes the encoder without flushing pending input.
Prefer Self::finish when the encoded output must be complete.
Sourcepub fn try_into_inner(self) -> Result<W, Self>
pub fn try_into_inner(self) -> Result<W, Self>
Consumes the encoder 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 input bytes.
Source§impl<W, A, const PAD: bool> Encoder<W, A, PAD>
impl<W, A, const PAD: bool> Encoder<W, A, PAD>
Sourcepub fn try_finish(&mut self) -> Result<()>
pub fn try_finish(&mut self) -> Result<()>
Writes any pending input and flushes the wrapped writer without consuming this encoder.
After this succeeds, Self::pending_len returns 0, later
writes are rejected, and Self::finish can still be used to
recover the wrapped writer.
This is useful when a caller needs to finalize a framed payload
while keeping the stream adapter available for diagnostics or
explicit recovery.
Trait Implementations§
Source§impl<W, A, const PAD: bool> Write for Encoder<W, A, PAD>
impl<W, A, const PAD: bool> Write for Encoder<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)