pub struct JsonDecodeOptions { /* private fields */ }Expand description
Configuration switches for crate::LenientJsonDecoder.
Its fields control text normalization, input limits, and error diagnostics. Defaults are intentionally conservative and cover the most common non-fully-trusted text inputs without attempting aggressive repair.
§Examples
use qubit_json::{JsonDecodeOptions, LenientJsonDecoder};
let options = JsonDecodeOptions::strict();
let _decoder = LenientJsonDecoder::new(options);
let _moved_options = options;Implementations§
Source§impl JsonDecodeOptions
impl JsonDecodeOptions
Sourcepub const fn lenient() -> Self
pub const fn lenient() -> Self
Creates the default lenient option set.
§Returns
An option set that enables every supported normalization rule, applies no input-size limit, and redacts input-derived error details.
Sourcepub const fn strict() -> Self
pub const fn strict() -> Self
Creates an option set that disables all text-rewriting rules.
The decoder still applies empty-input classification, optional raw and normalized input-size limits, the configured privacy policy, and stable error mapping before or around parsing and deserialization.
§Returns
An option set that leaves input text unchanged, applies no raw or
normalized size limit,
delegates parsing and deserialization to serde_json, and redacts
input-derived error details.
Sourcepub const fn trim_whitespace(&self) -> bool
pub const fn trim_whitespace(&self) -> bool
Returns whether leading and trailing whitespace is removed.
§Returns
true when surrounding whitespace is removed; otherwise, false.
Sourcepub const fn with_trim_whitespace(self, enabled: bool) -> Self
pub const fn with_trim_whitespace(self, enabled: bool) -> Self
Sourcepub const fn strip_utf8_bom(&self) -> bool
pub const fn strip_utf8_bom(&self) -> bool
Returns whether a leading UTF-8 byte order mark is removed.
§Returns
true when a leading UTF-8 byte order mark is removed; otherwise,
false.
Sourcepub const fn with_strip_utf8_bom(self, enabled: bool) -> Self
pub const fn with_strip_utf8_bom(self, enabled: bool) -> Self
Sourcepub const fn markdown_fence_policy(&self) -> &MarkdownFencePolicy
pub const fn markdown_fence_policy(&self) -> &MarkdownFencePolicy
Sourcepub const fn with_markdown_fence_policy(
self,
markdown_fence_policy: MarkdownFencePolicy,
) -> Self
pub const fn with_markdown_fence_policy( self, markdown_fence_policy: MarkdownFencePolicy, ) -> Self
Sourcepub const fn escape_control_chars_in_strings(&self) -> bool
pub const fn escape_control_chars_in_strings(&self) -> bool
Returns whether raw control characters in JSON strings are escaped.
§Returns
true when raw ASCII control characters inside JSON strings are
escaped; otherwise, false.
Sourcepub const fn with_escape_control_chars_in_strings(self, enabled: bool) -> Self
pub const fn with_escape_control_chars_in_strings(self, enabled: bool) -> Self
Sourcepub const fn max_input_bytes(&self) -> Option<usize>
pub const fn max_input_bytes(&self) -> Option<usize>
Returns the raw input byte-size limit.
§Returns
Some(limit) when accepted raw input is capped at limit bytes, or
None when the decoder enforces no input-size limit.
Sourcepub const fn with_max_input_bytes(self, max_input_bytes: Option<usize>) -> Self
pub const fn with_max_input_bytes(self, max_input_bytes: Option<usize>) -> Self
Sourcepub const fn max_normalized_bytes(&self) -> Option<usize>
pub const fn max_normalized_bytes(&self) -> Option<usize>
Returns the normalized JSON byte-size limit.
§Returns
Some(limit) when normalized JSON is capped at limit bytes, or
None when the decoder enforces no normalized-size limit.
Sourcepub const fn with_max_normalized_bytes(
self,
max_normalized_bytes: Option<usize>,
) -> Self
pub const fn with_max_normalized_bytes( self, max_normalized_bytes: Option<usize>, ) -> Self
Returns these options with a normalized JSON byte-size limit.
The decoder calculates the normalized size before allocating repaired text for raw control characters, so this limit also bounds the allocation caused by supported control-character escaping.
§Parameters
max_normalized_bytes-Some(limit)to cap normalized JSON atlimitbytes, orNoneto remove the limit.
§Returns
The updated option set.
Sourcepub const fn error_privacy_policy(&self) -> ErrorPrivacyPolicy
pub const fn error_privacy_policy(&self) -> ErrorPrivacyPolicy
Returns the privacy policy applied to decoding error diagnostics.
§Returns
The configured error privacy policy.
Sourcepub const fn with_error_privacy_policy(
self,
error_privacy_policy: ErrorPrivacyPolicy,
) -> Self
pub const fn with_error_privacy_policy( self, error_privacy_policy: ErrorPrivacyPolicy, ) -> Self
Trait Implementations§
Source§impl Clone for JsonDecodeOptions
impl Clone for JsonDecodeOptions
Source§fn clone(&self) -> JsonDecodeOptions
fn clone(&self) -> JsonDecodeOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more