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>
impl<'de, K, V, KA, VA> Deserialize<'de, BTreeMap<K, V>> for MapSkipError<KA, VA>
Source§fn deserialize_into<'out>(
out: &'out mut Option<BTreeMap<K, V>>,
state: &mut State,
) -> SinkHandle<'out, 'de>
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>
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>
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>
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)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
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>
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.
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>
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>
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>
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>
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)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
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>
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.
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>
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>
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>
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>
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)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
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>
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.
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>
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>
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>
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>
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)
fn describe_type(d: &mut dyn Describe)
Describes the Rust shape of the type. Read more
Source§fn initial_value() -> Option<T>
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>
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>
impl<K, V, KA, VA> Serialize<BTreeMap<K, V>> for MapSkipError<KA, VA>
Source§fn serialize<'a>(
value: &'a BTreeMap<K, V>,
state: &mut State,
) -> Result<Emit<'a>, Error>
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
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)
fn describe(value: &BTreeMap<K, V>, d: &mut dyn Describe)
Describes the Rust shape of the value. Read more
Source§impl<K, V, H, KA, VA> Serialize<HashMap<K, V, H>> for MapSkipError<KA, VA>
Available on crate feature std only.
impl<K, V, H, KA, VA> Serialize<HashMap<K, V, H>> for MapSkipError<KA, VA>
Available on crate feature
std only.Source§fn serialize<'a>(
value: &'a HashMap<K, V, H>,
state: &mut State,
) -> Result<Emit<'a>, Error>
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
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)
fn describe(value: &HashMap<K, V, H>, d: &mut dyn Describe)
Describes the Rust shape of the value. Read more
Source§impl<K, V, S, KA, VA> Serialize<HashMap<K, V, S>> for MapSkipError<KA, VA>
Available on crate feature hashbrown only.
impl<K, V, S, KA, VA> Serialize<HashMap<K, V, S>> for MapSkipError<KA, VA>
Available on crate feature
hashbrown only.Source§fn serialize<'a>(
value: &'a HashMap<K, V, S>,
state: &mut State,
) -> Result<Emit<'a>, Error>
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
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)
fn describe(value: &HashMap<K, V, S>, d: &mut dyn Describe)
Describes the Rust shape of the value. Read more
Source§impl<K, V, S, KA, VA> Serialize<IndexMap<K, V, S>> for MapSkipError<KA, VA>
Available on crate feature indexmap only.
impl<K, V, S, KA, VA> Serialize<IndexMap<K, V, S>> for MapSkipError<KA, VA>
Available on crate feature
indexmap only.Source§fn serialize<'a>(
value: &'a IndexMap<K, V, S>,
state: &mut State,
) -> Result<Emit<'a>, Error>
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
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)
fn describe(value: &IndexMap<K, V, S>, d: &mut dyn Describe)
Describes the Rust shape of the 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>
impl<KA, VA> Sync for MapSkipError<KA, VA>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more