Function a2lfile::load_from_string

source ·
pub fn load_from_string(
    a2ldata: &str,
    a2ml_spec: Option<String>,
    log_msgs: &mut Vec<A2lError>,
    strict_parsing: bool
) -> Result<A2lFile, A2lError>
Expand description

load a2l data stored in a string

a2ldata contains the text of an a2l file.

a2ml_spec is optional and contains a String that is valid A2ML that can be used while parsing the file in addition to the A2ML that might be contained inside the A2ML block in the file. If a definition is provided here and there is also an A2ML block in the file, then the definition provided here will be tried first during parsing.

log_msgs is a reference to a Vec<A2LError> which will receive all warnings generated during parsing

strict_parsing toggles strict parsing: If strict parsing is enabled, most warnings become errors.

§Example

let text = r#"
ASAP2_VERSION 1 71
/begin PROJECT new_project ""
  /begin MODULE new_module ""
  /end MODULE
/end PROJECT
"#;

let mut log_msgs = Vec::<A2lError>::new();
let a2l = a2lfile::load_from_string(&text, None, &mut log_msgs, true).unwrap();
assert_eq!(a2l.project.module[0].name, "new_module");

§Errors

An A2lError provides details information if loading the data fails.