pub struct Options {
pub budget: Option<Budget>,
pub duplicate_keys: DuplicateKeyPolicy,
pub alias_limits: AliasLimits,
pub legacy_octal_numbers: bool,
pub strict_booleans: bool,
pub ignore_binary_tag_for_string: bool,
pub angle_conversions: bool,
pub no_schema: bool,
}Expand description
Parser configuration options.
Use this to configure duplicate-key policy, alias-replay limits, and an
optional pre-parse YAML Budget.
Example: parse a small Config using custom Options.
use serde::Deserialize;
use serde_saphyr::options::DuplicateKeyPolicy;
use serde_saphyr::{from_str_with_options, Budget, Options};
#[derive(Deserialize)]
struct Config {
name: String,
enabled: bool,
retries: i32,
}
let yaml = r#"
name: My Application
enabled: true
retries: 5
"#;
let options = Options {
budget: Some(Budget {
max_documents: 2,
..Budget::default()
}),
duplicate_keys: DuplicateKeyPolicy::LastWins,
..Options::default()
};
let cfg: Config = from_str_with_options(yaml, options).unwrap();
assert_eq!(cfg.name, "My Application");Fields§
§budget: Option<Budget>Optional YAML budget to enforce before parsing (counts raw parser events).
duplicate_keys: DuplicateKeyPolicyPolicy for duplicate keys.
alias_limits: AliasLimitsLimits for alias replay to harden against alias bombs.
legacy_octal_numbers: boolEnable legacy octal parsing where values starting with 00 are treated as base-8.
They are deprecated in YAML 1.2. Default: false.
strict_booleans: boolIf true, interpret only the exact literals true and false as booleans.
YAML 1.1 forms like yes/no/on/off will be rejected and not inferred.
Default: false (accept YAML 1.1 boolean forms).
ignore_binary_tag_for_string: boolWhen a field marked with the !!binary tag is deserialized into a String,
serde-saphyr normally expects the value to be base64-encoded UTF-8.
If you want to treat the value as a plain string and ignore the !!binary tag,
set this to true (the default is false).
angle_conversions: boolActivates YAML conventions common in robotics community. These extensions support conversion functions (deg, rad) and simple mathematical expressions such as deg(180), rad(pi), 1 + 2*(3 - 4/5), or rad(pi/2). [robotics] feature must also be enabled.
no_schema: boolIf true, values that can be parsed as booleans or numbers are rejected as unquoted strings. This flag is intended for teams that want to enforce compatibility with YAML parsers that infer types from unquoted values, requiring such strings to be explicitly quoted. The default is false (a number or boolean will be stored in the string field exactly as provided, without quoting).