14 releases

0.5.1 Mar 4, 2023
0.4.1 Mar 25, 2022
0.3.2 Mar 11, 2021
0.3.1 Dec 28, 2020
0.1.3 Dec 29, 2018

#38 in Encoding

Download history 83234/week @ 2024-08-13 73054/week @ 2024-08-20 80050/week @ 2024-08-27 85488/week @ 2024-09-03 77402/week @ 2024-09-10 75424/week @ 2024-09-17 78225/week @ 2024-09-24 76740/week @ 2024-10-01 75269/week @ 2024-10-08 83389/week @ 2024-10-15 78158/week @ 2024-10-22 71744/week @ 2024-10-29 80059/week @ 2024-11-05 79789/week @ 2024-11-12 86574/week @ 2024-11-19 64703/week @ 2024-11-26

327,605 downloads per month
Used in 758 crates (156 directly)

MIT/Apache

12KB
178 lines

serde-big-array

docs crates.io dependency status

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:

MSRV

The minimum supported Rust version (MSRV) is Rust 1.56.0.

License

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.

License of your contributions

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.

Dependencies

~100–330KB