#const-generics #serialize-deserialize #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

#543 in Encoding

Download history 9525/week @ 2024-06-12 9066/week @ 2024-06-19 9079/week @ 2024-06-26 8568/week @ 2024-07-03 9370/week @ 2024-07-10 11262/week @ 2024-07-17 7224/week @ 2024-07-24 8344/week @ 2024-07-31 9566/week @ 2024-08-07 8888/week @ 2024-08-14 11840/week @ 2024-08-21 8782/week @ 2024-08-28 8865/week @ 2024-09-04 7305/week @ 2024-09-11 7323/week @ 2024-09-18 7102/week @ 2024-09-25

32,126 downloads per month
Used in 64 crates (27 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