Crate facet_value

Crate facet_value 

Source
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 Value type: The main Value type is exactly one pointer in size
  • Eight value types: Null, Bool, Number, String, Bytes, Array, Object, DateTime
  • no_std compatible: Works with just alloc, 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§

value
Creates a Value from a JSON-like syntax.

Structs§

ArrayIntoIter
Iterator over owned Values from a VArray.
FormattedValue
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.
ObjectIntoIter
Iterator over owned (VString, Value) pairs.
VArray
An array value.
VBytes
A binary data value.
VDateTime
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.
VSafeString
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.
ValueError
Error type for Value deserialization.
Values
Iterator over values.
ValuesMut
Iterator over mutable values.

Enums§

DateTimeKind
The kind of datetime value.
Destructured
Enum for destructuring a Value by ownership.
DestructuredMut
Enum for destructuring a Value by mutable reference.
DestructuredRef
Enum for destructuring a Value by reference.
OtherKind
Secondary discriminant for “Other” types (tag 7).
PathSegment
A segment in a deserialization path
ValueErrorKind
Specific error kinds for Value deserialization.
ValueType
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 Value into any type implementing Facet.