Crates.io | serde_bytes_ng |
lib.rs | serde_bytes_ng |
version | 0.1.2 |
source | src |
created_at | 2023-12-09 16:32:52.297844 |
updated_at | 2023-12-10 10:31:54.496085 |
description | Optimized handling of `[u8; N]`, `&[u8]` and `Vec |
homepage | |
repository | https://github.com/so-schen/serde-bytes-ng.git |
max_upload_size | |
id | 1063780 |
size | 50,074 |
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.
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],
}