Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 30 variants Overflow { quantity: &'static str, operation: &'static str, left: i128, right: Option<i128>, }, PowerOutOfRange { watts: u64, }, NegativeAmount { power: Power, }, ParsePower { text: String, reason: &'static str, }, Inexact { numerator: i128, denominator: i128, }, IspDuration { minutes: u16, }, GridSize { count: u64, }, TimeRange { start: Timestamp, count: u32, }, Day { date: Date, zone: String, reason: &'static str, }, LocalTime { date: Date, time: Time, zone: String, reason: &'static str, }, GridMismatch { left: Grid, right: Grid, }, SeriesLength { expected: u32, actual: usize, }, InvertedBounds { min: Power, max: Power, }, DeviceId { id: String, reason: &'static str, }, Receipt { path: String, reason: String, }, InvertedLevel { min: Energy, max: Energy, }, EmptyLevel { after: IspLabel, min: Energy, max: Energy, }, InitialLevel { initial: Energy, level: Level, }, NotABoundary { at: Timestamp, grid: Grid, }, InvertedBand { min: Deviation, max: Deviation, }, Mismatch { field: &'static str, ours: String, theirs: String, }, Unrepresentable { protocol: &'static str, field: &'static str, value: String, reason: &'static str, }, EmptyWindow { from: Timestamp, until: Timestamp, }, EmptyRange { isp: IspLabel, min: Power, max: Power, }, GuaranteeBreached(Box<Breach>), Method { method: MethodId, reason: String, }, NoData { what: &'static str, }, ParseDigest { text: String, }, ParseMethod { text: String, }, IspRange { first: u32, last: u32, count: u32, },
}
Expand description

Why an operation refused. Every variant names the values involved; Display renders it as one line, and Error::hint suggests a remedy where there is one.

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

Overflow

Arithmetic left the representable range.

Fields

§quantity: &'static str

power, deviation or energy.

§operation: &'static str

The operation, such as + or negate.

§left: i128

The left operand, or the only one.

§right: Option<i128>

The right operand, if any.

§

PowerOutOfRange

A magnitude larger than the largest representable power.

Fields

§watts: u64

The magnitude in watts.

§

NegativeAmount

An amount that must not be negative was.

Fields

§power: Power

The amount given.

§

ParsePower

Power text that is not an exact power with a unit.

Fields

§text: String

The text, or its length if it was too long to keep.

§reason: &'static str

Why.

§

Inexact

A division with Rounding::Exact left a remainder.

Fields

§numerator: i128

The numerator.

§denominator: i128

The denominator.

§

IspDuration

An ISP duration that does not divide a day into whole ISPs.

Fields

§minutes: u16

The duration in minutes.

§

GridSize

A grid with no ISPs or more than MAX_ISPS.

Fields

§count: u64

The requested number of ISPs.

§

TimeRange

A grid whose end lies outside the representable time range.

Fields

§start: Timestamp

The grid’s start.

§count: u32

The requested number of ISPs.

§

Day

A date that has no day grid in the zone.

Fields

§date: Date

The date.

§zone: String

The zone’s name, or unnamed.

§reason: &'static str

Why.

§

LocalTime

A local wall-clock time that is skipped or repeated on its date, or out of range.

Fields

§date: Date

The date.

§time: Time

The local time.

§zone: String

The zone’s name, or unnamed.

§reason: &'static str

Why.

§

GridMismatch

Two values on different grids.

Fields

§left: Grid

The left operand’s grid.

§right: Grid

The right operand’s grid.

§

SeriesLength

A series with a different number of values than its grid has ISPs.

Fields

§expected: u32

The grid’s ISP count.

§actual: usize

The number of values given.

§

InvertedBounds

A minimum above the maximum.

Fields

§min: Power

The minimum.

§max: Power

The maximum.

§

DeviceId

A device id that is empty, longer than 64 characters or contains a control character.

