musli_core/de/
sequence_decoder.rsuse crate::Context;
use super::{Decode, Decoder, SizeHint};
pub trait SequenceDecoder<'de> {
type Cx: ?Sized + Context;
type DecodeNext<'this>: Decoder<
'de,
Cx = Self::Cx,
Error = <Self::Cx as Context>::Error,
Mode = <Self::Cx as Context>::Mode,
>
where
Self: 'this;
#[inline]
fn size_hint(&self) -> SizeHint {
SizeHint::any()
}
#[must_use = "Decoders must be consumed"]
fn decode_next(&mut self) -> Result<Self::DecodeNext<'_>, <Self::Cx as Context>::Error>;
#[must_use = "Decoders must be consumed"]
fn try_decode_next(
&mut self,
) -> Result<Option<Self::DecodeNext<'_>>, <Self::Cx as Context>::Error>;
#[inline]
fn next<T>(&mut self) -> Result<T, <Self::Cx as Context>::Error>
where
T: Decode<'de, <Self::Cx as Context>::Mode>,
{
self.decode_next()?.decode()
}
#[inline]
fn try_next<T>(&mut self) -> Result<Option<T>, <Self::Cx as Context>::Error>
where
T: Decode<'de, <Self::Cx as Context>::Mode>,
{
let Some(decoder) = self.try_decode_next()? else {
return Ok(None);
};
Ok(Some(decoder.decode()?))
}
}