Expand description
§qubit-metadata
A general-purpose, typed-value, extensible metadata model for Rust.
This crate provides a Metadata type — a structured key-value store
designed for any domain that needs to attach typed annotations to its data
models. It is not a plain HashMap — it is a structured extensibility point
with strict typed access, explicit conversion helpers,
qubit_value::Value backing, and first-class serde support.
§Design Goals
- Typed Values: Strict typed reads, explicit conversion helpers,
chainable set, and replacement-aware insert APIs backed by
qubit_value::Value - Generality: No domain-specific assumptions — usable in any Rust project
- Schema Support: Optional schema validation for metadata and filters
through the
schemafeature - Serialization: First-class
serdesupport for JSON interchange - Filtering: Composable query conditions through the
filterfeature
§Features
- Core type:
Metadata— an ordered key-value store with typed accessors - Enable
filterfor composable filter expressions and their public types - Enable
schema(which includesfilter) for field definitions and validation APIs - Error type:
MetadataError— structured failure reporting for reads, conversions, validation, and wire boundaries schemaalso provides aggregate validation errors
§Example
use qubit_metadata::Metadata;
let meta = Metadata::new()
.with("author", "alice")
.with("priority", 3_i64);
// Optional strict reads distinguish absence from conversion/type failures.
let author = meta.get_optional::<String>("author").unwrap();
assert_eq!(author.as_deref(), Some("alice"));
// Explicit API: preserve failure reasons for diagnostics.
let priority = meta.convert::<i64>("priority").unwrap();
assert_eq!(priority, 3);The filter feature uses fail-closed three-valued logic: a missing or unset
value stays unknown through negation and does not match at the public API
boundary.
Metadata’s Debug and Display implementations are bounded and rendered
through the default redaction policy. They are useful diagnostic views, not
a confidentiality boundary for arbitrary user-defined keys or error text.
Structs§
- Filter
Expression - An immutable Boolean expression in a
crate::MetadataFilter. - Filter
Expression Builder - Fluent builder for a non-empty
FilterExpression. - Filter
Limits - Resource bounds enforced for every constructed or deserialized filter.
- Filter
Limits Builder - Fluent builder for validated filter limits.
- Filter
Match Options - Match policies used when evaluating a
crate::MetadataFilter. - Filter
Match Options Builder - Fluent builder for filter match options.
- Metadata
- A structured, key-sorted, typed key-value store for metadata fields.
- Metadata
Field - Definition of one metadata field in a
crate::MetadataSchema. - Metadata
Filter - An expression, its matching policy, and its resource limits.
- Metadata
Filter Builder - Builder for the non-logical configuration of a
MetadataFilter. - Metadata
Limits - Domain-specific metadata limits composed with a shared JSON profile.
- Metadata
Limits Builder - Builder for
MetadataLimits. - Metadata
Schema - Schema for metadata fields.
- Metadata
Schema Builder - Builder for
MetadataSchema. - Metadata
Validation Error - Aggregate error returned by schema-level validation APIs.
Enums§
- Condition
- A single comparison operator applied to one metadata key.
- Filter
Expression View - A borrowed, read-only view of one
FilterExpressionnode. - Filter
Limit Kind - Identifies one resource bounded while constructing or decoding a filter.
- Metadata
Error - Errors produced by explicit metadata accessors and schema validation.
- Metadata
Wire Decode Error - Failure returned by a bounded metadata JSON decoding API.
- Metadata
Wire Encode Error - Failure returned by bounded metadata JSON encoding APIs.
- Metadata
Wire Limit Kind - A metadata resource category bounded by the strict V1 wire contract.
- Unknown
Filter Field Policy - Policy for filter fields that are not declared by a schema.
- Unknown
Metadata Field Policy - Policy for metadata fields that are not declared by a schema.
Constants§
- DEFAULT_
MAX_ JSON_ BYTES - Default maximum complete metadata JSON input or output length.
- DEFAULT_
MAX_ KEY_ BYTES - Default maximum UTF-8 bytes in one metadata key.
- DEFAULT_
MAX_ METADATA_ ENTRIES - Default maximum metadata map entries accepted by the JSON profile.
- DEFAULT_
MAX_ SCHEMA_ FIELDS - Default maximum schema fields accepted by the JSON profile.
Functions§
- default_
json_ decode_ limits - Creates the default metadata JSON decoding profile.
- default_
json_ encode_ limits - Creates the default metadata JSON encoding profile.
- default_
json_ value_ limits - Creates the default direction-independent metadata JSON value profile.
Type Aliases§
- Metadata
Result - Result type used by explicit
Metadataoperations that report failure reasons instead of collapsing them intoNone. - Metadata
Validation Result - Result type for schema validation that may report multiple issues.