Trait serde::Deserialize

source ·
pub trait Deserialize<'de>: Sized {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::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§

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.

Implementations on Foreign Types§

Implementors§

impl<'de, const LENGTH: usize> Deserialize<'de> for StackByteArray<LENGTH>

impl<'de> Deserialize<'de> for HeapBytes

impl<'de> Deserialize<'de> for LockedBytes

impl<'de, const LENGTH: usize> Deserialize<'de> for Locked<HeapByteArray<LENGTH>>

impl<'de, EphemeralPublicKey, Mac, Data> Deserialize<'de> for DryocBox<EphemeralPublicKey, Mac, Data>where
    EphemeralPublicKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>,
    Mac: Deserialize<'de> + ByteArray<CRYPTO_BOX_MACBYTES>,
    Data: Deserialize<'de> + Bytes,

impl<'de, Mac, Data> Deserialize<'de> for DryocSecretBox<Mac, Data>where
    Mac: Deserialize<'de> + ByteArray<CRYPTO_SECRETBOX_MACBYTES>,
    Data: Deserialize<'de> + Bytes,

impl<'de, Key, Context> Deserialize<'de> for Kdf<Key, Context>where
    Key: Deserialize<'de> + ByteArray<CRYPTO_KDF_KEYBYTES>,
    Context: Deserialize<'de> + ByteArray<CRYPTO_KDF_CONTEXTBYTES>,

impl<'de, PublicKey, SecretKey> Deserialize<'de> for KeyPair<PublicKey, SecretKey>where
    PublicKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_PUBLICKEYBYTES>,
    SecretKey: Deserialize<'de> + ByteArray<CRYPTO_BOX_SECRETKEYBYTES>,

impl<'de, SessionKey> Deserialize<'de> for Session<SessionKey>where
    SessionKey: Deserialize<'de> + ByteArray<CRYPTO_KX_SESSIONKEYBYTES>,

impl<'de> Deserialize<'de> for Config

impl<'de, Hash, Salt> Deserialize<'de> for PwHash<Hash, Salt>where
    Hash: Deserialize<'de> + Bytes,
    Salt: Deserialize<'de> + Bytes,

impl<'de, PublicKey, SecretKey> Deserialize<'de> for SigningKeyPair<PublicKey, SecretKey>where
    PublicKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_PUBLICKEYBYTES>,
    SecretKey: Deserialize<'de> + ByteArray<CRYPTO_SIGN_SECRETKEYBYTES>,

impl<'de, Signature, Message> Deserialize<'de> for SignedMessage<Signature, Message>where
    Signature: Deserialize<'de> + ByteArray<CRYPTO_SIGN_BYTES>,
    Message: Deserialize<'de> + Bytes,