pub trait Deserialize<'de>: Sized {
// Required method
fn deserialize<D>(
deserializer: D,
) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>;
}
storage
only.Expand description
A data structure that can be deserialized from any data format supported by Serde.
Serde provides Deserialize
implementations for many Rust primitive and
standard library types. The complete list is here. All of these
can be deserialized using Serde out of the box.
Additionally, Serde provides a procedural macro called serde_derive
to
automatically generate Deserialize
implementations for structs and enums
in your program. See the derive section of the manual for how to
use this.
In rare cases it may be necessary to implement Deserialize
manually for
some type in your program. See the Implementing
Deserialize
section of the manual for more about this.
Third-party crates may provide Deserialize
implementations for types that
they expose. For example the linked-hash-map
crate provides a
LinkedHashMap<K, V>
type that is deserializable by Serde because the crate
provides an implementation of Deserialize
for it.
§Lifetime
The 'de
lifetime of this trait is the lifetime of data that may be
borrowed by Self
when deserialized. See the page Understanding
deserializer lifetimes for a more detailed explanation of these lifetimes.
Required Methods§
Sourcefn deserialize<D>(
deserializer: D,
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer.
See the Implementing Deserialize
section of the
manual for more information about how to implement this method.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'de> Deserialize<'de> for IpAddr
Available on crate feature std
or non-no_core_net
only.
impl<'de> Deserialize<'de> for IpAddr
std
or non-no_core_net
only.fn deserialize<D>(
deserializer: D,
) -> Result<IpAddr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for SocketAddr
Available on crate feature std
or non-no_core_net
only.
impl<'de> Deserialize<'de> for SocketAddr
std
or non-no_core_net
only.fn deserialize<D>(
deserializer: D,
) -> Result<SocketAddr, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for bool
impl<'de> Deserialize<'de> for bool
fn deserialize<D>(
deserializer: D,
) -> Result<bool, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for char
impl<'de> Deserialize<'de> for char
fn deserialize<D>(
deserializer: D,
) -> Result<char, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for f32
impl<'de> Deserialize<'de> for f32
fn deserialize<D>(
deserializer: D,
) -> Result<f32, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for f64
impl<'de> Deserialize<'de> for f64
fn deserialize<D>(
deserializer: D,
) -> Result<f64, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for i8
impl<'de> Deserialize<'de> for i8
fn deserialize<D>(
deserializer: D,
) -> Result<i8, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for i16
impl<'de> Deserialize<'de> for i16
fn deserialize<D>(
deserializer: D,
) -> Result<i16, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for i32
impl<'de> Deserialize<'de> for i32
fn deserialize<D>(
deserializer: D,
) -> Result<i32, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for i64
impl<'de> Deserialize<'de> for i64
fn deserialize<D>(
deserializer: D,
) -> Result<i64, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for i128
impl<'de> Deserialize<'de> for i128
fn deserialize<D>(
deserializer: D,
) -> Result<i128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for isize
impl<'de> Deserialize<'de> for isize
fn deserialize<D>(
deserializer: D,
) -> Result<isize, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for u8
impl<'de> Deserialize<'de> for u8
fn deserialize<D>(
deserializer: D,
) -> Result<u8, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for u16
impl<'de> Deserialize<'de> for u16
fn deserialize<D>(
deserializer: D,
) -> Result<u16, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for u32
impl<'de> Deserialize<'de> for u32
fn deserialize<D>(
deserializer: D,
) -> Result<u32, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for u64
impl<'de> Deserialize<'de> for u64
fn deserialize<D>(
deserializer: D,
) -> Result<u64, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for u128
impl<'de> Deserialize<'de> for u128
fn deserialize<D>(
deserializer: D,
) -> Result<u128, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for ()
impl<'de> Deserialize<'de> for ()
fn deserialize<D>(
deserializer: D,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for usize
impl<'de> Deserialize<'de> for usize
fn deserialize<D>(
deserializer: D,
) -> Result<usize, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for SocketAddrV4
impl<'de> Deserialize<'de> for SocketAddrV4
fn deserialize<D>(
deserializer: D,
) -> Result<SocketAddrV4, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for SocketAddrV6
impl<'de> Deserialize<'de> for SocketAddrV6
fn deserialize<D>(
deserializer: D,
) -> Result<SocketAddrV6, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<i8>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<i8>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<i8>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<i16>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<i16>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<i16>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<i32>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<i32>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<i32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<i64>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<i64>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<i64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<i128>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<i128>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<i128>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<isize>
Available on non-no_num_nonzero_signed
only.
impl<'de> Deserialize<'de> for NonZero<isize>
no_num_nonzero_signed
only.fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<isize>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<u8>
impl<'de> Deserialize<'de> for NonZero<u8>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<u8>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<u16>
impl<'de> Deserialize<'de> for NonZero<u16>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<u16>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<u32>
impl<'de> Deserialize<'de> for NonZero<u32>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<u32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<u64>
impl<'de> Deserialize<'de> for NonZero<u64>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<u64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<u128>
impl<'de> Deserialize<'de> for NonZero<u128>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<u128>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for NonZero<usize>
impl<'de> Deserialize<'de> for NonZero<usize>
fn deserialize<D>(
deserializer: D,
) -> Result<NonZero<usize>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<i8>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<i8>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<i8>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<i16>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<i16>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<i16>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<i32>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<i32>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<i32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<i64>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<i64>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<i64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<i128>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<i128>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<i128>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<isize>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<isize>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<isize>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<u8>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<u8>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<u8>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<u16>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<u16>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<u16>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<u32>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<u32>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<u32>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<u64>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<u64>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<u64>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<u128>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<u128>
no_core_num_saturating
only.fn deserialize<D>(
deserializer: D,
) -> Result<Saturating<u128>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserialize<'de> for Saturating<usize>
Available on non-no_core_num_saturating
only.
impl<'de> Deserialize<'de> for Saturating<usize>
no_core_num_saturating
only.