'Buckets' for [Serde] Deserialisation
The [Bucket
] stores data (and it's type) according to the serde data model,
allowing for format analogous representation of any self-describing type.
This type is intended for use in the deserialisation process, where the structure is
not known until a given field is parsed. This type can store that data without
copying or taking ownership of heap allocated types (unlike serde_value
).
Under the hood, the Bucket
type is a vec
of 'nodes' that depict the type, it's value
and other attributes. This makes it easier to work with and removes some of the
heap allocation that you find with recursive data structures.
This is a crate created for my projects, and as such is unlikely to be maintained. It might be worth saying 'bucket' and use [
serde_value
] instead.
The following examples use serde_json
as the format
```rust use serde_bucket::Bucket;
// parse an input using your favourite serde library
// deserialise it into the Bucket
type.
let input = r#"{"a": 10, "b": false}"#;
let mut bucket: Bucket = serdejson::fromstr(&input).unwrap();
// our example structure
struct Example { a: u8, b: bool }
// use deserialize_into
to "deserialise into" a given type.
// the error type (in this serde_json::Error
) must implement serde::de::Error
let value = bucket.deserializeinto::
Merci Buckets for stopping by <3
- here is My Twitter if you want to say hello