Skip to main content

JsonValidatedDecodeOptionsBuilder

Struct JsonValidatedDecodeOptionsBuilder 

Source
pub struct JsonValidatedDecodeOptionsBuilder { /* private fields */ }
Expand description

Builds JsonValidatedDecodeOptions.

Unset optional settings impose no additional limit. A configured zero is a valid bound and permits zero counted nodes or zero source bytes.

§Examples

use qubit_json::decode::{JsonDecoder, JsonNumberPolicy, JsonValidatedDecodeOptions};

let options = JsonValidatedDecodeOptions::builder()
    .max_value_and_key_nodes(3)
    .max_encoded_string_bytes(8)
    .build();
let value = JsonDecoder::unlimited().decode_unique_validated_str(
    r#"{"id":42}"#,
    &options,
    |_path, _token| Ok::<_, std::convert::Infallible>(JsonNumberPolicy::ExactSafeInteger),
)?;
assert_eq!(value.as_value()["id"].as_i64(), Some(42));

Implementations§

Source§

impl JsonValidatedDecodeOptionsBuilder

Source

pub fn admission_policy(self, policy: JsonValidatedAdmissionPolicy) -> Self

Selects the token admission order for validated decoding.

§Parameters
  • policy - The admission order to use.
§Returns

The builder configured with the selected admission policy.

Source

pub fn root_kind(self, kind: JsonRootKind) -> Self

Requires a particular root kind.

§Parameters
  • kind - Root kind required for a successfully decoded document.
§Returns

The builder configured with the required root kind.

Source

pub fn number_model(self, model: JsonDecodeNumberModel) -> Self

Selects the number representation model.

§Parameters
  • model - Number representation model used when numbers are preserved.
§Returns

The builder configured with the selected number model.

Source

pub fn max_value_and_key_nodes(self, maximum: usize) -> Self

Limits value entries and decoded object-key entries per document.

Every JSON value counts once, and every object key also counts once. Zero is a valid limit and permits no counted entries.

§Parameters
  • maximum - Maximum combined value and object-key node count.
§Returns

The builder with this per-document limit configured.

Source

pub fn max_encoded_string_bytes(self, maximum: usize) -> Self

Limits the source bytes inside each string token, excluding quotes. Escape spelling is counted as it appears in the source, so \u0061 consumes six bytes. Zero permits only empty string token contents.

§Parameters
  • maximum - Maximum number of source bytes inside each string token.
§Returns

The builder with this per-token limit configured.

Source

pub fn build(self) -> JsonValidatedDecodeOptions

Builds the configured options.

§Returns

The options snapshot containing all configured settings.

Trait Implementations§

Source§

impl Clone for JsonValidatedDecodeOptionsBuilder

Source§

fn clone(&self) -> Self

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 Debug for JsonValidatedDecodeOptionsBuilder

Source§

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

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

impl Default for JsonValidatedDecodeOptionsBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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, !>

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.