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: DeserializeAs<'de, T>> Deserialize<'de> for As<T, A>
impl<'de, T: Send, A: DeserializeAs<'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 initial_value() -> Option<Self>
fn initial_value() -> Option<Self>
Provides the value of a missing struct field. Read more
Source§fn deserialize_update<'out>(
value: &'out mut Self,
state: &mut State,
) -> SinkHandle<'out, 'de>
fn deserialize_update<'out>( value: &'out mut Self, 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: SerializeAs<T>> Serialize for As<T, A>
impl<T: Sync, A: SerializeAs<T>> Serialize for As<T, A>
Source§fn serialize(&self, state: &mut State) -> Result<Chunk<'_>, Error>
fn serialize(&self, state: &mut State) -> Result<Chunk<'_>, Error>
Serializes this serializable.
Source§fn finish(&self, state: &mut State) -> Result<(), Error>
fn finish(&self, state: &mut State) -> Result<(), Error>
Invoked after the serialization finished. Read more
Source§fn is_optional(&self) -> bool
fn is_optional(&self) -> bool
Checks if the current value that would be serialized represents an
optional value. Read more
Source§fn container_shape(&self) -> ContainerShape
fn container_shape(&self) -> ContainerShape
Returns the shape of this 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.