pub struct BigIntegerLimits<R, Q = u64>where
Q: ResourceQuantity,{ /* private fields */ }big-integer only.Expand description
Optional point limits for one arbitrary-precision integer.
§Type Parameters
R- Caller-defined resource identity retained by limits and errors.Q- Exact unsigned quantity used for measurements and accounting.
§Examples
use num_bigint::BigInt;
use qubit_budget::BigIntegerLimits;
use qubit_budget::ResourceLimit;
let limits = BigIntegerLimits::builder()
.magnitude_bits_limit(ResourceLimit::new("integer bits", 8_u64))
.build();
limits.check(&BigInt::from(255_u16)).expect("255 needs eight bits");Implementations§
Source§impl<R, Q> BigIntegerLimits<R, Q>where
Q: ResourceQuantity,
impl<R, Q> BigIntegerLimits<R, Q>where
Q: ResourceQuantity,
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates limits with no configured integer bounds.
§Returns
Creates limits with no configured integer bounds.
Sourcepub const fn builder() -> BigIntegerLimitsBuilder<R, Q>
pub const fn builder() -> BigIntegerLimitsBuilder<R, Q>
Sourcepub const fn into_builder(self) -> BigIntegerLimitsBuilder<R, Q>
pub const fn into_builder(self) -> BigIntegerLimitsBuilder<R, Q>
Converts these limits into a builder for further configuration.
§Returns
Converts these limits into a builder for further configuration.
Sourcepub const fn magnitude_bits_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn magnitude_bits_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the configured magnitude bit-length limit, if any.
§Returns
Returns the configured magnitude bit-length limit, if any.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn significant_decimal_digits_limit(
&self,
) -> Option<&ResourceLimit<R, Q>>
pub const fn significant_decimal_digits_limit( &self, ) -> Option<&ResourceLimit<R, Q>>
Returns the configured significant decimal digit limit, if any.
§Returns
Returns the configured significant decimal digit limit, if any.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub fn check(&self, value: &BigInt) -> Result<(), MeasuredBudgetError<R, Q>>where
R: Clone,
pub fn check(&self, value: &BigInt) -> Result<(), MeasuredBudgetError<R, Q>>where
R: Clone,
Checks one integer without formatting clearly oversized values.
Values near the decimal boundary are formatted once. Clearly oversized values report a conservative lower bound instead of allocating a decimal string proportional to the input magnitude.
§Parameters
value- Arbitrary-precision integer whose magnitude and decimal digit counts are compared with the configured limits.
§Returns
Ok(()) when the operation completes successfully.
§Errors
Returns MeasuredBudgetError when a native measurement cannot fit Q
or a configured limit rejects it.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for BigIntegerLimits<R, Q>where
Q: ResourceQuantity + Clone,
impl<R: Clone, Q> Clone for BigIntegerLimits<R, Q>where
Q: ResourceQuantity + Clone,
Source§fn clone(&self) -> BigIntegerLimits<R, Q>
fn clone(&self) -> BigIntegerLimits<R, Q>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more