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

#579 in Encoding

Download history 8336/week @ 2024-11-08 7941/week @ 2024-11-15 7373/week @ 2024-11-22 8601/week @ 2024-11-29 9354/week @ 2024-12-06 7230/week @ 2024-12-13 3875/week @ 2024-12-20 3286/week @ 2024-12-27 7114/week @ 2025-01-03 9053/week @ 2025-01-10 9236/week @ 2025-01-17 8273/week @ 2025-01-24 10685/week @ 2025-01-31 11777/week @ 2025-02-07 5412/week @ 2025-02-14

29,345 downloads per month
Used in 70 crates (31 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

~99–320KB