pub struct NormalizingJsonDecodePolicy { /* private fields */ }Expand description
Text-normalization and diagnostic policy for
crate::decode::NormalizingJsonDecoder.
Resource limits deliberately live in
qubit_budget::json::JsonDecodeLimits
and are supplied separately when constructing a decoder.
§Examples
use qubit_json::decode::NormalizingJsonDecodePolicy;
let policy = NormalizingJsonDecodePolicy::builder()
.trim_whitespace(false)
.build();
assert!(!policy.trim_whitespace());Implementations§
Source§impl NormalizingJsonDecodePolicy
impl NormalizingJsonDecodePolicy
Sourcepub const fn lenient() -> Self
pub const fn lenient() -> Self
Creates the default permissive normalization policy.
The defaults trim surrounding whitespace, strip a leading UTF-8 BOM, accept JSON-only Markdown fences with an optional closing fence, escape raw string control characters, and redact input-derived diagnostics.
§Returns
A policy with the documented permissive defaults.
Sourcepub const fn builder() -> NormalizingJsonDecodePolicyBuilder
pub const fn builder() -> NormalizingJsonDecodePolicyBuilder
Creates a builder initialized with the lenient policy.
§Returns
A builder whose fields can be selectively changed before build.
Sourcepub const fn trim_whitespace(&self) -> bool
pub const fn trim_whitespace(&self) -> bool
Returns whether surrounding whitespace is removed.
§Returns
true when leading and trailing whitespace is discarded before JSON
parsing.
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 BOM is discarded before JSON parsing.
Sourcepub const fn markdown_fence_policy(&self) -> &MarkdownFencePolicy
pub const fn markdown_fence_policy(&self) -> &MarkdownFencePolicy
Returns the outer Markdown fence policy.
§Returns
A shared reference to the policy governing Markdown fence stripping.
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 strings are escaped.
§Returns
true when raw JSON string control characters are rewritten to escaped
forms during normalization.
Sourcepub const fn diagnostic_policy(&self) -> DiagnosticPolicy
pub const fn diagnostic_policy(&self) -> DiagnosticPolicy
Returns the error diagnostic policy.
§Returns
The policy controlling retention of input-derived error details.
Trait Implementations§
Source§impl Clone for NormalizingJsonDecodePolicy
impl Clone for NormalizingJsonDecodePolicy
Source§fn clone(&self) -> NormalizingJsonDecodePolicy
fn clone(&self) -> NormalizingJsonDecodePolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more