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
impl JsonValidatedDecodeOptionsBuilder
Sourcepub fn admission_policy(self, policy: JsonValidatedAdmissionPolicy) -> Self
pub fn admission_policy(self, policy: JsonValidatedAdmissionPolicy) -> Self
Sourcepub fn root_kind(self, kind: JsonRootKind) -> Self
pub fn root_kind(self, kind: JsonRootKind) -> Self
Sourcepub fn number_model(self, model: JsonDecodeNumberModel) -> Self
pub fn number_model(self, model: JsonDecodeNumberModel) -> Self
Sourcepub fn max_value_and_key_nodes(self, maximum: usize) -> Self
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.
Sourcepub fn max_encoded_string_bytes(self, maximum: usize) -> Self
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.
Sourcepub fn build(self) -> JsonValidatedDecodeOptions
pub fn build(self) -> JsonValidatedDecodeOptions
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsonValidatedDecodeOptionsBuilder
impl RefUnwindSafe for JsonValidatedDecodeOptionsBuilder
impl Send for JsonValidatedDecodeOptionsBuilder
impl Sync for JsonValidatedDecodeOptionsBuilder
impl Unpin for JsonValidatedDecodeOptionsBuilder
impl UnsafeUnpin for JsonValidatedDecodeOptionsBuilder
impl UnwindSafe for JsonValidatedDecodeOptionsBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more