pub trait Deserialize<'de>: Sized {
// Required method
fn deserialize<D>(
deserializer: D,
) -> Result<Self, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>;
}
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.
Object Safety§
Implementations on Foreign Types§
§impl Deserialize<'static> for UpdateProgress
impl Deserialize<'static> for UpdateProgress
fn deserialize<__D>(
__deserializer: __D,
) -> Result<UpdateProgress, <__D as Deserializer<'static>>::Error>where
__D: Deserializer<'static>,
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 Month
impl<'de> Deserialize<'de> for Month
fn deserialize<D>(
deserializer: D,
) -> Result<Month, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'de> Deserialize<'de> for Weekday
impl<'de> Deserialize<'de> for Weekday
fn deserialize<D>(
deserializer: D,
) -> Result<Weekday, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
fn deserialize<D>(
deserializer: D,
) -> Result<Value, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'de> Deserialize<'de> for DateTime<FixedOffset>
impl<'de> Deserialize<'de> for DateTime<FixedOffset>
Deserialize an RFC 3339 formatted string into a DateTime<FixedOffset>
As an extension to RFC 3339 this can deserialize to DateTime
s outside the range of 0-9999
years using an ISO 8601 syntax (which prepends an -
or +
).
See the serde
module for alternate deserialization formats.
fn deserialize<D>(
deserializer: D,
) -> Result<DateTime<FixedOffset>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'de> Deserialize<'de> for DateTime<Local>
impl<'de> Deserialize<'de> for DateTime<Local>
Deserialize an RFC 3339 formatted string into a DateTime<Local>
The value will remain the same instant in UTC, but the offset will be recalculated to match
that of the Local
platform time zone.
As an extension to RFC 3339 this can deserialize to DateTime
s outside the range of 0-9999
years using an ISO 8601 syntax (which prepends an -
or +
).
See the serde
module for alternate deserialization formats.
fn deserialize<D>(
deserializer: D,
) -> Result<DateTime<Local>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<'de> Deserialize<'de> for DateTime<Utc>
impl<'de> Deserialize<'de> for DateTime<Utc>
Deserialize an RFC 3339 formatted string into a DateTime<Utc>
If the value contains an offset from UTC that is not zero, the value will be converted to UTC.
As an extension to RFC 3339 this can deserialize to DateTime
s outside the range of 0-9999
years using an ISO 8601 syntax (which prepends an -
or +
).
See the serde
module for alternate deserialization formats.