pub enum ValueContainer {
Scalar(Value),
Collection(MultiValues),
}Expand description
A typed value whose scalar or collection shape is explicit.
The shape is never inferred from collection length. In particular,
Scalar(Value::Int32(42)) and
Collection(MultiValues::Int32(vec![42])) remain distinguishable through
conversion and serialization boundaries.
Variants§
Scalar(Value)
One typed value.
Collection(MultiValues)
A homogeneous typed collection.
Tuple Fields
0: MultiValuesStored homogeneous collection.
Implementations§
Source§impl ValueContainer
impl ValueContainer
Sourcepub fn to_json_value(&self) -> ValueResult<JsonValue>
pub fn to_json_value(&self) -> ValueResult<JsonValue>
Projects this container while preserving concrete collection shape.
Scalar storage uses the natural scalar projection; concrete collection storage always uses a JSON array.
§Returns
The natural JSON representation, except scalar and collection unset
values both project to null.
§Errors
Returns the same structured projection error as the contained value.
Sourcepub fn to_json_value_with(
&self,
options: &DataConversionOptions,
) -> ValueResult<JsonValue>
pub fn to_json_value_with( &self, options: &DataConversionOptions, ) -> ValueResult<JsonValue>
Projects this container using explicit conversion options.
§Parameters
options- Controls duration units and precision-loss behavior.
§Returns
The natural JSON representation, except scalar and collection unset
values both project to null.
§Errors
Returns the same structured projection error as the contained value.
Source§impl ValueContainer
impl ValueContainer
Sourcepub fn data_type(&self) -> DataType
pub fn data_type(&self) -> DataType
Returns the stored or declared data type.
§Returns
The scalar or collection element type, including the declared type of unset storage.
Sourcepub const fn new_unset_scalar(data_type: DataType) -> Self
pub const fn new_unset_scalar(data_type: DataType) -> Self
Sourcepub const fn new_unset_collection(data_type: DataType) -> Self
pub const fn new_unset_collection(data_type: DataType) -> Self
Sourcepub const fn as_scalar(&self) -> Option<&Value>
pub const fn as_scalar(&self) -> Option<&Value>
Returns the contained scalar without consuming this container.
§Returns
Some for scalar storage, or None for collection storage.
Sourcepub fn into_scalar(self) -> Result<Value, Self>
pub fn into_scalar(self) -> Result<Value, Self>
Sourcepub const fn is_collection(&self) -> bool
pub const fn is_collection(&self) -> bool
Sourcepub const fn as_collection(&self) -> Option<&MultiValues>
pub const fn as_collection(&self) -> Option<&MultiValues>
Returns the contained collection without consuming this container.
§Returns
Some for collection storage, or None for scalar storage.
Sourcepub fn into_collection(self) -> Result<MultiValues, Self>
pub fn into_collection(self) -> Result<MultiValues, Self>
Sourcepub fn is_unset(&self) -> bool
pub fn is_unset(&self) -> bool
Returns whether the shape contains no concrete value or collection.
§Returns
true when the contained scalar or collection is unset.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns zero for unset storage, one for a concrete scalar, or the concrete collection length.
§Returns
The number of concrete values represented by this container.
Sourcepub fn get_first<T>(&self) -> ValueResult<T>where
T: StrictValueRead,
pub fn get_first<T>(&self) -> ValueResult<T>where
T: StrictValueRead,
Strictly reads a scalar or the first collection item as T.
§Type Parameters
T- Strict target type.
§Returns
The scalar value or first collection item.
§Errors
Returns ValueError::Missing for unset or empty matching storage and
ValueError::TypeMismatch when the stored data type differs.
Sourcepub fn get_list<T>(&self) -> ValueResult<Vec<T>>where
T: StrictValueRead,
pub fn get_list<T>(&self) -> ValueResult<Vec<T>>where
T: StrictValueRead,
Strictly reads a scalar as a one-item list or all collection items.
§Type Parameters
T- Strict target element type.
§Returns
A one-item scalar list or all collection items.
§Errors
Returns ValueError::Missing for unset matching storage and
ValueError::TypeMismatch when the stored data type differs.
Sourcepub fn set<S>(&mut self, value: S)where
S: Into<Self>,
pub fn set<S>(&mut self, value: S)where
S: Into<Self>,
Replaces this container, including its shape, from a supported input.
§Type Parameters
S- Input type convertible intoValueContainer.
§Parameters
value- New scalar or collection value.
Sourcepub fn add<S>(&mut self, values: S) -> ValueResult<()>where
S: Into<Self>,
pub fn add<S>(&mut self, values: S) -> ValueResult<()>where
S: Into<Self>,
Appends values, promoting scalar storage to collection storage when the input contains at least one concrete value. Same-typed empty and unset input is a no-op.
§Type Parameters
S- Input type convertible intoValueContainer.
§Parameters
values- Scalar or collection values to append.
§Returns
Ok(()) after appending or accepting an empty same-typed input.
§Errors
Returns ValueError::TypeMismatch when the appended values have a
different data type.
Sourcepub fn to_first<T>(&self) -> ValueResult<T>where
T: DataConversionTarget,
pub fn to_first<T>(&self) -> ValueResult<T>where
T: DataConversionTarget,
Sourcepub fn to_first_with<T>(
&self,
options: &DataConversionOptions,
) -> ValueResult<T>where
T: DataConversionTarget,
pub fn to_first_with<T>(
&self,
options: &DataConversionOptions,
) -> ValueResult<T>where
T: DataConversionTarget,
Converts a scalar or the first collection item using explicit options.
§Type Parameters
T- Target conversion type.
§Parameters
options- Conversion options forwarded to the contained value.
§Returns
The converted scalar or first collection item.
§Errors
Returns the mapped qubit-datatype conversion error.
Sourcepub fn to_list<T>(&self) -> ValueResult<Vec<T>>where
T: DataConversionTarget,
pub fn to_list<T>(&self) -> ValueResult<Vec<T>>where
T: DataConversionTarget,
Converts a scalar to a list or converts every collection item.
Scalar strings may be split according to collection conversion options; strings already stored in a collection are never split again.
§Type Parameters
T- Target list element type.
§Returns
A converted scalar list or all converted collection items.
§Errors
Returns the mapped single-value or indexed list conversion error.
Sourcepub fn to_list_with<T>(
&self,
options: &DataConversionOptions,
) -> ValueResult<Vec<T>>where
T: DataConversionTarget,
pub fn to_list_with<T>(
&self,
options: &DataConversionOptions,
) -> ValueResult<Vec<T>>where
T: DataConversionTarget,
Converts to a list using explicit conversion options.
§Type Parameters
T- Target list element type.
§Parameters
options- Conversion options forwarded to the contained value.
§Returns
A converted scalar list or all converted collection items.
§Errors
Returns the mapped single-value or indexed list conversion error.
Trait Implementations§
Source§impl Clone for ValueContainer
impl Clone for ValueContainer
Source§fn clone(&self) -> ValueContainer
fn clone(&self) -> ValueContainer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValueContainer
impl Debug for ValueContainer
impl Eq for ValueContainer
Source§impl<'a, 'b> From<&'a [&'b str]> for ValueContainer
impl<'a, 'b> From<&'a [&'b str]> for ValueContainer
Source§impl From<&Vec<BigDecimal>> for ValueContainer
Available on crate feature big-decimal only.
impl From<&Vec<BigDecimal>> for ValueContainer
big-decimal only.Source§fn from(values: &Vec<BigDecimal>) -> Self
fn from(values: &Vec<BigDecimal>) -> Self
Source§impl From<&Vec<NaiveDateTime>> for ValueContainer
Available on crate feature chrono only.
impl From<&Vec<NaiveDateTime>> for ValueContainer
chrono only.Source§fn from(values: &Vec<NaiveDateTime>) -> Self
fn from(values: &Vec<NaiveDateTime>) -> Self
Source§impl<const N: usize> From<&[BigDecimal; N]> for ValueContainer
Available on crate feature big-decimal only.
impl<const N: usize> From<&[BigDecimal; N]> for ValueContainer
big-decimal only.Source§fn from(values: &[BigDecimal; N]) -> Self
fn from(values: &[BigDecimal; N]) -> Self
Source§impl From<&[BigDecimal]> for ValueContainer
Available on crate feature big-decimal only.
impl From<&[BigDecimal]> for ValueContainer
big-decimal only.Source§fn from(values: &[BigDecimal]) -> Self
fn from(values: &[BigDecimal]) -> Self
Source§impl<const N: usize> From<&[BigInt; N]> for ValueContainer
Available on crate feature big-integer only.
impl<const N: usize> From<&[BigInt; N]> for ValueContainer
big-integer only.Source§impl From<&[BigInt]> for ValueContainer
Available on crate feature big-integer only.
impl From<&[BigInt]> for ValueContainer
big-integer only.Source§impl<const N: usize> From<&[DateTime<Utc>; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<&[DateTime<Utc>; N]> for ValueContainer
chrono only.Source§impl From<&[Duration]> for ValueContainer
impl From<&[Duration]> for ValueContainer
Source§impl<const N: usize> From<&[NaiveDate; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<&[NaiveDate; N]> for ValueContainer
chrono only.Source§impl<const N: usize> From<&[NaiveDateTime; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<&[NaiveDateTime; N]> for ValueContainer
chrono only.Source§fn from(values: &[NaiveDateTime; N]) -> Self
fn from(values: &[NaiveDateTime; N]) -> Self
Source§impl From<&[NaiveDateTime]> for ValueContainer
Available on crate feature chrono only.
impl From<&[NaiveDateTime]> for ValueContainer
chrono only.Source§fn from(values: &[NaiveDateTime]) -> Self
fn from(values: &[NaiveDateTime]) -> Self
Source§impl From<&[NaiveDate]> for ValueContainer
Available on crate feature chrono only.
impl From<&[NaiveDate]> for ValueContainer
chrono only.Source§impl<const N: usize> From<&[NaiveTime; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<&[NaiveTime; N]> for ValueContainer
chrono only.Source§impl From<&[NaiveTime]> for ValueContainer
Available on crate feature chrono only.
impl From<&[NaiveTime]> for ValueContainer
chrono only.Source§impl From<&[String]> for ValueContainer
impl From<&[String]> for ValueContainer
Source§impl From<&[Url]> for ValueContainer
Available on crate feature url only.
impl From<&[Url]> for ValueContainer
url only.Source§impl<const N: usize> From<&[Value; N]> for ValueContainer
Available on crate feature json only.
impl<const N: usize> From<&[Value; N]> for ValueContainer
json only.Source§impl From<&[Value]> for ValueContainer
Available on crate feature json only.
impl From<&[Value]> for ValueContainer
json only.Source§impl From<&[bool]> for ValueContainer
impl From<&[bool]> for ValueContainer
Source§impl From<&[char]> for ValueContainer
impl From<&[char]> for ValueContainer
Source§impl From<&[f32]> for ValueContainer
impl From<&[f32]> for ValueContainer
Source§impl From<&[f64]> for ValueContainer
impl From<&[f64]> for ValueContainer
Source§impl From<&[i8]> for ValueContainer
impl From<&[i8]> for ValueContainer
Source§impl From<&[i16]> for ValueContainer
impl From<&[i16]> for ValueContainer
Source§impl From<&[i32]> for ValueContainer
impl From<&[i32]> for ValueContainer
Source§impl From<&[i64]> for ValueContainer
impl From<&[i64]> for ValueContainer
Source§impl From<&[i128]> for ValueContainer
impl From<&[i128]> for ValueContainer
Source§impl From<&[u8]> for ValueContainer
impl From<&[u8]> for ValueContainer
Source§impl From<&[u16]> for ValueContainer
impl From<&[u16]> for ValueContainer
Source§impl From<&[u32]> for ValueContainer
impl From<&[u32]> for ValueContainer
Source§impl From<&[u64]> for ValueContainer
impl From<&[u64]> for ValueContainer
Source§impl From<&[u128]> for ValueContainer
impl From<&[u128]> for ValueContainer
Source§impl From<&str> for ValueContainer
impl From<&str> for ValueContainer
Source§impl From<BigDecimal> for ValueContainer
Available on crate feature big-decimal only.
impl From<BigDecimal> for ValueContainer
big-decimal only.Source§fn from(value: BigDecimal) -> Self
fn from(value: BigDecimal) -> Self
Source§impl From<BigInt> for ValueContainer
Available on crate feature big-integer only.
impl From<BigInt> for ValueContainer
big-integer only.Source§impl From<Duration> for ValueContainer
impl From<Duration> for ValueContainer
Source§impl From<MultiValues> for ValueContainer
impl From<MultiValues> for ValueContainer
Source§fn from(values: MultiValues) -> Self
fn from(values: MultiValues) -> Self
Source§impl From<NaiveDate> for ValueContainer
Available on crate feature chrono only.
impl From<NaiveDate> for ValueContainer
chrono only.Source§impl From<NaiveDateTime> for ValueContainer
Available on crate feature chrono only.
impl From<NaiveDateTime> for ValueContainer
chrono only.Source§fn from(value: NaiveDateTime) -> Self
fn from(value: NaiveDateTime) -> Self
Source§impl From<NaiveTime> for ValueContainer
Available on crate feature chrono only.
impl From<NaiveTime> for ValueContainer
chrono only.Source§impl From<String> for ValueContainer
impl From<String> for ValueContainer
Source§impl From<Url> for ValueContainer
Available on crate feature url only.
impl From<Url> for ValueContainer
url only.Source§impl From<Value> for ValueContainer
Available on crate feature json only.
impl From<Value> for ValueContainer
json only.Source§impl From<Value> for ValueContainer
impl From<Value> for ValueContainer
Source§impl From<ValueWirePayloadV1> for ValueContainer
impl From<ValueWirePayloadV1> for ValueContainer
Source§fn from(value: ValueWirePayloadV1) -> Self
fn from(value: ValueWirePayloadV1) -> Self
Extracts the shaped runtime value from a V1 payload.
Source§impl From<ValueWireV1> for ValueContainer
impl From<ValueWireV1> for ValueContainer
Source§fn from(value: ValueWireV1) -> Self
fn from(value: ValueWireV1) -> Self
Unwraps the runtime container from a V1 DTO.
Source§impl From<Vec<BigDecimal>> for ValueContainer
Available on crate feature big-decimal only.
impl From<Vec<BigDecimal>> for ValueContainer
big-decimal only.Source§fn from(values: Vec<BigDecimal>) -> Self
fn from(values: Vec<BigDecimal>) -> Self
Source§impl From<Vec<NaiveDateTime>> for ValueContainer
Available on crate feature chrono only.
impl From<Vec<NaiveDateTime>> for ValueContainer
chrono only.Source§fn from(values: Vec<NaiveDateTime>) -> Self
fn from(values: Vec<NaiveDateTime>) -> Self
Source§impl<const N: usize> From<[BigDecimal; N]> for ValueContainer
Available on crate feature big-decimal only.
impl<const N: usize> From<[BigDecimal; N]> for ValueContainer
big-decimal only.Source§fn from(values: [BigDecimal; N]) -> Self
fn from(values: [BigDecimal; N]) -> Self
Source§impl<const N: usize> From<[BigInt; N]> for ValueContainer
Available on crate feature big-integer only.
impl<const N: usize> From<[BigInt; N]> for ValueContainer
big-integer only.Source§impl<const N: usize> From<[DateTime<Utc>; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<[DateTime<Utc>; N]> for ValueContainer
chrono only.Source§impl<const N: usize> From<[NaiveDate; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<[NaiveDate; N]> for ValueContainer
chrono only.Source§impl<const N: usize> From<[NaiveDateTime; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<[NaiveDateTime; N]> for ValueContainer
chrono only.Source§fn from(values: [NaiveDateTime; N]) -> Self
fn from(values: [NaiveDateTime; N]) -> Self
Source§impl<const N: usize> From<[NaiveTime; N]> for ValueContainer
Available on crate feature chrono only.
impl<const N: usize> From<[NaiveTime; N]> for ValueContainer
chrono only.Source§impl<const N: usize> From<[Value; N]> for ValueContainer
Available on crate feature json only.
impl<const N: usize> From<[Value; N]> for ValueContainer
json only.Source§impl From<bool> for ValueContainer
impl From<bool> for ValueContainer
Source§impl From<char> for ValueContainer
impl From<char> for ValueContainer
Source§impl From<f32> for ValueContainer
impl From<f32> for ValueContainer
Source§impl From<f64> for ValueContainer
impl From<f64> for ValueContainer
Source§impl From<i8> for ValueContainer
impl From<i8> for ValueContainer
Source§impl From<i16> for ValueContainer
impl From<i16> for ValueContainer
Source§impl From<i32> for ValueContainer
impl From<i32> for ValueContainer
Source§impl From<i64> for ValueContainer
impl From<i64> for ValueContainer
Source§impl From<i128> for ValueContainer
impl From<i128> for ValueContainer
Source§impl From<u8> for ValueContainer
impl From<u8> for ValueContainer
Source§impl From<u16> for ValueContainer
impl From<u16> for ValueContainer
Source§impl From<u32> for ValueContainer
impl From<u32> for ValueContainer
Source§impl From<u64> for ValueContainer
impl From<u64> for ValueContainer
Source§impl From<u128> for ValueContainer
impl From<u128> for ValueContainer
Source§impl Hash for ValueContainer
impl Hash for ValueContainer
Source§impl PartialEq for ValueContainer
impl PartialEq for ValueContainer
Source§impl Redact for ValueContainer
impl Redact for ValueContainer
Source§fn redacted(&self) -> Redacted<'_, Self>where
Self: Sized,
fn redacted(&self) -> Redacted<'_, Self>where
Self: Sized,
Source§fn redacted_with(&self, policy: &RedactionPolicy) -> Redacted<'_, Self>where
Self: Sized,
fn redacted_with(&self, policy: &RedactionPolicy) -> Redacted<'_, Self>where
Self: Sized,
policy. Read moreimpl StructuralPartialEq for ValueContainer
Source§impl<'a> TryFrom<&'a ValueContainer> for ValueWirePayloadRefV1<'a>
impl<'a> TryFrom<&'a ValueContainer> for ValueWirePayloadRefV1<'a>
Source§fn try_from(value: &'a ValueContainer) -> Result<Self, Self::Error>
fn try_from(value: &'a ValueContainer) -> Result<Self, Self::Error>
Borrows and validates an explicit shape.
Source§type Error = ValueWireEncodeError
type Error = ValueWireEncodeError
Source§impl<'a> TryFrom<&'a ValueContainer> for ValueWireRefV1<'a>
impl<'a> TryFrom<&'a ValueContainer> for ValueWireRefV1<'a>
Source§fn try_from(value: &'a ValueContainer) -> Result<Self, Self::Error>
fn try_from(value: &'a ValueContainer) -> Result<Self, Self::Error>
Borrows and validates an explicit shape.
Source§type Error = ValueWireEncodeError
type Error = ValueWireEncodeError
Source§impl TryFrom<ValueContainer> for ValueWirePayloadV1
impl TryFrom<ValueContainer> for ValueWirePayloadV1
Source§fn try_from(value: ValueContainer) -> Result<Self, Self::Error>
fn try_from(value: ValueContainer) -> Result<Self, Self::Error>
Validates an explicitly shaped value for use in a V1 payload.
Source§type Error = ValueWireEncodeError
type Error = ValueWireEncodeError
Source§impl TryFrom<ValueContainer> for ValueWireV1
impl TryFrom<ValueContainer> for ValueWireV1
Source§fn try_from(value: ValueContainer) -> Result<Self, Self::Error>
fn try_from(value: ValueContainer) -> Result<Self, Self::Error>
Wraps an explicit runtime shape in a V1 DTO.