Skip to main content

read_settings

Function read_settings 

Source
pub fn read_settings(document: &str) -> Result<Vec<(String, Value)>>
Expand description

The settings a settings file holds, in the order it holds them, as music21’s _fromSettings reads them: each <preference> by its name, with its value or none, and the local corpora.

use music21::environment::{read_settings, LocalCorpus, Value};

let read = read_settings(
    "<settings><preference name=\"midiPath\" value=\"w\"/>\
     <localCorpusSettings><localCorpusPath> x </localCorpusPath></localCorpusSettings>\
     </settings>",
)
.unwrap();
assert_eq!(read[0], ("midiPath".to_owned(), Value::text("w")));
assert_eq!(
    read[1].1,
    Value::LocalCorpus(LocalCorpus { paths: vec!["x".to_owned()], ..Default::default() })
);