Crates.io | serde-big-array |
lib.rs | serde-big-array |
version | 0.5.1 |
source | src |
created_at | 2018-12-09 19:57:17.985699 |
updated_at | 2023-03-04 20:38:29.574008 |
description | Big array helper for serde. |
homepage | |
repository | https://github.com/est31/serde-big-array |
max_upload_size | |
id | 100987 |
size | 21,265 |
Big array helper for serde. The purpose of this crate is to make (de-)serializing arrays of sizes > 32 easy. This solution is needed until serde adopts const generics support.
Bases on this snippet.
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate serde_big_array;
use serde_big_array::BigArray;
#[derive(Serialize, Deserialize)]
struct S {
#[serde(with = "BigArray")]
arr: [u8; 64],
}
#[test]
fn test() {
let s = S { arr: [1; 64] };
let j = serde_json::to_string(&s).unwrap();
let s_back = serde_json::from_str::<S>(&j).unwrap();
assert!(&s.arr[..] == &s_back.arr[..]);
}
Important links:
The minimum supported Rust version (MSRV) is Rust 1.56.0.
This crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0), at your option.
See LICENSE-APACHE and LICENSE-MIT for details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.