pub enum DataConversionError {
Missing {
from: DataType,
to: DataType,
},
EmptyCollection {
to: DataType,
},
Unsupported {
from: DataType,
to: DataType,
},
InvalidValue {
from: DataType,
to: DataType,
reason: InvalidValueReason,
},
}Expand description
Describes why a single source value could not be converted.
Value conversion variants record both the declared source and requested
target DataType. Self::EmptyCollection records only the requested
target because an empty generic collection has no source value whose type
can be observed. Invalid-value errors additionally carry a stable,
value-independent InvalidValueReason. Source values are deliberately not
retained or formatted, which makes these errors safe to surface for secrets
such as environment variables.
§Examples
use qubit_datatype::{DataConversionError, DataConverter, InvalidValueReason};
assert!(matches!(
DataConverter::from("not-a-number").to::<u32>(),
Err(DataConversionError::InvalidValue {
reason: InvalidValueReason::InvalidSyntax { .. },
..
}),
));Variants§
Missing
The source has no concrete value.
EmptyCollection
A first-value conversion was requested from an empty collection.
Unsupported
The source and target type pair is unsupported.
InvalidValue
The type pair is supported but the source value is invalid.
Trait Implementations§
Source§impl Clone for DataConversionError
impl Clone for DataConversionError
Source§fn clone(&self) -> DataConversionError
fn clone(&self) -> DataConversionError
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 DataConversionError
impl Debug for DataConversionError
Source§impl Display for DataConversionError
impl Display for DataConversionError
impl Eq for DataConversionError
Source§impl Error for DataConversionError
impl Error for DataConversionError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()