pub struct AutosarProject(_);
Expand description

AutosarProject is the top level data type in the autosar-data crate.

All manipulations of arxml files are performed through an instance of AutosarProject

Implementations

Create an instance of AutosarData

Initially it contains no arxml files

Example
let project = AutosarProject::new();

Create a new ArxmlFile inside this AutosarData structure

You must provide a filename for the ArxmlFile, even if you do not plan to write the data to disk. You must also specify an AutosarVersion. All methods manipulation the data insdie the file will ensure conformity with the version specified here. The newly created ArxmlFile will be created with a root AUTOSAR element.

Parameters
  • filename: A filename for the data from the buffer. It must be unique within the project. It will be used by write(), and is also used to identify this data in error messages.
  • version: The AutosarVersion that will be used by the data created inside this file
Example
let project = AutosarProject::new();
let file = project.create_file("filename.arxml", AutosarVersion::Autosar_00050)?;
Possible Errors

Load a named buffer containing arxml data

If you have e.g. received arxml data over a network, or decompressed it from an archive, etc, then you may load it with this method.

Parameters:
  • buffer: The data inside the buffer must be valid utf-8. Optionally it may begin with a UTF-8-BOM, which will be silently ignored.
  • filename: the original filename of the data, or a newly generated name that is unique within the AutosarData instance.
  • strict: toggle strict parsing. Some parsing errors are recoverable and can be issued as warnings.

This method may be called concurrently on multiple threads to load different buffers

Example
let project = AutosarProject::new();
project.load_named_arxml_buffer(buffer, "filename.arxml", true)?;
Possible Errors

Load an arxml file

This function is a wrapper around load_named_arxml_buffer to make the common case of loading a file from disk more convenient

Parameters:
  • filename: the original filename of the data, or a newly generated name that is unique within the AutosarData instance.
  • strict: toggle strict parsing. Some parsing errors are recoverable and can be issued as warnings.
Example
let project = AutosarProject::new();
project.load_arxml_file("filename.arxml", true)?;
Possible Errors

remove a file from the project

Parameters:
  • file: The file that will be removed from the project
Example
let project = AutosarProject::new();
let file = project.create_file("filename.arxml", AutosarVersion::Autosar_00050)?;
project.remove_file(&file);

serialize each of the files in the project

returns the result in a HashMap of <file_name, file_content>

Example
let project = AutosarProject::new();
for (pathbuf, file_content) in project.serialize_files() {
    // do something with it
}

write all files in the project

This is a wrapper around serialize_files. The current filename of each file will be used to write the serialized data.

If any of the individual files cannot be written, then write() will abort and return the error. This may result in a situation where some files have been written and others have not.

Example
let project = AutosarProject::new();
// load or create files
project.write()?;
Possible errors

create an iterator over all ArxmlFiles in this AutosarData object

Example
let project = AutosarProject::new();
// load or create files
for file in project.files() {
    // do something with the file
}

get a named element by its Autosar path

This is a lookup in a hash table and runs in O(1) time

Parameters
  • path: The Autosar path to look up
Example
let project = AutosarProject::new();
// [...]
if let Some(element) = project.get_element_by_path("/Path/To/Element") {
    // use the element
}

create a depth-first iterator over all Elements in all ArxmlFiles

The AUTOSAR elements in each file will appear at depth = 0. Directly printing the return values could show something like this:

0: AUTOSAR
1: AR-PACKAGES
2: AR-PACKAGE
...
2: AR-PACKAGE
Example
for (depth, element) in project.elements_dfs() {
    // [...]
}

create an iterator over all identifiable elements

It returns the full Autosar path of each element together with a reference to the element. The returned values are sorted alphabetically by the path value.

The iterator created by identifiable_elements() returns values from an internal list that is built when identifiable_elements() is called. This means that the iteration can never show any changes that were made to the data after the iterator was created.

Example
for (path, element) in project.identifiable_elements() {
    // [...]
}

return all elements referring to the given target path

It returns WeakElements which must be upgraded to get usable Elements.

This is effectively the reverse operation of get_element_by_path()

Parameters
  • target_path: The path whose references should be returned
Example
for weak_element in project.get_references_to("/Path/To/Element") {
    // [...]
}

check all Autosar path references and return a list of elements with invalid references

For each reference: The target must exist and the DEST attribute must correctly specify the type of the target

If no references are invalid, then the return value is an empty list

Example
for broken_ref_weak in project.check_references() {
    if let Some(broken_ref) = broken_ref_weak.upgrade() {
        // update or delete ref?
    }
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.