Expand description
§anda_db_schema
Type system and schema definitions for Anda DB, the embedded knowledge & memory database for AI Agents.
This crate provides the building blocks used across all Anda DB sub-crates:
FieldType(aliasFt): a closed enum of every type a field may declare, including primitive, composite (Array,Map) andOptionvariants.FieldValue(aliasFv): the runtime representation of an actual value. It can losslessly round-trip withCborand is serde-compatible for both human-readable (JSON) and binary (CBOR) formats.FieldEntry(aliasFe): metadata for a single field — name, type, description, uniqueness flag and a stable numericidxused as the on-disk key (instead of the field name) to keep records compact.Schema/SchemaBuilder: an ordered, versioned collection ofFieldEntryvalues. Schemas are versioned and support forward-compatible migration viaSchema::upgrade_with.Document/DocumentOwned: schema-bound and standalone document representations.Resource: a predefined struct describing an external resource (file, blob, URI…) referenced from a document.
§Derive macros
Two macros are re-exported from anda_db_derive:
AndaDBSchema— generates aschema()constructor from a Rust struct.FieldTyped— generates afield_type()constructor returning the nestedFieldType::Mapdescribing the struct’s layout.
See the crate-level guide in docs/anda_db_schema.md for a full tour and
SCHEMA.md for the on-disk format.
§Storage format
All values are normalized to CBOR for persistence. The CBOR encoding is
deterministic and small; floating point values disallow NaN so that
FieldValue keeps a meaningful PartialEq.
Structs§
- Byte
Array B64 - Wrapper around
[u8; N]to serialize and deserialize efficiently. If the serialization format is human readable (formats like JSON and YAML), it will be encoded in Base64URL. Otherwise, it will be serialized as a byte array. - Byte
BufB64 - Wrapper around
Vec<u8>to serialize and deserialize efficiently. If the serialization format is human readable (formats like JSON and YAML), it will be encoded in Base64URL. Otherwise, it will be serialized as a byte array. - Document
- A single Anda DB document together with its
Schema. - Document
Owned - A standalone document without an attached
Schema. - Field
Entry - Metadata for a single field in a
Schema. - Map
- Re-export Map from serde_json Represents a JSON key/value type.
- Resource
- Represents a resource for AI Agents.
- Schema
- Document schema definition for Anda DB.
- Schema
Builder - SchemaBuilder is used to construct a Schema instance. It provides methods to add fields and build the final schema.
- bf16
- Re-export bf16 from half crate
A 16-bit floating point type implementing the
bfloat16format.
Enums§
- Field
Key - A key in a
FieldType::Map/FieldValue::Map. - Field
Type - The type of a field declared in a
Schema. - Field
Value - The runtime value of a field.
- Schema
Error - Errors produced when building, validating or (de)serializing a schema, a field entry, or a field value.
Statics§
- BYTES_
WILDCARD_ KEY - The wildcard byte key (
b"*") used to express a homogeneousMap<Bytes, T>. - TEXT_
WILDCARD_ KEY - The wildcard text key (
"*") used to express a homogeneousMap<Text, T>.
Functions§
- validate_
field_ name - Validate a field name against Anda DB’s naming rules.
- vector_
from_ f32 - Convert a
Vec<f32>into aVector(i.e.Vec<bf16>) by lossy conversion of every element. - vector_
from_ f64 - Convert a
Vec<f64>into aVector(i.e.Vec<bf16>) by lossy conversion of every element.
Type Aliases§
- BoxError
- A boxed, thread-safe
std::error::Error. - Cbor
- Type alias for cbor2::Value
- Document
Id - The unique identifier for a document within a collection.
- Fe
- Type alias for FieldEntry
- Ft
- Type alias for FieldType
- Fv
- Type alias for FieldValue
- Indexed
Field Values - Type alias for
BTreeMap<usize, FieldValue>, the canonical container for a document’s field values. - Json
- Type alias for serde_json::Value
- Vector
- Type alias for
Vec<bf16>
Derive Macros§
- AndaDB
Schema - A derive macro that generates a
schema()associated function for a struct. - Field
Typed - A derive macro that generates a
field_type()associated function for a struct.