Crates.io | autosar-data |
lib.rs | autosar-data |
version | |
source | src |
created_at | 2022-08-24 20:07:09.557535 |
updated_at | 2024-11-30 13:18:59.52201 |
description | read, write and modify Autosar arxml data |
homepage | |
repository | https://github.com/DanielT/autosar-data |
max_upload_size | |
id | 651786 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
autosar-data
This crate provides functionality to read, modify and write Autosar 4 arxml files, both separately and in projects consisting of multiple files.
use autosar_data::*;
/* load a multi-file data model */
let model = AutosarModel::new();
let (file_1, warnings_1) = model.load_file("some_file.arxml", false)?;
let (file_2, warnings_2) = model.load_file("other_file.arxml", false)?;
/* load a buffer */
let (file_3, _) = model.load_buffer(buffer, "filename.arxml", true)?;
/* write all files of the model */
model.write()?;
/* alternatively: */
for file in model.files() {
let file_data = file.serialize();
// do something with file_data
}
/* iterate over all elements in all files */
for (depth, element) in model.elements_dfs() {
if element.is_identifiable() {
/* the element is identifiable using an Autosar path */
println!("{depth}: {}, {}", element.element_name(), element.path()?);
} else {
println!("{depth}: {}", element.element_name());
}
}
/* get an element by its Autosar path */
let pdu_element = model.get_element_by_path("/Package/Mid/PduName").unwrap();
/* work with the content of elements */
if let Some(length) = pdu_element
.get_sub_element(ElementName::Length)
.and_then(|elem| elem.character_data())
.and_then(|cdata| cdata.string_value())
{
println!("Pdu Length: {length}");
}
/* modify the attributes of an element */
pdu_element.set_attribute_string(AttributeName::Uuid, "12ab34cd-1234-1234-1234-12ab34cd56ef");
pdu_element.remove_attribute(AttributeName::Uuid);
Two complete example programs can be found in the examples directory of the source repostitory. They are: