Skip to main content

MapSkipError

Struct MapSkipError 

Source
pub struct MapSkipError<KA = Same, VA = Same>(/* private fields */);
Expand description

Skips entries of a map which cannot be deserialized.

Keys are deserialized with the adapter KA and values with VA (both Same by default). If either of them fails, the rest of the entry is skipped (see Sink::recover). Only errors of the entries are handled, errors of the data format and of layers still fail the deserialization. Supported are BTreeMap and HashMap. Serialization uses the inner adapters.

use std::collections::BTreeMap;
use deser::Deserialize;
use deser::adapters::MapSkipError;

#[derive(Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum Kind {
    A,
    B,
}

#[derive(Deserialize)]
pub struct Weights {
    // entries with unknown kinds are skipped
    #[deser(as = MapSkipError)]
    weights: BTreeMap<Kind, f64>,
}

Trait Implementations§

Source§

impl<'de, K, V, KA, VA> Deserialize<'de, BTreeMap<K, V>> for MapSkipError<KA, VA>
where K: Ord + Send, V: Send, KA: Deserialize<'de, K>, VA: Deserialize<'de, V>,

Source§

fn deserialize_into<'out>( out: &'out mut Option<BTreeMap<K, V>>, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that deserializes the value into the given slot. Read more
Source§

fn expecting() -> Cow<'static, str>

Returns what the value expects, for error messages. Read more
Source§

