facet-value

Crates.iofacet-value
lib.rsfacet-value
version0.43.2
created_at2025-12-11 16:24:34.359821+00
updated_at2026-01-23 18:02:43.013835+00
descriptionMemory-efficient dynamic value type for facet, supporting JSON-like data plus bytes
homepagehttps://facet.rs
repositoryhttps://github.com/facet-rs/facet
max_upload_size
id1980036
size313,151
Amos Wenger (fasterthanlime)

documentation

README

facet-value

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

facet-value

A memory-efficient dynamic value type for representing structured data, with support for bytes.

Features

  • Pointer-sized: Value is exactly one pointer in size using tagged pointers
  • Rich type support: Null, Bool, Number, String, Bytes, Array, Object, DateTime
  • Bidirectional conversion: Convert between Value and any type implementing Facet

Example

use facet::Facet;
use facet_value::{Value, to_value, from_value};

#[derive(Debug, Facet, PartialEq)]
struct Person {
    name: String,
    age: u32,
}

// Convert a typed value to a dynamic Value
let person = Person { name: "Alice".into(), age: 30 };
let value: Value = to_value(&person).unwrap();

// Inspect the value dynamically
let obj = value.as_object().unwrap();
assert_eq!(obj.get("name").unwrap().as_string().unwrap().as_str(), "Alice");

// Convert back to a typed value
let person2: Person = from_value(value).unwrap();
assert_eq!(person, person2);

Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

...along with corporate sponsors:

AWS Zed Depot

...without whom this work could not exist.

Special thanks

The facet logo was drawn by Misiasart.

License

Licensed under either of:

at your option.

Commit count: 3380

cargo fmt