use super::super::engine::TranscodeDecodeHooks;
use super::super::{
decode_action::DecodeAction,
decode_context::DecodeContext,
};
use crate::{
Codec,
CodecDecodeError,
};
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
pub(in crate::transcode) struct CodecTranscodeDecodeHooks;
impl<C> TranscodeDecodeHooks<C> for CodecTranscodeDecodeHooks
where
C: Codec,
{
type Error = CodecDecodeError<C::DecodeError>;
#[inline(always)]
fn handle_decode_error(
&mut self,
_codec: &mut C,
error: C::DecodeError,
context: DecodeContext,
) -> Result<DecodeAction<C::Value>, Self::Error> {
Err(CodecDecodeError::decode(error, context.input_index()))
}
#[inline(always)]
fn map_decode_flush_error(
&mut self,
_codec: &mut C,
error: C::DecodeError,
) -> Self::Error {
CodecDecodeError::decode(error, 0)
}
}