pub struct TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,{ /* private fields */ }Expand description
Reusable buffered conversion engine for codec-backed converters.
The engine owns reusable buffered decode and encode engines. It keeps
common converter control flow private: index validation, pending-value
retention, finish draining, decode-error policy dispatch, encode attempts,
output-capacity checks, and crate::TranscodeStatus reporting.
Use this type to build a streaming converter over two one-value Codec
implementations that share the same logical value type. Each hot-path step
decodes one source unit sequence into a value, then immediately tries to
encode that value into the target output buffer. If the target buffer lacks
capacity, the decoded value is retained in an internal pending slot and
must be drained before more source input is consumed, preserving output
order across buffer turns.
TranscodeConvertEngine is intentionally batch-oriented. Its public
Self::transcode method drives a source/output buffer loop and reuses the
same unchecked codec and hook primitives as
crate::engine::TranscodeDecodeEngine and
crate::engine::TranscodeEncodeEngine. It does not call one-value public
transcoders in the hot path.
Values emitted by the source codec’s decode reset or finish phase have no source-unit position. The converter reports the placeholder index 0 for their encode contexts and errors. This index cannot distinguish lifecycle-generated values from a value decoded at source index 0. Error phases describe the underlying codec operation: encoding such a value uses the main encode path, even during converter reset or finish. Ordinary decoded values retain their index in the input slice supplied to the decode call that produced them. A pending value keeps that index across calls; it is not rebased to a later input slice and is not a whole-stream offset. The retained index may be outside the bounds of a later input slice.
For strict codec-backed conversion with default decode and encode policies,
use crate::CodecTranscodeConverter. Use TranscodeConvertEngine
directly when either side needs custom malformed-input repair, encode
planning, skipped values, or finish-time output.
The engine follows the same lifecycle as crate::Transcoder:
reset → transcode* → finish → reset. Call Self::reset before starting
a new logical stream and Self::finish after EOF once any incomplete
source tail has been handled.
§Examples
use core::convert::Infallible;
use core::num::NonZeroUsize;
use qubit_codec::Codec;
use qubit_codec::DecodeFailure;
use qubit_codec::TranscodeDecodeErrorOf;
use qubit_codec::TranscodeEncodeErrorOf;
use qubit_codec::TranscodeStatus;
use qubit_codec::engine::DecodeContext;
use qubit_codec::engine::EncodeContext;
use qubit_codec::engine::EncodeUnencodableAction;
use qubit_codec::engine::TranscodeConvertEngine;
use qubit_codec::engine::TranscodeDecodeHooks;
use qubit_codec::engine::TranscodeEncodeHooks;
#[derive(Clone, Copy)]
struct SourceCodec;
#[derive(Clone, Copy)]
struct TargetCodec;
impl Codec for SourceCodec {
type Value = u8;
type Unit = u8;
type DecodeError = Infallible;
type EncodeError = Infallible;
const MIN_UNITS_PER_VALUE: usize = 1;
const MAX_ENCODE_UNITS_PER_VALUE: usize = 1;
const MAX_DECODE_UNITS_PER_VALUE: usize = 1;
unsafe fn decode(
&mut self,
input: &[u8],
index: usize,
) -> Result<(u8, NonZeroUsize), DecodeFailure<Self::DecodeError>> {
Ok((input[index].wrapping_add(1), NonZeroUsize::MIN))
}
unsafe fn encode(
&mut self,
value: &u8,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError> {
output[index] = *value;
Ok(1)
}
}
impl Codec for TargetCodec {
type Value = u8;
type Unit = u8;
type DecodeError = Infallible;
type EncodeError = Infallible;
const MIN_UNITS_PER_VALUE: usize = 1;
const MAX_ENCODE_UNITS_PER_VALUE: usize = 1;
const MAX_DECODE_UNITS_PER_VALUE: usize = 1;
unsafe fn decode(
&mut self,
input: &[u8],
index: usize,
) -> Result<(u8, NonZeroUsize), DecodeFailure<Self::DecodeError>> {
Ok((input[index], NonZeroUsize::MIN))
}
unsafe fn encode(
&mut self,
value: &u8,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError> {
output[index] = *value;
Ok(1)
}
}
struct StrictDecodeHooks;
impl TranscodeDecodeHooks<SourceCodec> for StrictDecodeHooks {
fn handle_invalid_decode(
&mut self,
_codec: &mut SourceCodec,
error: &Infallible,
_consumed: Option<NonZeroUsize>,
_context: DecodeContext,
) -> Result<qubit_codec::engine::DecodeInvalidAction<u8>, TranscodeDecodeErrorOf<SourceCodec>> {
match *error {}
}
}
struct StrictEncodeHooks;
impl TranscodeEncodeHooks<TargetCodec> for StrictEncodeHooks {
fn handle_unencodable_encode(
&mut self,
_codec: &mut TargetCodec,
_context: &EncodeContext<'_, u8>,
) -> Result<EncodeUnencodableAction<u8>, TranscodeEncodeErrorOf<TargetCodec>> {
unreachable!("TargetCodec accepts every u8")
}
}
let mut engine = TranscodeConvertEngine::new(
SourceCodec,
TargetCodec,
StrictDecodeHooks,
StrictEncodeHooks,
);
let input = [1_u8, 2, 3];
let mut output = [0_u8; 2];
let mut reset_output = [];
engine.reset(&mut reset_output, 0)?;
let progress = engine.transcode(&input, 0, &mut output, 0)?;
match progress.status() {
TranscodeStatus::NeedOutput { .. } => {
assert_eq!(2, progress.written());
assert_eq!([2, 3], output);
// Drain `output[..progress.written()]`, then resume at
// `progress.read()` with fresh output capacity.
}
TranscodeStatus::Complete => unreachable!("output is intentionally short"),
TranscodeStatus::NeedInput { .. } => unreachable!("input is complete"),
}§Type Parameters
D: Source-side decoder codec.E: Target-side encoder codec.DH: Source-side decode hooks.EH: Target-side encode hooks.
Implementations§
Source§impl<D, E, DH, EH> TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
impl<D, E, DH, EH> TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
Sourcepub fn new(decoder: D, encoder: E, decode_hooks: DH, encode_hooks: EH) -> Self
pub fn new(decoder: D, encoder: E, decode_hooks: DH, encode_hooks: EH) -> Self
Creates a buffered converter engine.
The caller supplies decode hooks and encode hooks directly.
§Parameters
decoder: Low-level codec used for source decoding.encoder: Low-level codec used for target encoding.decode_hooks: Decode-side policy hooks.encode_hooks: Encode-side policy hooks.
§Returns
Returns a buffered converter engine.
§Compile-Time Checks
Fails to compile when either codec declares a zero decode unit bound or
when Codec::MIN_UNITS_PER_VALUE exceeds
Codec::MAX_DECODE_UNITS_PER_VALUE.
Sourcepub fn source_codec(&self) -> &D
pub fn source_codec(&self) -> &D
Returns the source-side codec.
§Returns
Returns a shared reference to the decoder codec owned by this engine.
Sourcepub fn source_codec_mut(&mut self) -> &mut D
pub fn source_codec_mut(&mut self) -> &mut D
Returns the source-side codec mutably.
§Returns
Returns a mutable reference to the decoder codec owned by this engine.
Sourcepub fn target_codec(&self) -> &E
pub fn target_codec(&self) -> &E
Returns the target-side codec.
§Returns
Returns a shared reference to the encoder codec owned by this engine.
Sourcepub fn target_codec_mut(&mut self) -> &mut E
pub fn target_codec_mut(&mut self) -> &mut E
Returns the target-side codec mutably.
§Returns
Returns a mutable reference to the encoder codec owned by this engine.
Sourcepub const fn decode_hooks(&self) -> &DH
pub const fn decode_hooks(&self) -> &DH
Returns the decode hooks used by this engine.
§Returns
Returns a shared reference to the decode hooks owned by this engine.
Sourcepub fn decode_hooks_mut(&mut self) -> &mut DH
pub fn decode_hooks_mut(&mut self) -> &mut DH
Returns the decode hooks mutably.
Mutating the returned hooks does not reset the converter or clear a pending value. The replacement hooks must continue to satisfy their global output-capacity contract for every reachable converter state.
§Returns
Returns a mutable reference to the decode hooks owned by this engine.
Sourcepub const fn encode_hooks(&self) -> &EH
pub const fn encode_hooks(&self) -> &EH
Returns the encode hooks used by this engine.
§Returns
Returns a shared reference to the encode hooks owned by this engine.
Sourcepub fn encode_hooks_mut(&mut self) -> &mut EH
pub fn encode_hooks_mut(&mut self) -> &mut EH
Returns the encode hooks mutably.
Mutating the returned hooks does not reset the converter or clear a pending value. The replacement hooks must continue to satisfy their global output-capacity contract for every reachable converter state.
§Returns
Returns a mutable reference to the encode hooks owned by this engine.
Sourcepub fn into_parts(self) -> (D, E, DH, EH)
pub fn into_parts(self) -> (D, E, DH, EH)
Consumes the engine and returns its codecs and hooks.
Any pending value and lifecycle state owned by the converter are discarded. Callers should use this only when no further conversion state needs to be preserved.
§Returns
Returns the source codec, target codec, decode hooks, and encode hooks.
Sourcepub fn max_transcode_output_len(
&self,
input_len: usize,
) -> Result<usize, CapacityError>
pub fn max_transcode_output_len( &self, input_len: usize, ) -> Result<usize, CapacityError>
Returns an upper bound for target units produced from input_len units.
The bound sums three parts: one possible retained pending value, the
maximum decoded values from the source side, and the maximum target
units for those values on the encode side. It covers only the streaming
convert phase and remains valid even when no value is currently pending.
Downstream converters must use this engine-level API for capacity
planning instead of recomputing the bound from the source or target
Codec constants.
§Parameters
input_len: Number of source units the caller plans to convert.
§Returns
Returns a conservative upper bound, or a capacity error on arithmetic overflow.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Sourcepub fn max_reset_output_len(&self) -> Result<usize, CapacityError>
pub fn max_reset_output_len(&self) -> Result<usize, CapacityError>
Returns the global maximum target units emitted when resetting stream state.
Covers decode-side reset values (encoded to target units) plus
encode-side reset units. Most codecs are stateless and return 0
for Codec::MAX_DECODE_RESET_VALUES; in that case this equals the
encode reset bound only.
§Returns
Returns the combined decode-reset and encode-reset output bound, or a capacity error on arithmetic overflow.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Sourcepub fn max_finish_output_len(&self) -> Result<usize, CapacityError>
pub fn max_finish_output_len(&self) -> Result<usize, CapacityError>
Returns the maximum target units emitted by finishing retained state.
The bound covers one possible retained pending value, the global decode-side finish-value bound (encoded to target units), and the global encode-side finish-unit bound. It is independent of whether a pending value currently exists.
§Returns
Returns the combined pending, decode-finish, and encode-finish output bound, or a capacity error on arithmetic overflow.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Sourcepub fn max_total_output_len(
&self,
input_len: usize,
) -> Result<usize, CapacityError>
pub fn max_total_output_len( &self, input_len: usize, ) -> Result<usize, CapacityError>
Returns the maximum target units needed by a complete one-shot conversion.
The returned bound covers conversion reset output, the streaming convert
phase for input_len source units, and finish output. Its components
are global across transient state. Higher-level complete conversion
helpers should use this engine-level bound instead of recomputing
capacity from the source or target codec constants, because decode
and encode hooks may change streaming or finish output.
§Parameters
input_len: Number of source units in the complete stream.
§Returns
Returns the complete-stream target-output bound, or a capacity error on arithmetic overflow.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Sourcepub fn reset(
&mut self,
output: &mut [E::Unit],
output_index: usize,
) -> Result<usize, TranscodeConvertErrorOf<D, E>>
pub fn reset( &mut self, output: &mut [E::Unit], output_index: usize, ) -> Result<usize, TranscodeConvertErrorOf<D, E>>
Clears retained conversion state, runs before-reset hooks, and emits stream-start encode output.
Reset clears any retained pending value, resets the target encoder, then
drains decode-side reset values through that reset encoder state. The
caller must provide enough output capacity for
Self::max_reset_output_len.
§Parameters
output: Complete output unit slice visible to the converter.output_index: Absolute output index where writing starts.
§Returns
Returns the number of target units written while resetting stream state.
§Errors
Returns a converter error if reset validation, target reset output emission, or reservation of the internal lifecycle value buffer fails. Capacity and index failures occur before converter state is changed. Once lifecycle execution starts, failure leaves the converter poisoned until a later reset succeeds.
§Panics
Panics when decode-reset values cannot be encoded within the capacity
reserved by Self::max_reset_output_len.
Sourcepub fn transcode(
&mut self,
input: &[D::Unit],
input_index: usize,
output: &mut [E::Unit],
output_index: usize,
) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
pub fn transcode( &mut self, input: &[D::Unit], input_index: usize, output: &mut [E::Unit], output_index: usize, ) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
Converts source units into target units.
The engine drains any retained pending value before consuming new input. Each loop iteration decodes one source value and immediately attempts to encode it. Conversion stops when the input tail is incomplete, when the output buffer cannot hold the next encoded value, or when the visible input is exhausted.
§Parameters
input: Complete input unit slice visible to the converter.input_index: Absolute input index where conversion starts.output: Complete output unit slice visible to the converter.output_index: Absolute output index where writing starts.
§Returns
Returns conversion progress describing input units consumed, target units written, and why conversion stopped.
§Errors
Returns TranscodeConvertError::Failure with
TranscodeFailure::InvalidInputIndex for an invalid input index or
TranscodeFailure::InvalidOutputIndex for an invalid output index.
Concrete codec or hook conversion errors retain their decode-side or
encode-side classification. Returns
TranscodeFailure::TranscodeBeforeReset when the
engine has not completed its first reset. Returns
TranscodeFailure::TranscodeAfterFinish when the logical stream was
already finished and has not been reset, or
TranscodeFailure::LifecyclePoisoned when an earlier reset or finish
failed after execution started.
§Panics
Panics when a codec or hook violates its declared decode or encode bounds, including a decode hook consuming beyond the available input, or when an encode hook supplies an unencodable replacement value.
Sourcepub fn transcode_eof(
&mut self,
input: &[D::Unit],
input_index: usize,
output: &mut [E::Unit],
output_index: usize,
) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
pub fn transcode_eof( &mut self, input: &[D::Unit], input_index: usize, output: &mut [E::Unit], output_index: usize, ) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
Converts source units after the caller has established end of input.
§Parameters
input: Source units visible to this call.input_index: Starting index ininput.output: Destination for target units.output_index: Starting index inoutput.
§Returns
Consumed source units, written target units, and the stopping reason.
§Errors
Returns an error for invalid indices, a missing reset, a finished or poisoned stream, or codec/hook conversion failure.
§Panics
Panics when a codec or hook violates its declared decode or encode bounds, including a decode hook consuming beyond the available input, or when an encode hook supplies an unencodable replacement value.
Sourcepub fn finish(
&mut self,
output: &mut [E::Unit],
output_index: usize,
) -> Result<usize, TranscodeConvertErrorOf<D, E>>
pub fn finish( &mut self, output: &mut [E::Unit], output_index: usize, ) -> Result<usize, TranscodeConvertErrorOf<D, E>>
Finishes retained output after EOF.
Finalization drains a pending decoded value first, then lets the
source-side decode hooks emit final values, encodes those values through
the target-side encode hooks, and finally finishes target-side encode
hook state. The decode-finish value buffer used for this cold path
requires D::Value: Default; the normal Self::transcode loop does
not.
§Parameters
output: Complete output unit slice visible to the converter.output_index: Absolute output index where writing starts.
§Returns
Returns the number of target units written during finalization.
§Errors
Returns a converter error when output capacity checks fail, the
internal lifecycle value buffer cannot be reserved, or hook
finalization fails. Returns
TranscodeFailure::FinishBeforeReset when the engine has not
completed its first reset. Returns
TranscodeFailure::FinishAfterFinish when the logical stream was
already finished and has not been reset, or
TranscodeFailure::LifecyclePoisoned when an earlier reset or finish
failed after execution started. Capacity and index failures occur before
finish execution and remain retryable; later failures poison the
converter until reset succeeds. Once lifecycle execution starts,
failure leaves the converter poisoned until a later reset succeeds.
§Panics
Panics when a retained pending value or decode-finish value cannot be encoded within the planned finish capacity.
Sourcepub fn transcode_complete_into(
&mut self,
input: &[D::Unit],
output: &mut [E::Unit],
) -> Result<usize, TranscodeConvertErrorOf<D, E>>
pub fn transcode_complete_into( &mut self, input: &[D::Unit], output: &mut [E::Unit], ) -> Result<usize, TranscodeConvertErrorOf<D, E>>
Runs a complete one-shot reset -> transcode -> finish conversion.
The complete input is supplied as input, and output starts at index
0 in output. Callers that need subranges should slice their
buffers before calling this method. Downstream one-shot converter
helpers should call this engine method instead of reproducing the
reset, transcode, and finish sequence themselves.
§Parameters
input: Complete source unit slice.output: Target unit slice for the whole converted stream.
§Returns
Returns the number of target units written.
§Errors
Returns framework errors for insufficient output, capacity overflow, or an incomplete EOF tail, and domain errors from reset, conversion, or finish.
§Panics
Panics if codec/hook lifecycle output exceeds its declared capacity bound.
Trait Implementations§
Source§impl<D, E, DH, EH> Debug for TranscodeConvertEngine<D, E, DH, EH>
impl<D, E, DH, EH> Debug for TranscodeConvertEngine<D, E, DH, EH>
Source§impl<D, E, DH, EH> Default for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec + Default,
E: Codec<Value = D::Value> + Default,
DH: TranscodeDecodeHooks<D> + Default,
EH: TranscodeEncodeHooks<E> + Default,
impl<D, E, DH, EH> Default for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec + Default,
E: Codec<Value = D::Value> + Default,
DH: TranscodeDecodeHooks<D> + Default,
EH: TranscodeEncodeHooks<E> + Default,
Source§impl<D, E, DH, EH> TranscodeConverter for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
D::Value: Default,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
impl<D, E, DH, EH> TranscodeConverter for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
D::Value: Default,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
Source§type DecodeError = <D as Codec>::DecodeError
type DecodeError = <D as Codec>::DecodeError
Source codec failures retained in conversion errors.
Source§type EncodeError = <E as Codec>::EncodeError
type EncodeError = <E as Codec>::EncodeError
Target codec failures retained in conversion errors.
Source§impl<D, E, DH, EH> Transcoder for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
D::Value: Default,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
impl<D, E, DH, EH> Transcoder for TranscodeConvertEngine<D, E, DH, EH>where
D: Codec,
E: Codec<Value = D::Value>,
D::Value: Default,
DH: TranscodeDecodeHooks<D>,
EH: TranscodeEncodeHooks<E>,
Source§type Error = TranscodeConvertError<<D as Codec>::DecodeError, <E as Codec>::EncodeError, <D as Codec>::Value>
type Error = TranscodeConvertError<<D as Codec>::DecodeError, <E as Codec>::EncodeError, <D as Codec>::Value>
Source, target, contract, and capacity failures in the pipeline.
Source§fn max_transcode_output_len(
&self,
input_len: usize,
) -> Result<usize, CapacityError>
fn max_transcode_output_len( &self, input_len: usize, ) -> Result<usize, CapacityError>
Returns an upper bound for target units produced from input_len
units.
§Parameters
input_len: Number of source units to include in capacity planning.
§Returns
The target-unit capacity bound, including the applicable retained state.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Source§fn max_finish_output_len(&self) -> Result<usize, CapacityError>
fn max_finish_output_len(&self) -> Result<usize, CapacityError>
Returns an upper bound for target units emitted by finishing retained state.
§Returns
The target-unit capacity bound, including the applicable retained state.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Source§fn max_reset_output_len(&self) -> Result<usize, CapacityError>
fn max_reset_output_len(&self) -> Result<usize, CapacityError>
Returns an upper bound for target units emitted when resetting stream state.
§Returns
The target-unit capacity bound, including the applicable retained state.
§Errors
Returns CapacityError when a component bound or their sum overflows
usize.
Source§fn reset(
&mut self,
output: &mut [E::Unit],
output_index: usize,
) -> Result<usize, TranscodeConvertErrorOf<D, E>>
fn reset( &mut self, output: &mut [E::Unit], output_index: usize, ) -> Result<usize, TranscodeConvertErrorOf<D, E>>
Clears retained conversion state and emits target reset output.
§Parameters
output: Destination for lifecycle output units.output_index: Starting index inoutput.
§Returns
The number of lifecycle output units written.
§Errors
Returns the engine error for invalid indices, insufficient capacity,
an invalid lifecycle transition, or codec/hook failure. See the inherent
TranscodeConvertEngine::reset method for retry and poisoning
semantics.
§Panics
Panics if a codec/hook output bound fails to reserve enough space for emitted values.
Source§fn transcode(
&mut self,
input: &[D::Unit],
input_index: usize,
output: &mut [E::Unit],
output_index: usize,
) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
fn transcode( &mut self, input: &[D::Unit], input_index: usize, output: &mut [E::Unit], output_index: usize, ) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
Converts source units into target units.
§Parameters
input: Source units visible to this call.input_index: Starting index ininput.output: Destination for target units.output_index: Starting index inoutput.
§Returns
Consumed source units, written target units, and the stopping reason.
§Errors
Returns an error for invalid indices, a missing reset, a finished or poisoned stream, or codec/hook conversion failure.
Source§fn transcode_eof(
&mut self,
input: &[D::Unit],
input_index: usize,
output: &mut [E::Unit],
output_index: usize,
) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
fn transcode_eof( &mut self, input: &[D::Unit], input_index: usize, output: &mut [E::Unit], output_index: usize, ) -> Result<TranscodeProgress, TranscodeConvertErrorOf<D, E>>
Transcodes an input segment while marking it as the end of the stream.
This forwarding implementation delegates to the engine’s EOF-aware
operation so the decoder can resolve trailing input using EOF rules.
Call finish separately to drain retained lifecycle output.
§Parameters
input: Source units visible to this call.input_index: Starting index ininput.output: Destination for target units.output_index: Starting index inoutput.
§Returns
Consumed source units, written target units, and the stopping reason.
§Errors
Returns an error for invalid indices, a missing reset, a finished or poisoned stream, or codec/hook conversion failure.
Source§fn finish(
&mut self,
output: &mut [E::Unit],
output_index: usize,
) -> Result<usize, TranscodeConvertErrorOf<D, E>>
fn finish( &mut self, output: &mut [E::Unit], output_index: usize, ) -> Result<usize, TranscodeConvertErrorOf<D, E>>
Finishes retained converter output after EOF.
§Parameters
output: Destination for lifecycle output units.output_index: Starting index inoutput.
§Returns
The number of lifecycle output units written.
§Errors
Returns the engine error for invalid indices, insufficient capacity,
an invalid lifecycle transition, or codec/hook failure. See the inherent
TranscodeConvertEngine::finish method for retry and poisoning
semantics.
§Panics
Panics if a codec/hook output bound fails to reserve enough space for emitted values.
Source§fn max_total_output_len(&self, input_len: usize) -> Result<usize, CapacityError>
fn max_total_output_len(&self, input_len: usize) -> Result<usize, CapacityError>
reset -> transcode_eof -> finish
stream. Read more