Skip to main content

JsonEncodeLimits

Struct JsonEncodeLimits 

Source
pub struct JsonEncodeLimits<R = JsonResource, Q = usize>{ /* private fields */ }
Available on crate feature json only.
Expand description

Optional limits for one JSON encoding 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::JsonEncodeLimits;

let limits = JsonEncodeLimits::builder().max_output_bytes(128_usize).max_depth(4_usize).build();
assert_eq!(limits.max_output_bytes(), Some(128));
assert_eq!(limits.value_limits().max_depth(), Some(4));

Implementations§

Source§

impl<R, Q> JsonEncodeLimits<R, Q>

Source

pub const fn new() -> Self

Creates an empty encoding limit set with no configured resource limits.

§Returns

Creates an empty encoding limit set with no configured resource limits.

Source

pub const fn builder() -> JsonEncodeLimitsBuilder<R, Q>

Creates a builder for JSON encoding limits.

§Returns

Creates a builder for JSON encoding limits.

Source

pub const fn into_builder(self) -> JsonEncodeLimitsBuilder<R, Q>

Converts these limits into a builder for further configuration.

§Returns

Converts these limits into a builder for further configuration.

Source

pub const fn has_limits(&self) -> bool

Returns whether any encoding or nested value limit is configured.

§Returns

true when the output limit or at least one nested value limit is configured; otherwise false.

Source

pub const fn output_bytes_limit(&self) -> Option<&ResourceLimit<R, Q>>

Returns the complete output-byte limit, when configured.

§Returns

Returns the complete output-byte limit, when configured.

None indicates that the corresponding limit or budget dimension is unconfigured.

Source

pub const fn value_limits(&self) -> &JsonValueLimits<R, Q>

Borrows the JSON value limits used for encoding.

§Returns

Borrows the JSON value limits used for encoding.

Source

pub fn into_value_limits(self) -> JsonValueLimits<R, Q>

Consumes these encoding limits and returns their JSON value limits.

§Returns

Consumes these encoding limits and returns their JSON value limits.

Source

pub const fn max_output_bytes(&self) -> Option<Q>

Returns the configured output-byte maximum.

§Returns

Returns the configured output-byte maximum.

None indicates that the corresponding limit or budget dimension is unconfigured.

Trait Implementations§

Source§

impl<R: Clone, Q> Clone for JsonEncodeLimits<R, Q>

Source§

fn clone(&self) -> JsonEncodeLimits<R, Q>

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<R: Copy, Q> Copy for JsonEncodeLimits<R, Q>

Source§

impl<R: Debug, Q> Debug for JsonEncodeLimits<R, Q>

Source§

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

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

impl<R, Q> Default for JsonEncodeLimits<R, Q>

Source§

fn default() -> Self

Creates encoding limits with every dimension unconfigured.

§Returns

Creates encoding limits with every dimension unconfigured.

Source§

impl<R: Eq, Q> Eq for JsonEncodeLimits<R, Q>
where Q: ResourceQuantity + Eq,

Source§

impl<R: Hash, Q> Hash for JsonEncodeLimits<R, Q>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<R: PartialEq, Q> PartialEq for JsonEncodeLimits<R, Q>

Source§

fn eq(&self, other: &JsonEncodeLimits<R, Q>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<R: PartialEq, Q> StructuralPartialEq for JsonEncodeLimits<R, Q>

Auto Trait Implementations§

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<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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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, 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, <T as TryFrom<U>>::Error>

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.