#const-generics #serde #array #deserialize #deserializing

serde_arrays

A simple module to support serializing and deserializing const generic or arbitrarily-large arrays

1 unstable release

0.1.0 May 7, 2021

#604 in Encoding

Download history 4641/week @ 2024-01-05 5057/week @ 2024-01-12 5268/week @ 2024-01-19 4786/week @ 2024-01-26 4949/week @ 2024-02-02 5430/week @ 2024-02-09 7082/week @ 2024-02-16 7717/week @ 2024-02-23 6188/week @ 2024-03-01 6947/week @ 2024-03-08 6620/week @ 2024-03-15 6377/week @ 2024-03-22 8046/week @ 2024-03-29 7840/week @ 2024-04-05 8557/week @ 2024-04-12 6793/week @ 2024-04-19

32,612 downloads per month
Used in 50 crates (21 directly)

MIT/Apache

10KB
63 lines

serde_arrays

A simple module to support serializing and deserializing const generic or arbitrarily-large arrays.

use serde::{Serialize, Deserialize};
use serde_json;

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
struct GenericArray<const N: usize> {
    #[serde(with = "serde_arrays")]
    arr: [u32; N],
}

let data = GenericArray{ arr: [1; 16] };
let json = serde_json::to_string(&data)?;
let de_data = serde_json::from_str(&json)?;

assert_eq!(data, de_data);
# Ok::<(), serde_json::Error>(())

MSRV

The minimum supported Rust version (MSRV) for serde_arrays is 1.51.0.

License

Licensed under either of

at your option.

Contribution

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

~110–350KB