pub struct EncodeContext<'a, Value, Unit> { /* private fields */ }Expand description
Context for one encode attempt inside a buffered encoder engine.
The context carries the current input value and output cursor. The hook
decides whether the value can be consumed with the visible output capacity
and reports that decision through crate::EncodeOutcome.
§Type Parameters
Value: Logical input value type.Unit: Encoded output unit type.
Implementations§
Source§impl<'a, Value, Unit> EncodeContext<'a, Value, Unit>
impl<'a, Value, Unit> EncodeContext<'a, Value, Unit>
Sourcepub fn new(
input_value: &'a Value,
input_index: usize,
output: &'a mut [Unit],
output_index: usize,
) -> Self
pub fn new( input_value: &'a Value, input_index: usize, output: &'a mut [Unit], output_index: usize, ) -> Self
Sourcepub fn input_value(&self) -> &Value
pub fn input_value(&self) -> &Value
Returns the input value being encoded.
§Returns
Returns a shared reference to the current input value.
Sourcepub fn input_index(&self) -> usize
pub fn input_index(&self) -> usize
Sourcepub fn output_index(&self) -> usize
pub fn output_index(&self) -> usize
Returns the start position in the output slice where writing begins.
§Returns
Returns the absolute output index.
Sourcepub fn available_output(&self) -> usize
pub fn available_output(&self) -> usize
Returns writable output units from the current output index.
§Returns
Returns output capacity visible to this encode attempt.
Sourcepub fn into_parts(self) -> (&'a Value, usize, &'a mut [Unit], usize)
pub fn into_parts(self) -> (&'a Value, usize, &'a mut [Unit], usize)
Consumes the context and returns all parts.
Use this when you need simultaneous access to the input value reference
and the mutable output slice, since Rust’s borrow checker disallows
taking &self and &mut self in the same expression.
§Returns
Returns (input_value, input_index, output, output_index).