#serialize-deserialize #serde #vec #hash-map #json-object

no-std serde-tuple-vec-map

Deserialize a serialized map to a Vec<(K, V)> in serde

6 releases (2 stable)

Uses old Rust 2015

1.0.1 Apr 4, 2022
1.0.0 Feb 8, 2020
0.2.2 Feb 8, 2020
0.2.1 Jan 5, 2018
0.1.0 Mar 28, 2017

#416 in Encoding

Download history 6830/week @ 2024-06-14 6544/week @ 2024-06-21 5062/week @ 2024-06-28 5072/week @ 2024-07-05 6661/week @ 2024-07-12 6492/week @ 2024-07-19 6550/week @ 2024-07-26 6097/week @ 2024-08-02 6779/week @ 2024-08-09 5866/week @ 2024-08-16 6005/week @ 2024-08-23 6287/week @ 2024-08-30 6877/week @ 2024-09-06 5800/week @ 2024-09-13 6327/week @ 2024-09-20 5025/week @ 2024-09-27

25,271 downloads per month
Used in 20 crates (16 directly)

MIT license

8KB
69 lines

serde-tuple-vec-map

Build Status

Deserialize maps or JSON objects in serde to a vec of tuples rather than a HashMap for when you're only ever going to iterate over the result.

Usage:

// replace this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
    data: HashMap<KeyType, ValueType>,
}

// with this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
    #[serde(with = "tuple_vec_map")]
    data: Vec<(KeyType, ValueType)>,
}

The serialized format remains exactly the same, the only difference is in how the data is decoded in Rust.

serde-tuple-vec-map supports no_std builds by using Vec defined in the alloc crate. If you're on rust 1.36.0 or newer, you can enable this with default-features=false:

[dependencies.serde-tuple-vec-map]
version = "1"
default-features = false

Note: This crate is complete, and passively maintained. It depends solely on serde and features present in stable rust. The minimum supported rust version 1.13.0 when using default features, and 1.36.0 for default-features = false.

Full usage example in tests/integration.rs, documentation at https://docs.rs/serde-tuple-vec-map.

Dependencies

~110–340KB