Crates.io Github Actions codecov

autosar-data

This crate provides functionality to read, modify and write Autosar 4 arxml files, both separately and in projects consisting of multiple files.

Features

Example

```rust use autosar_data::*;

/* load a multi-file project */ let project = AutosarProject::new(); let (file1, warnings1) = project.loadarxmlfile("somefile.arxml", false)?; let (file2, warnings2) = project.loadarxmlfile("otherfile.arxml", false)?;

/* load a buffer */ let (file3, _) = project.loadnamedarxmlbuffer(buffer, "filename.arxml", true)?;

/* write all files of the project */ project.write()?;

/* alternatively: */ for file in project.files() { let filedata = file.serialize(); // do something with filedata }

/* iterate over all elements in all files / for (depth, element) in project.elements_dfs() { if element.is_identifiable() { / the element is identifiable using an Autosar path */ println!("{depth}: {}, {}", element.elementname(), element.path()?); } else { println!("{depth}: {}", element.elementname()); } }

/* get an element by its Autosar path */ let pduelement = project.getelementbypath("/Package/Mid/PduName").unwrap();

/* work with the content of elements */ if let Some(length) = pduelement .getsubelement(ElementName::Length) .andthen(|elem| elem.characterdata()) .andthen(|cdata| cdata.string_value()) { println!("Pdu Length: {length}"); }

/* modify the attributes of an element */ pduelement.setattributestring(AttributeName::Uuid, "12ab34cd-1234-1234-1234-12ab34cd56ef"); pduelement.remove_attribute(AttributeName::Uuid); ```

Example Programs

Two complete example programs can be found in the examples directory of the source repostitory. They are: