#serialize-deserialize #serde #serialization #byte #no-alloc #serde-derive #derive-deserialize

no-std serde_bytes_ng

Optimized handling of [u8; N], &[u8] and Vec<u8> for Serde

3 releases

0.1.2 Dec 10, 2023
0.1.1 Dec 10, 2023
0.1.0 Dec 9, 2023

#2064 in Encoding

Download history 2317/week @ 2024-07-29 1880/week @ 2024-08-05 1913/week @ 2024-08-12 1679/week @ 2024-08-19 1889/week @ 2024-08-26 1655/week @ 2024-09-02 2019/week @ 2024-09-09 1952/week @ 2024-09-16 2427/week @ 2024-09-23 2125/week @ 2024-09-30 1870/week @ 2024-10-07 2990/week @ 2024-10-14 2659/week @ 2024-10-21 2117/week @ 2024-10-28 2598/week @ 2024-11-04 2362/week @ 2024-11-11

9,825 downloads per month
Used in 15 crates (2 directly)

MIT/Apache

28KB
727 lines

ci crates.io

serde-bytes-ng

Integrate serde_bytes and generic byte array support.

The goal is the contribute to upstream serde_bytes, but because lack of response from its author, create a separate crate with generic byte array support plus latest serde_bytes codes so that can be released as one crate.

Example

use serde::{Deserialize, Serialize};

#[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],

}

lib.rs:

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],
}

Dependencies

~100–335KB