pub struct LimitExceededError<R, Q = u64>{
pub resource: R,
pub observed: Observation<Q>,
pub maximum: Q,
}Expand description
Structured facts for a point measurement that exceeded its maximum.
§Type Parameters
R- Caller-defined resource value retained for diagnostics.Q- Copyable measurement value used by the failed constraint.
§Examples
use qubit_budget::LimitExceededError;
use qubit_budget::Observation;
let error = LimitExceededError::exact("depth", 3_u64, 2);
assert_eq!(error.observation(), Observation::Exact(3));
assert_eq!(error.maximum(), 2);Fields§
§resource: RResource associated with the failed point check.
observed: Observation<Q>Observed point measurement or safe lower bound.
maximum: QConfigured inclusive point maximum.
Implementations§
Source§impl<R, Q> LimitExceededError<R, Q>
impl<R, Q> LimitExceededError<R, Q>
Sourcepub const fn exact(resource: R, observed: Q, maximum: Q) -> Self
pub const fn exact(resource: R, observed: Q, maximum: Q) -> Self
Creates a failure from an exact point measurement.
§Parameters
resource- Resource associated with the failed point check.observed- Exact measurement that exceededmaximum.maximum- Configured inclusive point maximum.
§Returns
A structured failure containing an Observation::Exact measurement.
Sourcepub const fn at_least(resource: R, lower_bound: Q, maximum: Q) -> Self
pub const fn at_least(resource: R, lower_bound: Q, maximum: Q) -> Self
Creates a failure from a safe lower bound for a point measurement.
§Parameters
resource- Resource associated with the failed point check.lower_bound- Proven lower bound that exceededmaximum.maximum- Configured inclusive point maximum.
§Returns
A structured failure containing an Observation::AtLeast
measurement.
Sourcepub const fn resource(&self) -> &R
pub const fn resource(&self) -> &R
Returns the resource associated with this failure.
§Returns
Returns the resource associated with this failure.
Sourcepub fn into_resource(self) -> R
pub fn into_resource(self) -> R
Consumes this error and returns its associated resource.
§Returns
Consumes this error and returns its associated resource.
Sourcepub const fn observation(&self) -> Observation<Q>
pub const fn observation(&self) -> Observation<Q>
Returns the observed point measurement or safe lower bound.
§Returns
Returns the observed point measurement or safe lower bound.
Sourcepub const fn exact_observed(&self) -> Option<Q>
pub const fn exact_observed(&self) -> Option<Q>
Returns the exact point measurement when the observation is exact.
§Returns
Returns the exact point measurement when the observation is exact.
None indicates that the observation is only a lower bound.
Sourcepub const fn observed_lower_bound(&self) -> Q
pub const fn observed_lower_bound(&self) -> Q
Returns the safe lower bound of the observed point measurement.
§Returns
Returns the safe lower bound of the observed point measurement.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for LimitExceededError<R, Q>
impl<R: Clone, Q> Clone for LimitExceededError<R, Q>
Source§fn clone(&self) -> LimitExceededError<R, Q>
fn clone(&self) -> LimitExceededError<R, Q>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R: Debug, Q> Debug for LimitExceededError<R, Q>
impl<R: Debug, Q> Debug for LimitExceededError<R, Q>
Source§impl<R, Q> Display for LimitExceededError<R, Q>
impl<R, Q> Display for LimitExceededError<R, Q>
impl<R: Eq, Q> Eq for LimitExceededError<R, Q>
Source§impl<R, Q> Error for LimitExceededError<R, Q>
impl<R, Q> Error for LimitExceededError<R, Q>
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()