facet_value/
lib.rs

1//! `facet-value` provides a memory-efficient dynamic value type for representing
2//! structured data similar to JSON, but with added support for binary data and datetime.
3//!
4//! # Features
5//!
6//! - **Pointer-sized `Value` type**: The main `Value` type is exactly one pointer in size
7//! - **Eight value types**: Null, Bool, Number, String, Bytes, Array, Object, DateTime
8//! - **`no_std` compatible**: Works with just `alloc`, no standard library required
9//! - **Bytes support**: First-class support for binary data (useful for MessagePack, CBOR, etc.)
10//! - **DateTime support**: First-class support for temporal data (useful for TOML, YAML, etc.)
11//!
12//! # Design
13//!
14//! `Value` uses a tagged pointer representation with 8-byte alignment, giving us 3 tag bits
15//! to distinguish between value types. Inline values (null, true, false) don't require
16//! heap allocation.
17
18#![cfg_attr(not(feature = "std"), no_std)]
19#![warn(missing_docs)]
20#![warn(clippy::std_instead_of_core)]
21#![warn(clippy::std_instead_of_alloc)]
22
23#[cfg(feature = "alloc")]
24extern crate alloc;
25
26#[cfg(feature = "alloc")]
27mod macros;
28
29mod value;
30pub use value::*;
31
32mod number;
33pub use number::*;
34
35mod string;
36pub use string::*;
37
38mod bytes;
39pub use bytes::*;
40
41mod array;
42pub use array::*;
43
44mod object;
45pub use object::*;
46
47mod datetime;
48pub use datetime::*;
49
50mod other;
51pub use other::{OtherKind, VQName, VUuid};
52
53#[cfg(feature = "alloc")]
54mod facet_impl;
55#[cfg(feature = "alloc")]
56pub use facet_impl::VALUE_SHAPE;
57
58#[cfg(feature = "alloc")]
59mod deserialize;
60#[cfg(feature = "diagnostics")]
61pub use deserialize::ValueErrorReport;
62#[cfg(feature = "alloc")]
63pub use deserialize::{PathSegment, ValueError, ValueErrorKind, from_value};
64
65#[cfg(feature = "alloc")]
66mod format;
67#[cfg(feature = "alloc")]
68pub use format::{FormattedValue, format_value, format_value_with_spans};
69
70#[cfg(feature = "diagnostics")]
71mod highlight;
72
73#[cfg(all(test, feature = "alloc"))]
74mod inline_roundtrip_tests;