Fields

§id: String

The id, escaped and shortened.

§reason: &'static str

Why.

§

Receipt

A received canonical text that is not a settlement this crate would write: not exactly canonical, another profile, or lines that break the settlement rule.

Fields

§path: String

Where in the text: lines[2].deficiency; empty for the text as a whole.

§reason: String

Why, with received text escaped and shortened.

§

InvertedLevel

A level whose minimum is above its maximum.

Fields

§min: Energy

The minimum.

§max: Energy

The maximum.

§

EmptyLevel

Level bounds that together allow no level after an ISP.

Fields

§after: IspLabel

The ISP the boundary ends.

§min: Energy

The combined minimum.

§max: Energy

The combined maximum.

§

InitialLevel

A level that must always hold, which the initial level already breaks.

Fields

§initial: Energy

The initial level.

§level: Level

The level that must always hold.

§

NotABoundary

An instant that is not a boundary between ISPs of the grid.

Fields

§at: Timestamp

The instant.

§grid: Grid

The grid.

§

InvertedBand

A deviation band whose minimum is above its maximum.

Fields

§min: Deviation

The minimum.

§max: Deviation

The maximum.

§

Mismatch

Two values that must agree do not, such as an order’s day and its settlement’s.

Fields

§field: &'static str

What differs.

§ours: String

Our value.

§theirs: String

Theirs.

§

Unrepresentable

A protocol value this crate cannot hold, or a message it cannot read without guessing.

Fields

§protocol: &'static str

The protocol.

§field: &'static str

The field.

§value: String

The value, as written.

§reason: &'static str

Why.

§

EmptyWindow

A window whose end is not after its start.

Fields

§from: Timestamp

The window’s start.

§until: Timestamp

The window’s end.

§

EmptyRange

A combination that leaves an ISP with no allowed power.

Fields

§isp: IspLabel

The first ISP without allowed power.

§min: Power

The combined minimum.

§max: Power

The combined maximum.

§

GuaranteeBreached(Box<Breach>)

A limit that would allow less than a guarantee in force.

§

Method

A baseline method refused its inputs or parameters.

Fields

§method: MethodId

The method.

§reason: String

Why, naming the values involved.

§

NoData

An operation that needs data got none.

Fields

§what: &'static str

What was missing.

§

ParseDigest

Text that is not sha256: and 64 hex digits.

Fields

§text: String

The text, cut to 80 characters.

§

ParseMethod

Text that is not a known method id.

Fields

§text: String

The text, cut to 80 characters.

§

IspRange

ISPs outside a grid.

Fields

§first: u32

The first ISP asked for.

§last: u32

The last ISP asked for.

§count: u32

The grid’s ISP count.

Implementations§

Source§

impl Error

Source

pub fn hint(&self) -> Option<&'static str>

A one-line remedy, where the crate knows one.

use flexibility::Power;
let err = "4.0001 kW".parse::<Power>().unwrap_err();
assert_eq!(err.hint(), Some("power is whole watts: at most three decimals in kW and six in MW"));

Trait Implementations§

Source§

impl Clone for Error

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 Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Eq for Error

Source§

impl Error for Error

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

Replaced by Error::source.
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 Error

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 StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Forget for Error

§

impl Freeze for Error

§

impl Move for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error
where &'static str: Send, RawVecInner: Send, Repr: Send, BoxRaw<Breach>: Send,

§

impl Sync for Error
where RawVecInner: Sync, Repr: Sync, BoxRaw<Breach>: Sync,

§

impl Unpin for Error
where &'static str: Unpin, *const u8 is !null: Unpin, *const u8: Unpin, Box<Breach>: Unpin,

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error
where &'static str: UnwindSafe, RawVecInner: UnwindSafe, *const u8: UnwindSafe, BoxRaw<Breach>: UnwindSafe,

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<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. 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> Same for T

Source§

type Output = T

Should always be Self
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.