pub struct As<T, A> { /* private fields */ }Expand description
Holds a value that serializes and deserializes with an adapter.
This implements Serialize and Deserialize with the adapter A.
It’s useful to use adapters in places where #[deser(as = ...)] is not
available. The wrapper dereferences to the value.
use deser::adapters::{As, DisplayFromStr};
let values: Vec<As<u32, DisplayFromStr>> = vec![As::new(1), As::new(2)];
assert_eq!(*values[0], 1);Implementations§
Trait Implementations§
impl<T: Copy, A> Copy for As<T, A>
Source§impl<'de, T: Send, A: Deserialize<'de, T>> Deserialize<'de> for As<T, A>
impl<'de, T: Send, A: Deserialize<'de, T>> Deserialize<'de> for As<T, A>
Source§fn deserialize_into<'out>(
out: &'out mut Option<Self>,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_into<'out>( out: &'out mut Option<Self>, 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 initial_value() -> Option<Self>
fn initial_value() -> Option<Self>
Provides the value of a missing struct field. 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 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 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
impl<T: Eq, A> Eq for As<T, A>
Source§impl<T: Ord, A> Ord for As<T, A>
impl<T: Ord, A> Ord for As<T, A>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialOrd, A> PartialOrd for As<T, A>
impl<T: PartialOrd, A> PartialOrd for As<T, A>
Source§impl<T: Sync, A: Serialize<T>> Serialize for As<T, A>
impl<T: Sync, A: Serialize<T>> Serialize for As<T, A>
Source§fn serialize<'a>(value: &'a Self, state: &mut State) -> Result<Emit<'a>, Error>
fn serialize<'a>(value: &'a Self, state: &mut State) -> Result<Emit<'a>, Error>
Serializes the value.
Source§fn finish(value: &Self, state: &mut State) -> Result<(), Error>
fn finish(value: &Self, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn is_optional(value: &Self) -> bool
fn is_optional(value: &Self) -> bool
Checks if the value represents an optional value. Read more
Source§fn container_shape(value: &Self) -> ContainerShape
fn container_shape(value: &Self) -> ContainerShape
Returns the shape of the value if it’s a map or sequence. Read more
Auto Trait Implementations§
impl<T, A> Freeze for As<T, A>
impl<T, A> RefUnwindSafe for As<T, A>
impl<T, A> Send for As<T, A>
impl<T, A> Sync for As<T, A>
impl<T, A> Unpin for As<T, A>
impl<T, A> UnsafeUnpin for As<T, A>
impl<T, A> UnwindSafe for As<T, A>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.