facet-value
facet-value provides a memory-efficient dynamic value type for representing
structured data similar to JSON, but with added support for binary data and datetime.
Features
- Pointer-sized
Valuetype: The mainValuetype is exactly one pointer in size - Eight value types: Null, Bool, Number, String, Bytes, Array, Object, DateTime
no_stdcompatible: Works with justalloc, no standard library required- Bytes support: First-class support for binary data (useful for MessagePack, CBOR, etc.)
- DateTime support: First-class support for temporal data (useful for TOML, YAML, etc.)
Design
Value uses a tagged pointer representation with 8-byte alignment, giving us 3 tag bits
to distinguish between value types. Inline values (null, true, false) don’t require
heap allocation.
facet-value
A memory-efficient dynamic value type for representing structured data, with support for bytes.
Features
- Pointer-sized:
Valueis exactly one pointer in size using tagged pointers - Rich type support: Null, Bool, Number, String, Bytes, Array, Object, DateTime
- Typed extraction: Convert from
Valueinto any type implementingFacet - Companion serializer: Use
facet-formatto serialize typed values intoValue
Example
use Facet;
use ;
use to_value;
// Convert a typed value to a dynamic Value
let person = Person ;
let value: Value = to_value.unwrap;
// Inspect the value dynamically
let obj = value.as_object.unwrap;
assert_eq!;
// Convert back to a typed value
let person2: Person = from_value.unwrap;
assert_eq!;
Sponsors
Thanks to all individual sponsors:
...along with corporate sponsors:
...without whom this work could not exist.
Special thanks
The facet logo was drawn by Misiasart.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.