Crate serde_bytes_ng

source ·
Expand description

Wrapper types to enable optimized handling of [u8; N], &[u8] and Vec<u8>.

This crate is a fork of serde_bytes that adds support for [u8; N] and &[u8; N].

#[derive(Deserialize, Serialize)]
struct Efficient<'a> {
    #[serde(with = "serde_bytes_ng")]
    bytes: &'a [u8],

    #[serde(with = "serde_bytes_ng")]
    byte_buf: Vec<u8>,

    #[serde(with = "serde_bytes_ng")]
    byte_array: [u8; 188],

    #[serde(with = "serde_bytes_ng", borrow)]
    byte_array_ref: &'a [u8; 188],
}

Structs

  • Wrapper around Vec<u8> to serialize and deserialize efficiently.
  • Wrapper around [u8] to serialize and deserialize efficiently.

Traits

  • Types that can be deserialized via #[serde(with = "serde_bytes_ng")].
  • Types that can be serialized via #[serde(with = "serde_bytes_ng")].

Functions

  • Serde deserialize_with function to deserialize bytes efficiently.
  • Serde serialize_with function to serialize bytes efficiently.