Function serde_bytes::deserialize

source ยท
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where T: Deserialize<'de>, D: Deserializer<'de>,
Expand description

Serde deserialize_with function to deserialize bytes efficiently.

This function can be used with either of the following Serde attributes:

  • #[serde(with = "serde_bytes")]
  • #[serde(deserialize_with = "serde_bytes::deserialize")]
use serde::Deserialize;

#[derive(Deserialize)]
struct Packet {
    #[serde(with = "serde_bytes")]
    payload: Vec<u8>,

    #[serde(with = "serde_bytes")]
    byte_array: [u8; 314],
}