pub struct JsonDecodeLimits<R = JsonResource, Q = usize>where
Q: ResourceQuantity,{ /* private fields */ }json only.Expand description
Optional limits for one JSON decoding session.
§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::json::JsonDecodeLimits;
let limits = JsonDecodeLimits::builder().max_input_bytes(128_usize).max_depth(4_usize).build();
assert_eq!(limits.max_input_bytes(), Some(128));
assert_eq!(limits.value_limits().max_depth(), Some(4));Implementations§
Source§impl<R, Q> JsonDecodeLimits<R, Q>where
Q: ResourceQuantity,
impl<R, Q> JsonDecodeLimits<R, Q>where
Q: ResourceQuantity,
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates an empty decoding limit set with no configured resource limits.
§Returns
Creates an empty decoding limit set with no configured resource limits.
Sourcepub const fn builder() -> JsonDecodeLimitsBuilder<R, Q>
pub const fn builder() -> JsonDecodeLimitsBuilder<R, Q>
Sourcepub const fn into_builder(self) -> JsonDecodeLimitsBuilder<R, Q>
pub const fn into_builder(self) -> JsonDecodeLimitsBuilder<R, Q>
Converts these limits into a builder for further configuration.
§Returns
Converts these limits into a builder for further configuration.
Sourcepub const fn has_limits(&self) -> bool
pub const fn has_limits(&self) -> bool
Returns whether any decoding or nested value limit is configured.
§Returns
true when at least one input or nested value dimension has a finite
limit; otherwise false.
Sourcepub const fn input_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn input_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete raw input-byte limit, when configured.
§Returns
Returns the complete raw input-byte limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn normalized_input_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
pub const fn normalized_input_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>
Returns the complete normalized input-byte limit, when configured.
§Returns
Returns the complete normalized input-byte limit, when configured.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn value_limits(&self) -> &JsonValueLimits<R, Q>
pub const fn value_limits(&self) -> &JsonValueLimits<R, Q>
Borrows the JSON value limits used for decoding.
§Returns
Borrows the JSON value limits used for decoding.
Sourcepub fn into_value_limits(self) -> JsonValueLimits<R, Q>
pub fn into_value_limits(self) -> JsonValueLimits<R, Q>
Consumes these decoding limits and returns their JSON value limits.
§Returns
Consumes these decoding limits and returns their JSON value limits.
Sourcepub const fn max_input_bytes(&self) -> Option<Q>
pub const fn max_input_bytes(&self) -> Option<Q>
Returns the configured raw input-byte maximum.
§Returns
Returns the configured raw input-byte maximum.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Sourcepub const fn max_normalized_input_bytes(&self) -> Option<Q>
pub const fn max_normalized_input_bytes(&self) -> Option<Q>
Returns the configured normalized input-byte maximum.
§Returns
Returns the configured normalized input-byte maximum.
None indicates that the corresponding limit or budget dimension is
unconfigured.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for JsonDecodeLimits<R, Q>where
Q: ResourceQuantity + Clone,
impl<R: Clone, Q> Clone for JsonDecodeLimits<R, Q>where
Q: ResourceQuantity + Clone,
Source§fn clone(&self) -> JsonDecodeLimits<R, Q>
fn clone(&self) -> JsonDecodeLimits<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