Expand description
§Value Processing Framework
Provides type-safe value storage and access functionality, supporting single values, collections, explicit scalar-or-collection shape, and named values.
§Public API Overview
Valuestores one typed scalar, including an explicitUnset(DataType)state.MultiValuesstores one homogeneous typed collection.ValueRefandMultiValuesRefexpose borrowed semantic views while keeping runtime storage private.ValueContainerpreserves whether storage is scalar or collection.NamedValueandNamedMultiValuesprovide name wrappers.ValueWireV1andValueWirePayloadV1name explicit Serde DTOs.ValueWireRefV1andValueWirePayloadRefV1serialize borrowed values.
§Core behavior
Value::getandMultiValues::getperform strict typed reads.ValueContainerpreserves whether the source supplied a scalar or an explicit collection, even when the collection contains one item.tomethods usequbit-datatypeconversion policy and resource limits.- Optional type families and conversion methods are available only when the corresponding crate features are enabled; all-features documentation shows the superset of those APIs.
Value::is_unsetandValueContainer::is_unsetindicate that no concrete value is stored.MultiValues::is_unsetdistinguishes no collection from a concrete collection;MultiValues::is_emptyreports only that its length is zero.- Generic
setreplaces a value infallibly;MultiValues::addremains fallible because appended values must have the same data type. - Serde uses the strict, type-preserving
ValueWireV1envelope. Its canonical JSON representation is byte-stable for the same value under the supportedserde_jsonversion and configuration. String-map keys and nested JSON object keys are emitted in lexicographic order. Other Serde formats are supported as representations, but are outside this byte-level stability contract. With thenatural-jsonfeature,to_json_valueprovides a separate natural JSON projection with the same ordering. - Version one rejects externally tagged representations.
- Non-finite floats may exist in memory, but V1 Serde and natural JSON
reject them because JSON has no
NaNor infinity number literals. - JSON numbers follow
qubit-json’s explicit range contract: negative integers fiti64, non-negative integers fitu64, and fractional or exponential values are finitef64. Wider exact values use the crate’s explicit string-based integer and decimal wire representations.
§Usage Examples
§Single Value Operations
use qubit_value::Value;
// Create and access a single value
let value = Value::Int32(42);
assert_eq!(value.get_int32().unwrap(), 42);
// Strict generic access
let number: i32 = value.get().unwrap();
assert_eq!(number, 42);§Multiple Values Operations
use qubit_value::MultiValues;
// Create and access multiple values
let mut values = MultiValues::Int32(vec![1, 2, 3]);
assert_eq!(values.len(), 3);
// Add values
values.add(4).unwrap();
assert_eq!(values.get_int32s().unwrap(), &[1, 2, 3, 4]);§Named Value Operations
use qubit_value::{NamedValue, Value};
// Create a named value
let config = NamedValue::new("port", Value::Int32(8080));
assert_eq!(config.name(), "port");
assert_eq!(config.value().get_int32().unwrap(), 8080);§Explicit Shape Operations
use qubit_value::ValueContainer;
let scalar = ValueContainer::from(42_i32);
let collection = ValueContainer::from(vec![42_i32]);
assert!(scalar.is_scalar());
assert!(collection.is_collection());Structs§
- Multi
Values - Multiple typed runtime values with private storage representation.
- Named
Multi Values - Named multiple values
- Named
Value - Named single value
- Value
- Single typed runtime value with private storage representation.
- Value
Missing - Describes the storage state, requested type and source of a missing read.
- Value
Wire Encode Preflight - Performs conservative resource checks before Wire V1 sorting and formatting.
- Value
Wire Payload RefV1 - Borrowed unversioned V1 payload for serialization without cloning.
- Value
Wire Payload V1 - Typed V1 scalar-or-collection payload without an enclosing version field.
- Value
Wire Payload V1Seed - Explicit Serde seed for decoding one unversioned V1 payload.
- Value
Wire RefV1 - Borrowed standalone V1 envelope for serialization without cloning.
- Value
Wire V1 - Stable version-one wire DTO for a scalar or homogeneous collection.
- Value
Wire V1Seed - Explicit Serde seed for decoding one V1 envelope.
Enums§
- Multi
Values Ref - Borrowed semantic view preserving source types without owning payloads.
- Numeric
Comparison Error - Describes why two
crate::Valueinstances cannot be numerically ordered. - Value
Container - A typed value whose scalar or collection shape is explicit.
- Value
Error - Value processing error type
- Value
Missing Reason - Identifies why a read could not produce a concrete value.
- Value
Ref - Borrowed semantic view preserving source types without owning payloads.
- Value
Wire Decode Error - Error produced by a bounded
crate::ValueWireV1JSON decoder. - Value
Wire Encode Error - A runtime value cannot be represented by the JSON V1 wire contract.
Traits§
- Into
Value Default - Converts ergonomic default arguments into the value type expected by a read API.
- Strict
Value Read - Marks target types supported by exact, non-converting reads.
Type Aliases§
- Value
Result - Result returned by value processing operations.