fn deserialize_atom( slot: &mut Slot<T, Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom into the slot. Read more
Source§

fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom that borrows from the data being deserialized into the slot. Read more
Source§

fn describe_type(d: &mut dyn Describe)

Describes the Rust shape of the type. Read more
Source§

fn initial_value() -> Option<T>

Provides the value of a missing struct field. Read more
Source§

fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that updates an existing value. Read more
Source§

impl<'de, K, V, H, KA, VA> Deserialize<'de, HashMap<K, V, H>> for MapSkipError<KA, VA>
where K: Hash + Eq + Send, V: Send, H: BuildHasher + Default + Send, KA: Deserialize<'de, K>, VA: Deserialize<'de, V>,

Available on crate feature std only.
Source§

fn deserialize_into<'out>( out: &'out mut Option<HashMap<K, V, H>>, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that deserializes the value into the given slot. Read more
Source§

fn expecting() -> Cow<'static, str>

Returns what the value expects, for error messages. Read more
Source§

fn deserialize_atom( slot: &mut Slot<T, Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom into the slot. Read more
Source§

fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom that borrows from the data being deserialized into the slot. Read more
Source§

fn describe_type(d: &mut dyn Describe)

Describes the Rust shape of the type. Read more
Source§

fn initial_value() -> Option<T>

Provides the value of a missing struct field. Read more
Source§

fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that updates an existing value. Read more
Source§

impl<'de, K, V, S, KA, VA> Deserialize<'de, HashMap<K, V, S>> for MapSkipError<KA, VA>
where K: Hash + Eq + Send, V: Send, S: BuildHasher + Default + Send, KA: Deserialize<'de, K>, VA: Deserialize<'de, V>,

Available on crate feature hashbrown only.
Source§

fn deserialize_into<'out>( out: &'out mut Option<HashMap<K, V, S>>, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that deserializes the value into the given slot. Read more
Source§

fn expecting() -> Cow<'static, str>

Returns what the value expects, for error messages. Read more
Source§

fn deserialize_atom( slot: &mut Slot<T, Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom into the slot. Read more
Source§

fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom that borrows from the data being deserialized into the slot. Read more
Source§

fn describe_type(d: &mut dyn Describe)

Describes the Rust shape of the type. Read more
Source§

fn initial_value() -> Option<T>

Provides the value of a missing struct field. Read more
Source§

fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that updates an existing value. Read more
Source§

impl<'de, K, V, S, KA, VA> Deserialize<'de, IndexMap<K, V, S>> for MapSkipError<KA, VA>
where K: Hash + Eq + Send, V: Send, S: BuildHasher + Default + Send, KA: Deserialize<'de, K>, VA: Deserialize<'de, V>,

Available on crate feature indexmap only.
Source§

fn deserialize_into<'out>( out: &'out mut Option<IndexMap<K, V, S>>, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that deserializes the value into the given slot. Read more
Source§

fn expecting() -> Cow<'static, str>

Returns what the value expects, for error messages. Read more
Source§

fn deserialize_atom( slot: &mut Slot<T, Self>, atom: Atom<'_>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom into the slot. Read more
Source§

fn deserialize_borrowed_atom( slot: &mut Slot<T, Self>, atom: Atom<'de>, state: &mut State, ) -> Result<(), Error>

Deserializes an atom that borrows from the data being deserialized into the slot. Read more
Source§

fn describe_type(d: &mut dyn Describe)

Describes the Rust shape of the type. Read more
Source§

fn initial_value() -> Option<T>

Provides the value of a missing struct field. Read more
Source§

fn deserialize_update<'out>( value: &'out mut T, state: &mut State, ) -> SinkHandle<'out, 'de>

Creates a sink that updates an existing value. Read more
Source§

impl<K, V, KA, VA> Serialize<BTreeMap<K, V>> for MapSkipError<KA, VA>
where K: Sync, V: Sync, KA: Serialize<K>, VA: Serialize<V>,

Source§

fn serialize<'a>( value: &'a BTreeMap<K, V>, state: &mut State, ) -> Result<Emit<'a>, Error>

Serializes the value.
Source§

fn container_shape(value: &BTreeMap<K, V>) -> ContainerShape

Returns the shape of the value if it’s a map or sequence. Read more
Source§

fn describe(value: &BTreeMap<K, V>, d: &mut dyn Describe)

Describes the Rust shape of the value. Read more
Source§

fn finish(value: &T, state: &mut State) -> Result<(), Error>

Invoked after the serialization finished. Read more
Source§

fn is_optional(value: &T) -> bool

Checks if the value represents an optional value. Read more
Source§

impl<K, V, H, KA, VA> Serialize<HashMap<K, V, H>> for MapSkipError<KA, VA>
where K: Sync, V: Sync, H: BuildHasher + Sync, KA: Serialize<K>, VA: Serialize<V>,

Available on crate feature std only.
Source§

fn serialize<'a>( value: &'a HashMap<K, V, H>, state: &mut State, ) -> Result<Emit<'a>, Error>

Serializes the value.
Source§

fn container_shape(value: &HashMap<K, V, H>) -> ContainerShape

Returns the shape of the value if it’s a map or sequence. Read more
Source§

fn describe(value: &HashMap<K, V, H>, d: &mut dyn Describe)

Describes the Rust shape of the value. Read more
Source§

fn finish(value: &T, state: &mut State) -> Result<(), Error>

Invoked after the serialization finished. Read more
Source§

fn is_optional(value: &T) -> bool

Checks if the value represents an optional value. Read more
Source§

impl<K, V, S, KA, VA> Serialize<HashMap<K, V, S>> for MapSkipError<KA, VA>
where K: Sync, V: Sync, S: Sync, KA: Serialize<K>, VA: Serialize<V>,

Available on crate feature hashbrown only.
Source§

fn serialize<'a>( value: &'a HashMap<K, V, S>, state: &mut State, ) -> Result<Emit<'a>, Error>

Serializes the value.
Source§

fn container_shape(value: &HashMap<K, V, S>) -> ContainerShape

Returns the shape of the value if it’s a map or sequence. Read more
Source§

fn describe(value: &HashMap<K, V, S>, d: &mut dyn Describe)

Describes the Rust shape of the value. Read more
Source§

fn finish(value: &T, state: &mut State) -> Result<(), Error>

Invoked after the serialization finished. Read more
Source§

fn is_optional(value: &T) -> bool

Checks if the value represents an optional value. Read more
Source§

impl<K, V, S, KA, VA> Serialize<IndexMap<K, V, S>> for MapSkipError<KA, VA>
where K: Sync, V: Sync, S: Sync, KA: Serialize<K>, VA: Serialize<V>,

Available on crate feature indexmap only.
Source§

fn serialize<'a>( value: &'a IndexMap<K, V, S>, state: &mut State, ) -> Result<Emit<'a>, Error>

Serializes the value.
Source§

fn container_shape(value: &IndexMap<K, V, S>) -> ContainerShape

Returns the shape of the value if it’s a map or sequence. Read more
Source§

fn describe(value: &IndexMap<K, V, S>, d: &mut dyn Describe)

Describes the Rust shape of the value. Read more
Source§

fn finish(value: &T, state: &mut State) -> Result<(), Error>

Invoked after the serialization finished. Read more
Source§

fn is_optional(value: &T) -> bool

Checks if the value represents an optional value. Read more

Auto Trait Implementations§

§

impl<KA, VA> Freeze for MapSkipError<KA, VA>

§

impl<KA, VA> RefUnwindSafe for MapSkipError<KA, VA>

§

impl<KA, VA> Send for MapSkipError<KA, VA>
where PhantomData<fn() -> (KA, VA)>: Send,

§

impl<KA, VA> Sync for MapSkipError<KA, VA>
where PhantomData<fn() -> (KA, VA)>: Sync,

§

impl<KA, VA> Unpin for MapSkipError<KA, VA>

§

impl<KA, VA> UnsafeUnpin for MapSkipError<KA, VA>

§

impl<KA, VA> UnwindSafe for MapSkipError<KA, VA>

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.