pub fn from_multiple_with_options<'de, T>(
input: &'de str,
options: Options,
) -> Result<Vec<T>, Error>where
T: Deserialize<'de>,Expand description
Deserialize multiple YAML documents into a vector with configurable Options.
Like from_multiple, this supports owned and borrowed values and skips empty,
untagged null-like, and explicit !!null documents. With DockerComposeWithNulls,
interpolated nulls are also skipped. Application-tagged roots are deserialized.
Use from_str_multiple_with_options to collect into other collection types.
Since 2.0, function pointers or callbacks accepting any input lifetime may need a
forwarding closure such as |input, options| from_multiple_with_options::<String>(input, options).
Example: two Config documents with a custom budget.
use serde::Deserialize;
use serde_saphyr::DuplicateKeyPolicy;
#[derive(Debug, Deserialize, PartialEq)]
struct Config {
name: String,
enabled: bool,
retries: i32,
}
let yaml = r#"
name: First
enabled: true
retries: 1
---
name: Second
enabled: false
retries: 2
"#;
let options = serde_saphyr::options! {
budget: serde_saphyr::budget! {
max_anchors: 200,
},
duplicate_keys: DuplicateKeyPolicy::FirstWins,
};
let cfgs: Vec<Config> = serde_saphyr::from_multiple_with_options(yaml, options).unwrap();
assert_eq!(cfgs.len(), 2);
assert!(!cfgs[1].enabled);