#[non_exhaustive]pub struct ParserConfig {Show 35 fields
pub yaml_version: YamlVersion,
pub max_depth: usize,
pub max_document_length: usize,
pub max_alias_expansions: usize,
pub max_mapping_keys: usize,
pub max_sequence_length: usize,
pub max_events: usize,
pub max_nodes: usize,
pub max_total_scalar_bytes: usize,
pub max_documents: usize,
pub max_merge_keys: usize,
pub alias_anchor_ratio: Option<f64>,
pub duplicate_key_policy: DuplicateKeyPolicy,
pub strict_booleans: bool,
pub legacy_booleans: bool,
pub tag_registry: Option<Arc<TagRegistry>>,
pub merge_key_policy: MergeKeyPolicy,
pub no_schema: bool,
pub legacy_octal_numbers: bool,
pub ignore_binary_tag_for_string: bool,
pub plain_scalar_strings: bool,
pub legacy_sexagesimal: bool,
pub lossless_u64_integers: bool,
pub leading_zero_integer_strings: bool,
pub legacy_binary_numbers: bool,
pub float_overflow_strings: bool,
pub integer_overflow_errors: bool,
pub non_scalar_key_policy: NonScalarKeyPolicy,
pub alias_jump_event_factor: Option<usize>,
pub require_indent: RequireIndent,
pub policies: Vec<Arc<dyn Policy>>,
pub properties: Option<Arc<HashMap<String, String>>>,
pub strict_properties: bool,
pub include_resolver: Option<IncludeResolver>,
pub max_include_depth: usize,
}Expand description
Deserialization configuration.
All fields are public, but the struct is annotated
#[non_exhaustive] so that adding a new budget or
policy in a future minor release is not a breaking change.
Construct with ParserConfig::new / ParserConfig::strict
/ ParserConfig::default (preferred) or with the
..ParserConfig::default() struct-update form; do not
construct from an exhaustive struct-literal outside this
crate.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_depth(64);
assert_eq!(cfg.max_depth, 64);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.yaml_version: YamlVersionWhich YAML specification version to honour during plain-scalar resolution.
YAML 1.2 (default) follows the core schema — strict
true/false booleans, no bare 0-prefix octal, no
sexagesimal 60:00 integers. YAML 1.1 broadens the resolver
to accept all of those legacy forms.
Setting this to YamlVersion::V1_1 is equivalent to flipping
every legacy_* flag (legacy_booleans, legacy_octal_numbers,
legacy_sexagesimal) on at once. The legacy_* flags remain
available for fine-grained overrides — version selection sets a
preset, individual flags refine it.
max_depth: usizeMaximum recursion depth allowed during parsing (default: 128).
max_document_length: usizeMaximum length of a single YAML document in bytes (default: 64 MB).
max_alias_expansions: usizeMaximum number of times a single anchor can be expanded (default: 1024).
max_mapping_keys: usizeMaximum number of keys allowed in a single mapping (default: 64k).
max_sequence_length: usizeMaximum number of elements allowed in a single sequence (default: 64k).
max_events: usizeMaximum total parser events emitted across the input
(default: 1 000 000). Caps event-stream amplification
independent of recursion depth or alias count. Trips
crate::Error::Budget with
crate::BudgetBreach::MaxEvents.
max_nodes: usizeMaximum total Value nodes authored into the AST across the
input (default: 250 000). Each scalar, sequence, and mapping —
empty collections included — counts as one node, so this bounds
node-dense payloads (long runs of []/{}) that stay under the
scalar-byte and event caps. Trips crate::Error::Budget with
crate::BudgetBreach::MaxNodes. Enforced on the AST-loader
path; raise it for deliberately large documents.
max_total_scalar_bytes: usizeMaximum cumulative scalar-byte count across the document
(default: 64 MB). Distinct from
Self::max_document_length (input size) — this caps
scalar payload after alias expansion. Trips
crate::BudgetBreach::MaxTotalScalarBytes.
max_documents: usizeMaximum number of documents in a multi-document stream
(default: 1 000). Trips
crate::BudgetBreach::MaxDocuments.
max_merge_keys: usizeMaximum number of merge-key (<<) entries across the
document (default: 10 000). Trips
crate::BudgetBreach::MaxMergeKeys.
alias_anchor_ratio: Option<f64>Optional alias-to-anchor ratio heuristic for detecting
billion-laughs amplification patterns
(default: Some(10.0)). When more than ratio × anchors
aliases have been resolved, the parser trips
crate::BudgetBreach::AliasAnchorRatio. Set to None
to disable.
duplicate_key_policy: DuplicateKeyPolicyHow to handle duplicate keys in a mapping (default: Last, per YAML 1.2).
strict_booleans: boolIf true, only true and false (lowercase) are accepted as booleans.
legacy_booleans: boolIf true, accepts YAML 1.1 booleans like yes, no, on, off.
tag_registry: Option<Arc<TagRegistry>>Optional registry of custom tags to strip on the streaming path.
See TagRegistry for the full rationale.
None (default) preserves the legacy behaviour of routing every
custom-tagged value through the AST fallback.
merge_key_policy: MergeKeyPolicyHow the YAML merge key (<<) should be handled.
See MergeKeyPolicy for the available policies. The
default is MergeKeyPolicy::Auto — the YAML 1.2 spec
behaviour where <<: triggers automatic mapping merge.
no_schema: boolWhen true, plain scalars are never resolved to
null / bool / int / float — every plain scalar
becomes a string. Useful for schema-strict pipelines that
require the user to quote intent explicitly. Default
false.
legacy_octal_numbers: boolWhen true, accept YAML 1.1-style bare 0-prefix octal
literals (e.g. 0644 parsed as 420) in addition to the
YAML 1.2 0o644 form. Default false to honour the YAML
1.2 schema.
ignore_binary_tag_for_string: boolWhen true, deserializing !!binary "ABCD" into a
String target yields the literal base64 source string
("ABCD") rather than rejecting on tag mismatch. The
canonical bytes path (Vec<u8>,
serde_bytes::ByteBuf) still decodes the base64 payload
either way. Useful for migrations from Python pyyaml-style
applications that treat the tag as advisory. Default
false.
plain_scalar_strings: boolWhen enabled, a plain scalar deserializes into a String
(or char) target as its source text even where the YAML 1.2
schema resolves it to a number, boolean, or null:
password: 123456 gives "123456", ~ gives "~", an empty
value gives "". Off by default: a String field refuses a
non-string plain scalar. Quoted scalars are strings either
way. Matches what serde_yaml did for typed targets.
legacy_sexagesimal: boolWhen true, accept YAML 1.1-style sexagesimal numbers
(60:00, 1:30:00) as integers. The colon-separated
digits are interpreted in base 60: each component is
multiplied by an increasing power of 60, summed left to
right. 60:00 → 3 600; 1:30:00 → 5 400. Negative values
(-1:30:00) and partial signs are honoured.
Off by default to honour the YAML 1.2 schema. Useful for migrations from YAML 1.1 / Ruby / pyyaml configs that use the legacy time-of-day notation.
lossless_u64_integers: boollossless-u64 only.When true, and the lossless-u64 Cargo feature is enabled,
YAML integer scalars in (i64::MAX, u64::MAX] resolve as
unsigned integers instead of falling through to f64.
Default false to preserve the historical public
Integer(i64) / Float(f64) model and serde-yaml compatibility.
leading_zero_integer_strings: boolWhen true, a plain decimal integer with a leading zero
(0123, +007) resolves as a string instead of a
number. This is what serde_yaml 0.9 (libyaml) did — the
spelling is octal in YAML 1.1 and decimal in 1.2, and
libyaml sidestepped the ambiguity by resolving neither.
0, 0o755, and 0x1F are unaffected. Default false
(YAML 1.2: a decimal integer).
legacy_binary_numbers: boolWhen true, accept YAML 1.1-style binary literals
(0b11 → 3). Default false to honour the YAML 1.2
schema, which has no binary form.
float_overflow_strings: boolWhen true, a plain scalar float whose literal spelling
overflows f64 (1e999) resolves as a string instead
of infinity. The explicit spellings .inf / -.Inf /
.nan still resolve to their float values. Matches
serde_yaml 0.9. Default false (overflow saturates to
infinity, the Rust float-parsing convention).
integer_overflow_errors: boolWhen true, a plain decimal integer beyond u64::MAX
(18446744073709551616) aborts the parse with
ErrorKind::IntegerOverflow instead
of falling through to an approximate f64. Matches
serde_yaml 0.9’s “JSON number out of range”. Default
false.
non_scalar_key_policy: NonScalarKeyPolicyWhat to do with a non-scalar mapping key ([a, b]: v,
{k: v}: w). See NonScalarKeyPolicy. Default
NonScalarKeyPolicy::Stringify — the key is converted
to its deterministic string form.
alias_jump_event_factor: Option<usize>Transitive alias-expansion budget as a multiple of the
document’s own event count, mirroring serde_yaml 0.9’s
rule (its deserializer refuses once alias jumps exceed
events × 100 with “repetition limit exceeded”). Each
alias expansion charges the full node count of the anchored
subtree, so nested anchors multiply. None (default)
disables the factor check; the absolute
Self::max_alias_expansions and byte budgets still
apply.
require_indent: RequireIndentIndentation-validation mode. See RequireIndent.
Default: RequireIndent::Unchecked — accept any
well-formed YAML indent.
policies: Vec<Arc<dyn Policy>>Pluggable “Safe YAML” policies, run during parsing.
Each Policy inspects parser
events and the post-parse Value tree; any policy
returning Err(...) aborts the parse with that diagnostic.
Empty by default.
Use ParserConfig::with_policy to register a policy.
When at least one policy is present the streaming fast-path
is bypassed automatically so the policy contract holds for
every code path.
properties: Option<Arc<HashMap<String, String>>>std only.${KEY} / ${KEY:-default} substitution table consulted
after parsing every document.
Each scalar in the resulting Value tree is walked and
any ${name} placeholder is replaced with the property of
that name. Supported syntax:
${name}— substitute, error or pass through depending onSelf::strict_properties${name:-default}— substitute, falling back todefaultwhennameis missing (always silent, never surfaces in errors)${{— literal${(escape for the open delimiter)$$— literal$}}— literal}
None (default) disables the substitution pass entirely;
the parser is unchanged. Setting a non-empty map forces the
AST fallback so the post-parse walk runs uniformly across
every typed target.
strict_properties: boolstd only.When true, an unknown ${name} placeholder (no entry in
Self::properties and no :-default fallback) aborts
the parse with Error::Custom.
When false (default), unknown placeholders are replaced
with the empty string — the lossy semantics matching
Value::interpolate_properties_lossy.
include_resolver: Option<IncludeResolver>include only.!include directive resolver. When set, the post-parse
walk substitutes every Value::Tagged(!include, spec)
node with the result of resolver(IncludeRequest). See
crate::include::IncludeResolver for the closure
signature and crate::include::SafeFileResolver for
the bundled filesystem implementation.
None (default) disables include expansion; tagged
!include nodes flow through unchanged.
max_include_depth: usizeinclude only.Maximum !include recursion depth. Default 24. Each
nested !include increments the depth counter; once the
limit is reached, the parser aborts with
Error::RecursionLimitExceeded. Pairs with a per-walk
visited-set to catch cycles independent of depth.
Implementations§
Source§impl ParserConfig
impl ParserConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new configuration with default values.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new();
assert_eq!(cfg.max_depth, 128);Sourcepub fn strict() -> Self
pub fn strict() -> Self
Create a strict configuration (YAML 1.2 strict) with tighter security limits suitable for untrusted input.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::strict();
assert_eq!(cfg.max_depth, 64);Sourcepub fn serde_yaml_compat() -> Self
pub fn serde_yaml_compat() -> Self
Create the configuration the compat-serde-yaml shim uses:
noyalib’s defaults with every knob turned to reproduce
serde_yaml 0.9’s observable behaviour on the same input —
the behavioural half of being a drop-in replacement.
Concretely, relative to ParserConfig::new:
<<merge keys stay ordinary entries whose alias values resolve (MergeKeyPolicy::AsOrdinary) — serde_yaml never implemented the merge;- leading-zero integers (
0123) resolve as strings and YAML 1.1 binary literals (0b11) as integers — libyaml’s resolver, spec versions notwithstanding; - a literal float overflow (
1e999) is a string, not infinity; - integers past
u64::MAXerror (“JSON number out of range” territory) instead of degrading tof64, and (with thelossless-u64feature the shim enables)u64-range integers keep full precision; - a non-scalar mapping key is an error, not a stringified key;
- transitive alias expansion is budgeted at 100× the document’s event count — the exact rule behind serde_yaml’s “repetition limit exceeded”.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::serde_yaml_compat();
assert!(cfg.leading_zero_integer_strings);
assert_eq!(cfg.alias_jump_event_factor, Some(100));Sourcepub fn properties(self, properties: Arc<HashMap<String, String>>) -> Self
Available on crate feature std only.
pub fn properties(self, properties: Arc<HashMap<String, String>>) -> Self
std only.Install a ${KEY} substitution table consulted after
parsing.
Each scalar in the resulting Value tree is walked and
any ${name} placeholder is replaced with the property of
that name. Pairs with Self::strict_properties to choose
between erroring or silently empty-substituting on unknown
keys, and with ${name:-default} syntax for inline
defaults.
§Examples
use noyalib::{from_str_with_config, ParserConfig, Value};
use std::collections::HashMap;
use std::sync::Arc;
let mut props = HashMap::new();
props.insert("HOST".to_string(), "localhost".to_string());
let cfg = ParserConfig::new().properties(Arc::new(props));
let v: Value = from_str_with_config("url: http://${HOST}/", &cfg).unwrap();
assert_eq!(v["url"].as_str(), Some("http://localhost/"));Sourcepub fn strict_properties(self, strict: bool) -> Self
Available on crate feature std only.
pub fn strict_properties(self, strict: bool) -> Self
std only.Toggle strict-mode placeholder resolution.
When true, an unknown ${name} (no map entry, no
:-default fallback) aborts the parse. When false
(default), unknown placeholders are replaced with the empty
string — useful for environment-style configs where missing
variables should silently degrade.
§Examples
use noyalib::{from_str_with_config, ParserConfig, Value};
use std::collections::HashMap;
use std::sync::Arc;
let cfg = ParserConfig::new()
.properties(Arc::new(HashMap::new()))
.strict_properties(true);
let res: Result<Value, _> = from_str_with_config("x: ${MISSING}", &cfg);
assert!(res.is_err());Sourcepub fn include_resolver(self, resolver: IncludeResolver) -> Self
Available on crate feature include only.
pub fn include_resolver(self, resolver: IncludeResolver) -> Self
include only.Install an !include directive resolver.
Each Value::Tagged(!include, scalar_spec) node in the
parsed tree is replaced with the resolver’s output. The
resolver is consulted with an IncludeRequest carrying
the verbatim spec text, a stable source-id, and the
current recursion depth.
Pair with Self::max_include_depth to bound the
recursion ceiling. Cycle detection (A includes B includes
A) runs independently using a per-walk visited set.
§Examples
use noyalib::include::{IncludeRequest, IncludeResolver, InputSource};
use noyalib::{ParserConfig, Result};
let resolver = IncludeResolver::new(|req: IncludeRequest<'_>| -> Result<InputSource> {
// For an in-memory test, fabricate a YAML payload
// keyed on the spec.
Ok(InputSource::new(req.spec, format!("name: {}\n", req.spec)))
});
let cfg = ParserConfig::new().include_resolver(resolver);Sourcepub fn max_include_depth(self, depth: usize) -> Self
Available on crate feature include only.
pub fn max_include_depth(self, depth: usize) -> Self
include only.Maximum !include recursion depth.
Default 24 (8 in Self::strict()). Each nested
!include increments the depth; once the limit is
reached, the parser aborts with
Error::RecursionLimitExceeded. The cap is independent
of Self::max_depth (which bounds YAML structural
nesting) and of the per-walk cycle-detection set (which
catches A→B→A regardless of depth).
Sourcepub fn version(self, version: YamlVersion) -> Self
pub fn version(self, version: YamlVersion) -> Self
Select the YAML specification version the resolver should honour.
Selecting YamlVersion::V1_1 is a preset over the three
legacy_* flags — equivalent to:
cfg.legacy_booleans = true; // yes / no / on / off
cfg.legacy_octal_numbers = true; // 0644 → octal
cfg.legacy_sexagesimal = true; // 60:00 → 3600Selecting YamlVersion::V1_2 resets those three flags to
false so callers can revert to strict 1.2 mode without
re-creating the config from scratch. Other fields (limits,
policies, merge-key behaviour) are unaffected.
Fine-grained overrides (e.g. “1.1 booleans but reject octal
0644”) work as expected: call version first, then flip
individual flags.
§Examples
use noyalib::{from_str_with_config, ParserConfig, Value, YamlVersion};
let cfg = ParserConfig::new().version(YamlVersion::V1_1);
// YAML 1.1 booleans
let v: Value = from_str_with_config("on", &cfg).unwrap();
assert_eq!(v, Value::Bool(true));
// YAML 1.1 octal
let v: Value = from_str_with_config("0644", &cfg).unwrap();
assert_eq!(v, Value::from(420_i64));
// YAML 1.1 sexagesimal
let v: Value = from_str_with_config("1:30", &cfg).unwrap();
assert_eq!(v, Value::from(90_i64));Sourcepub fn with_policy<P>(self, policy: P) -> Selfwhere
P: Policy + 'static,
pub fn with_policy<P>(self, policy: P) -> Selfwhere
P: Policy + 'static,
Register a Policy to enforce
during parsing.
Multiple policies may be registered; they all run in registration order, and the first error short-circuits the parse. When any policy is present the streaming fast-path is bypassed so the policy contract is enforced uniformly.
§Examples
use noyalib::{from_str_with_config, ParserConfig, Value};
use noyalib::policy::DenyAnchors;
let cfg = ParserConfig::new().with_policy(DenyAnchors);
let res: Result<Value, _> =
from_str_with_config("a: &x 1\nb: *x\n", &cfg);
assert!(res.is_err());Sourcepub fn max_depth(self, depth: usize) -> Self
pub fn max_depth(self, depth: usize) -> Self
Set the maximum recursion depth.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_depth(32);
assert_eq!(cfg.max_depth, 32);Sourcepub fn max_document_length(self, len: usize) -> Self
pub fn max_document_length(self, len: usize) -> Self
Set the maximum document length.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_document_length(1024);
assert_eq!(cfg.max_document_length, 1024);Sourcepub fn max_alias_expansions(self, expansions: usize) -> Self
pub fn max_alias_expansions(self, expansions: usize) -> Self
Set the maximum alias expansions.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_alias_expansions(50);
assert_eq!(cfg.max_alias_expansions, 50);Sourcepub fn max_mapping_keys(self, max: usize) -> Self
pub fn max_mapping_keys(self, max: usize) -> Self
Set the maximum number of mapping keys.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_mapping_keys(100);
assert_eq!(cfg.max_mapping_keys, 100);Sourcepub fn max_sequence_length(self, max: usize) -> Self
pub fn max_sequence_length(self, max: usize) -> Self
Set the maximum sequence length.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_sequence_length(100);
assert_eq!(cfg.max_sequence_length, 100);Sourcepub fn max_events(self, max: usize) -> Self
pub fn max_events(self, max: usize) -> Self
Set the maximum total parser-event budget.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_events(50_000);
assert_eq!(cfg.max_events, 50_000);Sourcepub fn max_nodes(self, max: usize) -> Self
pub fn max_nodes(self, max: usize) -> Self
Set the maximum total Value node budget.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_nodes(10_000);
assert_eq!(cfg.max_nodes, 10_000);Sourcepub fn max_total_scalar_bytes(self, max: usize) -> Self
pub fn max_total_scalar_bytes(self, max: usize) -> Self
Set the maximum cumulative scalar-byte budget.
Distinct from Self::max_document_length — this caps
scalar bytes after alias expansion.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_total_scalar_bytes(8 * 1024 * 1024);
assert_eq!(cfg.max_total_scalar_bytes, 8 * 1024 * 1024);Sourcepub fn max_documents(self, max: usize) -> Self
pub fn max_documents(self, max: usize) -> Self
Set the maximum document count for multi-document streams.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_documents(64);
assert_eq!(cfg.max_documents, 64);Sourcepub fn max_merge_keys(self, max: usize) -> Self
pub fn max_merge_keys(self, max: usize) -> Self
Set the maximum merge-key count budget.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().max_merge_keys(1_000);
assert_eq!(cfg.max_merge_keys, 1_000);Sourcepub fn require_indent(self, mode: RequireIndent) -> Self
pub fn require_indent(self, mode: RequireIndent) -> Self
Set the indentation-validation mode.
§Examples
use noyalib::{ParserConfig, RequireIndent};
let cfg = ParserConfig::new().require_indent(RequireIndent::Even);
assert_eq!(cfg.require_indent, RequireIndent::Even);Sourcepub fn alias_anchor_ratio(self, ratio: Option<f64>) -> Self
pub fn alias_anchor_ratio(self, ratio: Option<f64>) -> Self
Set the alias-to-anchor ratio heuristic.
Pass Some(ratio) to enable the billion-laughs guard,
None to disable.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().alias_anchor_ratio(Some(20.0));
assert_eq!(cfg.alias_anchor_ratio, Some(20.0));Sourcepub fn duplicate_key_policy(self, policy: DuplicateKeyPolicy) -> Self
pub fn duplicate_key_policy(self, policy: DuplicateKeyPolicy) -> Self
Set the duplicate key policy.
§Examples
use noyalib::{DuplicateKeyPolicy, ParserConfig};
let cfg = ParserConfig::new().duplicate_key_policy(DuplicateKeyPolicy::Error);
assert_eq!(cfg.duplicate_key_policy, DuplicateKeyPolicy::Error);Sourcepub fn strict_booleans(self, strict: bool) -> Self
pub fn strict_booleans(self, strict: bool) -> Self
Enable or disable strict booleans.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().strict_booleans(true);
assert!(cfg.strict_booleans);Sourcepub fn legacy_booleans(self, legacy: bool) -> Self
pub fn legacy_booleans(self, legacy: bool) -> Self
Enable or disable legacy booleans.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().legacy_booleans(true);
assert!(cfg.legacy_booleans);Sourcepub fn tag_registry(self, registry: Arc<TagRegistry>) -> Self
pub fn tag_registry(self, registry: Arc<TagRegistry>) -> Self
Attach a TagRegistry so the streaming
deserializer strips listed custom tags instead of routing them
through the AST.
See the tag_registry module
documentation for when to use this versus #[serde(rename)].
§Examples
use noyalib::{ParserConfig, TagRegistry};
use std::sync::Arc;
let reg = Arc::new(TagRegistry::new().with("!Celsius"));
let cfg = ParserConfig::new().tag_registry(Arc::clone(®));
assert!(cfg.tag_registry.is_some());Sourcepub fn merge_key_policy(self, policy: MergeKeyPolicy) -> Self
pub fn merge_key_policy(self, policy: MergeKeyPolicy) -> Self
Set the policy for handling the YAML merge key (<<).
§Examples
use noyalib::{MergeKeyPolicy, ParserConfig};
let cfg = ParserConfig::new().merge_key_policy(MergeKeyPolicy::AsOrdinary);
assert_eq!(cfg.merge_key_policy, MergeKeyPolicy::AsOrdinary);Sourcepub fn no_schema(self, no_schema: bool) -> Self
pub fn no_schema(self, no_schema: bool) -> Self
Toggle schema-free plain-scalar resolution. When true,
every plain scalar becomes a string regardless of whether
it would normally resolve to null, bool, integer, or
float.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().no_schema(true);
assert!(cfg.no_schema);Sourcepub fn legacy_octal_numbers(self, on: bool) -> Self
pub fn legacy_octal_numbers(self, on: bool) -> Self
Toggle YAML 1.1-style bare 0-prefix octal parsing
(e.g. 0644 → 420). Off by default; YAML 1.2 requires the
0o prefix.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().legacy_octal_numbers(true);
assert!(cfg.legacy_octal_numbers);Sourcepub fn ignore_binary_tag_for_string(self, on: bool) -> Self
pub fn ignore_binary_tag_for_string(self, on: bool) -> Self
Toggle the migration-helper behaviour where
!!binary "ABCD" deserializes into a String target as
the literal base64 source string. The canonical bytes
path (Vec<u8>, serde_bytes::ByteBuf) is unaffected —
it always decodes the base64 payload.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().ignore_binary_tag_for_string(true);
assert!(cfg.ignore_binary_tag_for_string);Sourcepub fn plain_scalar_strings(self, on: bool) -> Self
pub fn plain_scalar_strings(self, on: bool) -> Self
When enabled, a plain scalar deserializes into a String
(or char) target as its source text even where the YAML 1.2
schema resolves it to a number, boolean, or null:
password: 123456 gives "123456", ~ gives "~", an empty
value gives "". Off by default: a String field refuses a
non-string plain scalar. Quoted scalars are strings either
way. Matches what serde_yaml did for typed targets.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().plain_scalar_strings(true);
assert!(cfg.plain_scalar_strings);Sourcepub fn legacy_sexagesimal(self, on: bool) -> Self
pub fn legacy_sexagesimal(self, on: bool) -> Self
Toggle YAML 1.1-style sexagesimal number parsing
(60:00 → 3 600). Off by default; YAML 1.2 dropped the
sexagesimal schema, so plain 1:30:00 would otherwise
surface as a string.
§Examples
use noyalib::ParserConfig;
let cfg = ParserConfig::new().legacy_sexagesimal(true);
assert!(cfg.legacy_sexagesimal);Sourcepub fn lossless_u64_integers(self, on: bool) -> Self
Available on crate feature lossless-u64 only.
pub fn lossless_u64_integers(self, on: bool) -> Self
lossless-u64 only.Enable or disable lossless unsigned integer resolution.
With the lossless-u64 feature enabled, setting this to
true lets YAML integer scalars in (i64::MAX, u64::MAX]
resolve as Number::Unsigned instead of falling through to
Number::Float.
Trait Implementations§
Source§impl Clone for ParserConfig
impl Clone for ParserConfig
Source§fn clone(&self) -> ParserConfig
fn clone(&self) -> ParserConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParserConfig
impl Debug for ParserConfig
Auto Trait Implementations§
impl !RefUnwindSafe for ParserConfig
impl !UnwindSafe for ParserConfig
impl Freeze for ParserConfig
impl Send for ParserConfig
impl Sync for ParserConfig
impl Unpin for ParserConfig
impl UnsafeUnpin for ParserConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSendSync for T
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);