Valence
Transparent, policy-aware data
Valence is a schema-driven ORM for Rust with privacy-aware models, composable storage adapters, and host-injectable ports. Wire backends at boot through Valence::builder(); trait ports live in valence-core and engines live in feature-gated valence-backend-* crates.Where it lands
Apps compile Valence schemas into Model APIs and bind them with Valence::builder().Define schemas with valence_schema!, generate Model APIs via valence-codegen in build.rs, and register backends through ValenceBuilder. One runtime may host heterogeneous engines; each operation stays on one backend. Host ports for secrets, actors, endpoints, and telemetry inject at boot next to the model. The capacity campaign measures mixed create, hot get, cache-off primary get, and equality filter work on SQLite and hybrid. Isolated hot-get and filter numbers stay in the component study. Published on crates.io as uf-valence; Rust imports use valence::.
In the workspace
Apps compile Valence schemas into Model APIs and bind them with Valence::builder().Code sample
From the upstream getting-started docs — see also all code recipes on Resources.
Valence schemaValence
Schema DSL + builder backends
use std::sync::Arc;
use valence::{
Database, DatabaseFromEngine, FieldType, InMemoryBackend, Valence, MEM_ENGINE_ID,
valence_schema,
};
const COUNTER_DB: DatabaseFromEngine = Database::from_engine("default", MEM_ENGINE_ID);
valence_schema! {
Counter {
table: "counter",
version: "0.1.0",
description: "Simple counter",
database: COUNTER_DB,
fields: [
id: { r#type: FieldType::String, primary_key: true, required: true },
value: { r#type: FieldType::Integer, required: true },
],
}
}
let valence = Valence::builder()
.add_backend("default", Arc::new(InMemoryBackend::new()))
.build()?;