#byte #serde #serialization #no-std #derive-deserialize #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

#889 in Encoding

Download history 219/week @ 2023-12-23 293/week @ 2023-12-30 399/week @ 2024-01-06 494/week @ 2024-01-13 428/week @ 2024-01-20 745/week @ 2024-01-27 406/week @ 2024-02-03 741/week @ 2024-02-10 584/week @ 2024-02-17 918/week @ 2024-02-24 932/week @ 2024-03-02 1552/week @ 2024-03-09 1182/week @ 2024-03-16 1234/week @ 2024-03-23 1239/week @ 2024-03-30 1011/week @ 2024-04-06

4,863 downloads per month
Used in 11 crates (3 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

~110–350KB