#serde #byte #no-alloc #serde-derive

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

#2385 in Encoding

Download history 2522/week @ 2024-11-16 2623/week @ 2024-11-23 2538/week @ 2024-11-30 2666/week @ 2024-12-07 1983/week @ 2024-12-14 1083/week @ 2024-12-21 1557/week @ 2024-12-28 2549/week @ 2025-01-04 2591/week @ 2025-01-11 2729/week @ 2025-01-18 2764/week @ 2025-01-25 2629/week @ 2025-02-01 2833/week @ 2025-02-08 3288/week @ 2025-02-15 3112/week @ 2025-02-22 3149/week @ 2025-03-01

12,906 downloads per month
Used in 17 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

~99–325KB