Expand description
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.
Macros§
Structs§
- Array
Into Iter - Iterator over owned
Values from aVArray. - Formatted
Value - Result of formatting a value with span tracking
- Iter
- Iterator over
(&VString, &Value)pairs. - IterMut
- Iterator over
(&VString, &mut Value)pairs. - Keys
- Iterator over keys.
- Object
Into Iter - Iterator over owned
(VString, Value)pairs. - VArray
- An array value.
- VBytes
- A binary data value.
- VDate
Time - A datetime value.
- VNumber
- A JSON number value.
- VObject
- An object (map) value.
- VQName
- A qualified name consisting of an optional namespace and a local name.
- VSafe
String - A string value marked as “safe” (e.g., pre-escaped HTML that should not be escaped again).
- VString
- A string value.
- VUuid
- A 128-bit universally unique identifier (UUID).
- Value
- A dynamic value that can represent null, booleans, numbers, strings, bytes, arrays, or objects.
- Value
Error - Error type for Value deserialization.
- Values
- Iterator over values.
- Values
Mut - Iterator over mutable values.
Enums§
- Date
Time Kind - The kind of datetime value.
- Destructured
- Enum for destructuring a
Valueby ownership. - Destructured
Mut - Enum for destructuring a
Valueby mutable reference. - Destructured
Ref - Enum for destructuring a
Valueby reference. - Other
Kind - Secondary discriminant for “Other” types (tag 7).
- Path
Segment - A segment in a deserialization path
- Value
Error Kind - Specific error kinds for Value deserialization.
- Value
Type - Enum distinguishing the value types.
Statics§
- VALUE_
SHAPE - The static shape for
Value.
Functions§
- format_
value - Format a Value as JSON-like text (no span tracking, just plain output)
- format_
value_ with_ spans - Format a Value as JSON-like text with span tracking
- from_
value - Deserialize a
Valueinto any type implementingFacet.