#const-generics #serialization #serde

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

#558 in Encoding

Download history 6704/week @ 2024-03-14 6292/week @ 2024-03-21 8219/week @ 2024-03-28 7766/week @ 2024-04-04 8306/week @ 2024-04-11 8201/week @ 2024-04-18 8680/week @ 2024-04-25 6535/week @ 2024-05-02 7577/week @ 2024-05-09 7456/week @ 2024-05-16 7001/week @ 2024-05-23 8367/week @ 2024-05-30 7175/week @ 2024-06-06 9491/week @ 2024-06-13 9803/week @ 2024-06-20 7028/week @ 2024-06-27

35,098 downloads per month
Used in 60 crates (24 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–345KB