pub struct ValueMissing { /* private fields */ }Expand description
Describes the storage state, requested type and source of a missing read.
The fields are private so callers cannot manufacture an incomplete fact.
Use the constructors for storage states and the accessors for the optional
facts. source_type and target_type are None only when the caller has
no type information (for example, a generic empty iterator); source_index
is set only when a collection item caused the failure. A preserved
conversion_error is available only when the converter feature is on.
Strict fallback is allowed only for an unset value after type admission. Conversion fallback additionally accepts a policy-classified missing scalar but never a concrete empty collection or a missing collection item.
§Examples
use qubit_datatype::DataType;
use qubit_value::{Value, ValueMissingReason};
let error = Value::new_unset(DataType::Int32).get::<i32>().unwrap_err();
let missing = error.missing().unwrap();
assert_eq!(missing.reason(), ValueMissingReason::UnsetScalar);
assert_eq!(missing.source_type(), Some(DataType::Int32));
assert_eq!(missing.target_type(), Some(DataType::Int32));
assert!(missing.is_defaultable_for_strict_read());Strict reads record both source and target. Conversion failures additionally
retain their original error and, for collection items, source index.
Inspect Self::reason and the accessors instead of matching storage
fields.
Implementations§
Source§impl ValueMissing
impl ValueMissing
Sourcepub const fn unset_scalar(source: DataType, target: DataType) -> Self
pub const fn unset_scalar(source: DataType, target: DataType) -> Self
Creates an unset scalar descriptor for a read from source to target.
§Parameters
source- Runtime type of the unset scalar storage.target- Type requested by the read operation.
§Returns
A descriptor classified as ValueMissingReason::UnsetScalar.
Sourcepub const fn unset_collection(source: DataType, target: DataType) -> Self
pub const fn unset_collection(source: DataType, target: DataType) -> Self
Creates an unset collection descriptor for the requested element type.
§Parameters
source- Runtime element type of the unset collection storage.target- Element type requested by the read operation.
§Returns
A descriptor classified as ValueMissingReason::UnsetCollection.
Sourcepub const fn empty_collection(source: DataType, target: DataType) -> Self
pub const fn empty_collection(source: DataType, target: DataType) -> Self
Creates a descriptor for a first-item read from a concrete empty collection.
§Parameters
source- Runtime element type of the empty collection.target- Element type requested by the read operation.
§Returns
A descriptor classified as ValueMissingReason::EmptyCollection.
Sourcepub const fn reason(&self) -> ValueMissingReason
pub const fn reason(&self) -> ValueMissingReason
Returns the storage or policy reason for this missing result.
This value is always present, including when the source or target type is unknown.
§Returns
The storage or conversion-policy classification.
Sourcepub const fn source_type(&self) -> Option<DataType>
pub const fn source_type(&self) -> Option<DataType>
Returns the known source type, or None when conversion did not retain
one (for example, a generic empty iterator).
§Returns
Some with the stored source type when known; otherwise None.
Sourcepub const fn target_type(&self) -> Option<DataType>
pub const fn target_type(&self) -> Option<DataType>
Returns the requested target type when known. Strict reads normally provide it; a low-level conversion failure may leave it absent.
§Returns
Some with the requested type when known; otherwise None.
Sourcepub const fn source_index(&self) -> Option<usize>
pub const fn source_index(&self) -> Option<usize>
Returns the original collection item index, or None for an outer
failure or a scalar conversion.
§Returns
Some with the zero-based source index for an item failure; otherwise
None.
Sourcepub const fn conversion_error(&self) -> Option<&DataConversionError>
pub const fn conversion_error(&self) -> Option<&DataConversionError>
Returns the original conversion error, absent for a strict storage
read. The error is the source for std::error::Error::source.
§Returns
Some with the preserved conversion error for conversion failures;
otherwise None.
Sourcepub const fn is_unset(&self) -> bool
pub const fn is_unset(&self) -> bool
Reports whether scalar or collection storage is unset.
This predicate is the condition used by strict fallback helpers.
§Returns
true for unset scalar or collection storage; otherwise false.
Sourcepub const fn is_empty_collection(&self) -> bool
pub const fn is_empty_collection(&self) -> bool
Reports whether a first-item read failed because a concrete collection is empty.
§Returns
true only for a concrete empty collection; otherwise false.
Sourcepub const fn is_conversion(&self) -> bool
pub const fn is_conversion(&self) -> bool
Reports whether conversion produced this failure, including enriched unset states.
§Returns
true when a conversion error is represented or retained; otherwise
false.
Sourcepub const fn is_defaultable_for_strict_read(&self) -> bool
pub const fn is_defaultable_for_strict_read(&self) -> bool
Allows strict fallback only for unset storage after the type check
passed. Concrete empty collections and type mismatches return false.
§Returns
true when a strict read may use its caller-supplied default.
Sourcepub const fn is_defaultable_for_conversion(&self) -> bool
pub const fn is_defaultable_for_conversion(&self) -> bool
Allows conversion fallback for unset storage or a policy-missing scalar.
Empty collections and missing collection items never default.
§Returns
true when a conversion read may use its caller-supplied default.
Trait Implementations§
Source§impl Clone for ValueMissing
impl Clone for ValueMissing
Source§fn clone(&self) -> ValueMissing
fn clone(&self) -> ValueMissing
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 ValueMissing
impl Debug for ValueMissing
Source§impl Display for ValueMissing
impl Display for ValueMissing
impl Eq for ValueMissing
Source§impl Error for ValueMissing
impl Error for ValueMissing
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Exposes the preserved conversion error, or terminates a strict-read chain.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()