pub struct StructureLimits<R = StructureResource, Q = usize>where
Q: ResourceQuantity,{ /* private fields */ }Expand description
Optional limits for processing nested structural data.
R identifies the resource values reported in crate::BudgetError, and
Q is the exact unsigned quantity used for all measurements. The default
configuration uses StructureResource and usize.
§Type Parameters
R- Caller-defined resource identity retained by limits and errors.Q- Exact unsigned quantity used for measurements and accounting.
§Examples
use qubit_budget::StructureLimits;
let limits = StructureLimits::builder()
.max_depth(4)
.max_nodes(16)
.build();
let mut budget = limits.budget();
budget.check_depth(4).expect("the inclusive depth limit should fit");
budget.charge_node().expect("the first node should fit");
assert_eq!(budget.used_nodes(), Some(1));Implementations§
Source§impl<R, Q> StructureLimits<R, Q>where
Q: ResourceQuantity,
impl<R, Q> StructureLimits<R, Q>where
Q: ResourceQuantity,
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates an unconfigured custom-resource limit set.
The default StructureResource/usize configuration is constructed
with Self::new. Custom resource sets use this constructor because
their resource identity is supplied by each *_limit method.
§Returns
Creates an unconfigured custom-resource limit set.
Sourcepub const fn builder() -> StructureLimitsBuilder<R, Q>
pub const fn builder() -> StructureLimitsBuilder<R, Q>
Sourcepub const fn into_builder(self) -> StructureLimitsBuilder<R, Q>
pub const fn into_builder(self) -> StructureLimitsBuilder<R, Q>
Converts these limits into a builder for further configuration.
§Returns
Converts these limits into a builder for further configuration.
Sourcepub fn to_builder(&self) -> StructureLimitsBuilder<R, Q>where
R: Clone,
pub fn to_builder(&self) -> StructureLimitsBuilder<R, Q>where
R: Clone,
Creates a builder by cloning this limit configuration.
Unlike Self::into_builder, this method leaves the original limits
available for reuse.
§Returns
A builder initialized with a clone of every configured limit.
Sourcepub const fn has_limits(&self) -> bool
pub const fn has_limits(&self) -> bool
Returns whether any structural limit is configured.
§Returns
true when at least one structural dimension has a finite limit;
otherwise false.
Sourcepub const fn depth_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn depth_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete depth limit, when configured.
§Returns
Returns the complete depth limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn nodes_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn nodes_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete node limit, when configured.
§Returns
Returns the complete node limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn sequence_items_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn sequence_items_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete sequence-item limit, when configured.
§Returns
Returns the complete sequence-item limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn map_entries_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn map_entries_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete map-entry limit, when configured.
§Returns
Returns the complete map-entry limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn key_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn key_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete structural-key limit, when configured.
§Returns
Returns the complete structural-key limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_depth(&self) -> Option<Q>
pub const fn max_depth(&self) -> Option<Q>
Returns the configured maximum nesting depth.
§Returns
Returns the configured maximum nesting depth.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_nodes(&self) -> Option<Q>
pub const fn max_nodes(&self) -> Option<Q>
Returns the configured maximum number of processed nodes.
§Returns
Returns the configured maximum number of processed nodes.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_sequence_items(&self) -> Option<Q>
pub const fn max_sequence_items(&self) -> Option<Q>
Returns the configured maximum number of items in one sequence.
§Returns
Returns the configured maximum number of items in one sequence.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_map_entries(&self) -> Option<Q>
pub const fn max_map_entries(&self) -> Option<Q>
Returns the configured maximum number of entries in one map.
§Returns
Returns the configured maximum number of entries in one map.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_key_bytes(&self) -> Option<Q>
pub const fn max_key_bytes(&self) -> Option<Q>
Returns the configured maximum byte length of one structural key.
§Returns
Returns the configured maximum byte length of one structural key.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub fn budget(&self) -> StructureBudget<R, Q>where
R: Clone,
pub fn budget(&self) -> StructureBudget<R, Q>where
R: Clone,
Creates an independent structural budget session from these limits.
§Returns
Creates an independent structural budget session from these limits.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for StructureLimits<R, Q>where
Q: ResourceQuantity + Clone,
impl<R: Clone, Q> Clone for StructureLimits<R, Q>where
Q: ResourceQuantity + Clone,
Source§fn clone(&self) -> StructureLimits<R, Q>
fn clone(&self) -> StructureLimits<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