pub struct DecodeContext { /* private fields */ }Expand description
Context for one codec decode attempt inside a buffered decoder engine.
Input positions are source-unit indexes. Output positions use the driving
engine’s output domain: decoded values for TranscodeDecodeEngine, and
target encoding units for TranscodeConvertEngine. output_written is
relative to the current call and does not count intermediate decoded
values in a converter.
§Examples
use qubit_codec::engine::DecodeContext;
let context = DecodeContext::new(0, 0, 0, 0, 2);
assert_eq!(context.available(), 2);Implementations§
Source§impl DecodeContext
impl DecodeContext
Sourcepub const fn new(
input_start: usize,
input_index: usize,
output_start: usize,
output_index: usize,
available: usize,
) -> Self
pub const fn new( input_start: usize, input_index: usize, output_start: usize, output_index: usize, available: usize, ) -> Self
Creates a decode context.
§Parameters
input_start: Absolute source index where thistranscodecall starts.input_index: Absolute source index where the attempted value starts.output_start: Absolute output index where this call starts, in the driving engine’s output domain.output_index: Absolute output index where the next output would be written, in the driving engine’s output domain.available: Units visible to the codec frominput_index.
§Returns
Returns a decode context.
§Panics
Panics when input_index < input_start or
output_index < output_start.
Sourcepub const fn input_start(self) -> usize
pub const fn input_start(self) -> usize
Returns the absolute source index where this transcode call starts.
§Returns
Returns the input start index.
Sourcepub const fn input_index(self) -> usize
pub const fn input_index(self) -> usize
Returns the absolute source index where the attempted value starts.
§Returns
Returns the current input index.
Sourcepub const fn output_start(self) -> usize
pub const fn output_start(self) -> usize
Returns the absolute output index where this call starts, in the driving engine’s output domain.
§Returns
Returns the output start index.
Sourcepub const fn output_index(self) -> usize
pub const fn output_index(self) -> usize
Returns the absolute output index where the next output would be written, in the driving engine’s output domain.
§Returns
Returns the current output index.
Sourcepub const fn available(self) -> usize
pub const fn available(self) -> usize
Returns units visible to the codec from Self::input_index.
§Returns
Returns the available input-unit count.
Sourcepub const fn input_used(self) -> usize
pub const fn input_used(self) -> usize
Returns input units consumed since this transcode call started.
§Returns
Returns input_index - input_start.
Sourcepub const fn output_written(self) -> usize
pub const fn output_written(self) -> usize
Returns output written since this call started, in the driving engine’s output domain. For a converter, this counts target encoding units rather than intermediate decoded values.
§Returns
Returns output_index - output_start.