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 rules and options.- 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 bothconverterandjson,to_json_valueprovides a separate natural JSON projection with the same ordering. - Version one rejects the pre-0.10 externally tagged representation.
- Non-finite floats may exist in memory, but V1 Serde and natural JSON
reject them because JSON has no
NaNor infinity number literals. - V1 JSON payloads reject objects containing serde_json’s private
"$serde_json::private::Number"key because arbitrary-precision number decoding uses that same Serde marker.
§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
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 RefV1 - Borrowed standalone V1 envelope for serialization without cloning.
- Value
Wire V1 - Stable version-one wire DTO for a scalar or homogeneous collection.
- Wire
Budget - Mutable accounting state shared by one complete wire decode.
- Wire
Limits - Shared limits applied to one complete wire decode.
Enums§
- Multi
Values Ref - Borrowed semantic view of a
crate::MultiValuesvalue. - 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 - Describes the typed state that produced a missing-value error.
- Value
Ref - Borrowed semantic view of a
crate::Value. - 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.
- Value
Wire Limit Kind - Shared resource category enforced while decoding one wire document.
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 - Value processing result type