pub fn from_str_with_options<'de, T>(
input: &'de str,
options: Options,
) -> Result<T, Error>where
T: Deserialize<'de>,Expand description
Deserialize a single YAML document with configurable Options.
This function supports both owned types (like String) and borrowed types
(like &str). For borrowed types, the deserialized value’s lifetime is tied
to the input string’s lifetime.
Example: read a small Config with a custom budget and default duplicate-key policy.
use serde::Deserialize;
use serde_saphyr::DuplicateKeyPolicy;
#[derive(Debug, Deserialize, PartialEq)]
struct Config {
name: String,
enabled: bool,
retries: i32,
}
let yaml = r#"
name: My Application
enabled: true
retries: 5
"#;
let options = serde_saphyr::options! {
budget: serde_saphyr::budget! {
max_anchors: 200,
},
duplicate_keys: DuplicateKeyPolicy::FirstWins,
};
let cfg: Config = serde_saphyr::from_str_with_options(yaml, options).unwrap();
assert_eq!(cfg.retries, 5);