Skip to main content

UnitError

Enum UnitError 

Source
#[non_exhaustive]
pub enum UnitError {
Show 16 variants Undefined { from: u64, to: u64, }, NotAUnit { instance: u64, entity: String, }, Unsupported { instance: u64, entity: String, }, Malformed { instance: u64, reason: &'static str, }, NotPositive { instance: u64, value: f64, }, KindMismatch { instance: u64, declared: UnitKind, found: UnitKind, }, TooDeep { instance: u64, }, NotAContext { instance: u64, entity: String, }, NotARepresentation { instance: u64, entity: String, }, Missing { context: u64, kind: UnitKind, }, Ambiguous { context: u64, kind: UnitKind, units: Vec<u64>, }, Unreadable { context: u64, unit: u64, reason: Box<UnitError>, }, NotHeld { item: u64, }, NotFollowed { item: u64, container: u64, entity: String, }, HolderUnreadable { item: u64, holder: u64, reason: Box<UnitError>, }, ContextsDisagree { item: u64, kind: Option<UnitKind>, contexts: [u64; 2], },
}
Expand description

Why a unit, one kind of a context’s units, its uncertainties or the units of an item cannot be read as stated.

Each variant names the innermost instance at fault.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Undefined

An instance refers to an #id that is not defined. When to is the #id the caller passed, from equals to.

Fields

§from: u64

The instance that refers to to.

§to: u64

The missing #id.

§

NotAUnit

Not a unit at all, such as a DIMENSIONAL_EXPONENTS or a measure with unit.

Fields

§instance: u64

The instance.

§entity: String

Its upper-cased entity types, joined with +.

§

Unsupported

Valid STEP that stepq does not read: a unit of another quantity (mass, time, …), a derived unit, a context-dependent unit (which states no factor), an SI unit such as the gram, or a named unit that is neither SI nor conversion-based.

Fields

§instance: u64

The unit.

§entity: String

Its upper-cased entity types, joined with +.

§

Malformed

Contradicts the schema: a wrong number of attributes, an attribute of the wrong type, an unknown SI prefix or SI unit name, an SI unit that is also conversion-based, a complex instance that repeats a partial entity, or a unit or uncertainty set that is $, empty or lists something other than references.

Fields

§instance: u64

The instance.

§reason: &'static str

What is wrong.

§

NotPositive

A conversion factor or uncertainty that is not a positive finite number once converted: zero, negative or too large.

Fields

§instance: u64

The measure with unit that states it.

§value: f64

The value after conversion.

§

KindMismatch

The unit’s statements of its kind disagree: its kind record, its SI name, its base unit, its factor’s measure type, its factor’s value type or its dimensional exponents. All-zero exponents, which every angle has, are reported as a plane angle.

Fields

§instance: u64

The unit, or the uncertainty whose value type contradicts its unit.

§declared: UnitKind

The kind it is read as.

§found: UnitKind

The kind another statement names.

§

TooDeep

A chain of conversion-based units more than 8 deep, or a cycle.

Fields

§instance: u64

The unit at which the chain was cut.

§

NotAContext

Not a representation context.

Fields

§instance: u64

The instance.

§entity: String

Its upper-cased entity types, joined with +.

§

NotARepresentation

Not a representation, or not one with a string name, a list of item references and a context reference.

Fields

§instance: u64

The instance.

§entity: String

Its upper-cased entity types, joined with +.

§

Missing

The context assigns no unit of this kind.

Fields

§context: u64

The context.

§kind: UnitKind

The kind.

§

Ambiguous

The context assigns several units of this kind whose factors differ.

Fields

§context: u64

The context.

§kind: UnitKind

The kind.

§units: Vec<u64>

Every unit of this kind it assigns, in order.

§

Unreadable

A unit the context assigns cannot be read, and it is of this kind or its kind cannot be told (it may be the length unit). Another readable unit of the same kind does not make up for it.

Fields

§context: u64

The context.

§unit: u64

The unit.

§reason: Box<UnitError>

Why it cannot be read.

§

NotHeld

No representation holds the item, directly or through a container stepq knows.

Fields

§item: u64

The item.

§

NotFollowed

Something that refers to the item, or to a container holding it, may hold it but is not followed: a shell, solid or model written as a complex instance, or an instance that lists it next to a reference that is not a context. A representation behind it could hold the item in another context, so the item is not read from the others.

Fields

§item: u64

The item.

§container: u64

The instance that is not followed.

§entity: String

Its upper-cased entity types, joined with +.

§

HolderUnreadable

A representation that lists the item, or that representation’s context, cannot be read. The item is not read from the others.

Fields

§item: u64

The item.

§holder: u64

The representation.

§reason: Box<UnitError>

Why it cannot be read.

§

ContextsDisagree

The item is held in contexts that disagree.

Fields

§item: u64

The item.

§kind: Option<UnitKind>

The kind whose units (or, from ContextUnits::uncertainty, whose uncertainties) differ; None if the coordinate space dimensions differ.

§contexts: [u64; 2]

Two contexts that disagree.

Trait Implementations§

Source§

impl Clone for UnitError

Source§

fn clone(&self) -> Self

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 UnitError

Source§

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

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

impl Display for UnitError

Source§

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

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

impl Error for UnitError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
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 From<UnitError> for Error

Source§

fn from(source: UnitError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for UnitError

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for UnitError

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UnitError

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> 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.