use core::num::NonZeroUsize;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub(in crate::transcode) enum DecodeStep<Value> {
Decoded {
value: Value,
consumed: NonZeroUsize,
input_index: usize,
},
Skipped {
consumed: NonZeroUsize,
},
NeedInput {
required: NonZeroUsize,
available: usize,
},
}
impl<Value> DecodeStep<Value> {
#[inline(always)]
pub(in crate::transcode) const fn decoded(
value: Value,
consumed: NonZeroUsize,
input_index: usize,
) -> Self {
Self::Decoded {
value,
consumed,
input_index,
}
}
#[inline(always)]
pub(in crate::transcode) const fn skipped(consumed: NonZeroUsize) -> Self {
Self::Skipped { consumed }
}
#[inline(always)]
pub(in crate::transcode) const fn need_input(
required: NonZeroUsize,
available: usize,
) -> Self {
Self::NeedInput {
required,
available,
}
}
}