pub struct Decoder { /* private fields */ }Expand description
Stateful standard basE91 decoder.
A call to finish ends the current message and consumes the
decoder, so the same stream cannot be continued afterwards. The consuming
contract is enforced by the type system: the decoder is not Copy, so
reusing it after finish fails to compile.
use fastbase91_core::{DecodeOptions, Decoder};
let mut decoder = Decoder::new(DecodeOptions::new());
let mut output = [0_u8; 4];
let _tail = decoder.finish();
// `finish` consumed the decoder; decoding more must not compile.
let _ = decoder.update(b"AA", &mut output);Implementations§
Source§impl Decoder
impl Decoder
Sourcepub const fn new(options: DecodeOptions) -> Self
pub const fn new(options: DecodeOptions) -> Self
Creates a decoder with the requested policy.
Sourcepub fn update(
&mut self,
input: &[u8],
output: &mut [u8],
) -> Result<usize, DecodeError>
pub fn update( &mut self, input: &[u8], output: &mut [u8], ) -> Result<usize, DecodeError>
Decodes a chunk into caller-provided storage.
Capacity is checked first using a content-independent upper bound; on
OutputTooSmall neither the decoder state
nor the output is changed. In strict mode the first byte outside the
alphabet stops decoding with InvalidByte,
whose offset is the 0-based index of that byte within this input; the
decoder state is left unchanged, but bytes already written to output
are unspecified and must be discarded.