SeqAccess

Trait SeqAccess 

Source
pub trait SeqAccess<'de>: Sized {
    type Error: Error;

    // Required method
    fn next_element_seed<S>(
        self,
        seed: S,
    ) -> Result<Option<(S::Value, Self)>, Self::Error>
       where S: DeserializeSeed<'de>;

    // Provided methods
    fn next_element<T>(self) -> Result<Option<(T, Self)>, Self::Error>
       where T: Deserialize<'de> { ... }
    fn size_hint(&self) -> Option<usize> { ... }
}
Expand description

Move-oriented version of serde::de::SeqAccess.

next_value_seed takes self by move, and returns an Option<(S::Value, Self)>, ensuring that it’s only possible to get another value if a previous call didn’t return None.

This trait otherwise is identical to its serde counterpart and serves the same purpose; see those docs for details.

Use AccessAdapter to convert this type to a serde::de::SeqAccess to pass into visit_seq.

Required Associated Types§

Source

type Error: Error

The type that can be returned if an error occurs during deserialization.

Required Methods§

Source

fn next_element_seed<S>( self, seed: S, ) -> Result<Option<(S::Value, Self)>, Self::Error>
where S: DeserializeSeed<'de>,

This returns Ok(Some((value, access))) for the next value in the sequence, or Ok(None) if there are no more remaining items. The returned access value can be used to read additional items from the sequence.

The seed allows for passing data into a Deserialize implementation at runtime; typically it makes more sense to call next_element.

Provided Methods§

Source

fn next_element<T>(self) -> Result<Option<(T, Self)>, Self::Error>
where T: Deserialize<'de>,

This returns Ok(Some((value, access))) for the next value in the sequence, or Ok(None) if there are no more remaining items. The returned access value can be used to read additional items from the sequence.

Source

fn size_hint(&self) -> Option<usize>

Returns the number of elements remaining in the sequence, if known.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§