AccessAdapter

Enum AccessAdapter 

Source
pub enum AccessAdapter<T, V> {
    Ready(T),
    Value(V),
    Done,
}
Expand description

Adapter type for converting the serde-mobile traits into serde’s &mut self oriented traits. It uses an enum to track the state of the accessors.

Because the underlying traits use a move-oriented interface to prevent calls after returning None, this object is guaranteed to be “fused”, meaning that next_key or next_element will always continue return None when the underlying collection is exhausted.

This type can be used for both serde::de::SeqAccess and serde::de::MapAccess.

Variants§

§

Ready(T)

The AccessAdapter is ready to yield the next value from K. This is the next element for SeqAccess or the next key for a MapAccess.

§

Value(V)

The AccessAdapter is ready to yield the value associated with a recently yielded key for a MapAccess. SeqAccess adapters can never be in this state.

§

Done

The AccessAdapter is empty; no more items will be yielded from it.

Implementations§

Source§

impl<T, V> AccessAdapter<T, V>

Source

pub fn new(access: T) -> Self

Create a new AccessAdapter, suitable for use as the argument to visit_seq or visit_map. This should be created using a SeqAccess or MapKeyAccess object, respectively.

Trait Implementations§

Source§

impl<T: Clone, V: Clone> Clone for AccessAdapter<T, V>

Source§

fn clone(&self) -> AccessAdapter<T, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, V: Debug> Debug for AccessAdapter<T, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, A> MapAccess<'de> for AccessAdapter<A, A::Value>
where A: MapKeyAccess<'de>,

Source§

type Error = <A as MapKeyAccess<'de>>::Error

The error type that can be returned if some error occurs during deserialization.
Source§

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

This returns Ok(Some(key)) for the next key in the map, or Ok(None) if there are no more remaining entries. Read more
Source§

fn next_value_seed<S>(&mut self, seed: S) -> Result<S::Value, Self::Error>
where S: DeserializeSeed<'de>,

This returns a Ok(value) for the next value in the map. Read more
Source§

fn next_entry_seed<K, V>( &mut self, key: K, value: V, ) -> Result<Option<(K::Value, V::Value)>, Self::Error>
where K: DeserializeSeed<'de>, V: DeserializeSeed<'de>,

This returns Ok(Some((key, value))) for the next (key-value) pair in the map, or Ok(None) if there are no more remaining items. Read more
Source§

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

Returns the number of entries remaining in the map, if known.
Source§

fn next_key<K>(&mut self) -> Result<Option<K>, Self::Error>
where K: Deserialize<'de>,

This returns Ok(Some(key)) for the next key in the map, or Ok(None) if there are no more remaining entries. Read more
Source§

fn next_value<V>(&mut self) -> Result<V, Self::Error>
where V: Deserialize<'de>,

This returns a Ok(value) for the next value in the map. Read more
Source§

fn next_entry<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
where K: Deserialize<'de>, V: Deserialize<'de>,

This returns Ok(Some((key, value))) for the next (key-value) pair in the map, or Ok(None) if there are no more remaining items. Read more
Source§

impl<'de, S> SeqAccess<'de> for AccessAdapter<S, Infallible>
where S: SeqAccess<'de>,

Implementation of serde::de::SeqAccess, using SeqAccess. An internal enum is used to track the

Source§

type Error = <S as SeqAccess<'de>>::Error

The error type that can be returned if some error occurs during deserialization.
Source§

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

This returns Ok(Some(value)) for the next value in the sequence, or Ok(None) if there are no more remaining items. Read more
Source§

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

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

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

This returns Ok(Some(value)) for the next value in the sequence, or Ok(None) if there are no more remaining items. Read more

Auto Trait Implementations§

§

impl<T, V> Freeze for AccessAdapter<T, V>
where T: Freeze, V: Freeze,

§

impl<T, V> RefUnwindSafe for AccessAdapter<T, V>

§

impl<T, V> Send for AccessAdapter<T, V>
where T: Send, V: Send,

§

impl<T, V> Sync for AccessAdapter<T, V>
where T: Sync, V: Sync,

§

impl<T, V> Unpin for AccessAdapter<T, V>
where T: Unpin, V: Unpin,

§

impl<T, V> UnwindSafe for AccessAdapter<T, V>
where T: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.