pub fn from_multiple<'de, T>(input: &'de str) -> Result<Vec<T>, Error>where
T: Deserialize<'de>,Expand description
Deserialize multiple YAML documents from a single string into a vector of T.
Completely empty documents, untagged plain null-like documents, and explicit !!null
documents are skipped. Application-tagged roots are deserialized, even with null payloads.
Supports both owned values and values borrowing from the input string. Borrowed values
cannot outlive the input, and strings requiring transformation cannot be borrowed as &str;
see from_str_multiple for details and for collecting into other collection types.
Since 2.0, function pointers or callbacks accepting any input lifetime may need a
forwarding closure such as |input| from_multiple::<String>(input).
Example: read two Config documents separated by ---.
use serde::Deserialize;
#[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 cfgs: Vec<Config> = serde_saphyr::from_multiple(yaml).unwrap();
assert_eq!(cfgs.len(), 2);
assert_eq!(cfgs[0].name, "First");