Skip to main content

ValueMissing

Struct ValueMissing 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ValueMissing

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueMissing

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ValueMissing

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats diagnostic types and indices without exposing source payloads.

Source§

impl Eq for ValueMissing

Source§

impl Error for ValueMissing

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ValueMissing

Source§

fn eq(&self, other: &ValueMissing) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ValueMissing

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoValueDefault<T> for T

Source§

fn into_value_default(self) -> T

Converts this argument into the default value. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.