[][src]Function mparsed::parse_response_vec

pub fn parse_response_vec<'a, I: Iterator<Item = &'a str>, T: DeserializeOwned>(
    input: I,
    first_keys: &[&str]
) -> Result<Vec<T>, Error>

Parse an iterator of string slices into a vector of T, splitting at any occurence of first_key. One possible use for this is the playlistinfo command which returns all items in the current playlist, where the file: key denotes the start of a new item.

Multiple values for first_key

In some cases, like the listfiles command, there are multiple possible values for first_key, so a vector can be specified.

let response = "file: A track.flac
size: 123456
Last-Modified: 2019-12-17T08:51:37Z
directory: A directory
Last-Modified: 2015-01-30T14:53:03Z
OK";
let files: Vec<File> = parse_response_vec(response.lines(), &vec!["file: ", "directory: "]).unwrap();

assert_eq!(files.len(), 2);
assert_eq!(files[0].name, String::from("A track.flac"));
assert!(files[1].is_directory());