ArxmlFile

Struct ArxmlFile 

Source
pub struct ArxmlFile(/* private fields */);
Expand description

An Autosar arxml file

Implementations§

Source§

impl ArxmlFile

Source

pub fn filename(&self) -> PathBuf

Get the filename of this ArxmlFile

§Example
println!("filename is : {}", file.filename().display());
Source

pub fn version(&self) -> AutosarVersion

Get the AutosarVersion of the file

§Example
let version = file.version();
Source

pub fn set_version( &self, new_ver: AutosarVersion, ) -> Result<(), AutosarDataError>

Set the AutosarVersion of the file

The compatibility of the data in the file with the new version will be checked before setting the version. The compatibility check can also be performed manually using the function check_version_compatibility().

If the data is compatible, then the version is set, otherwise an error is raised.

§Example
file.set_version(AutosarVersion::Autosar_00050);
§Errors
Source

pub fn check_version_compatibility( &self, target_version: AutosarVersion, ) -> (Vec<CompatibilityError>, u32)

Check if the elements and attributes in this file are compatible with some target_version

All elements and their attributes will be evaluated against the target version according to the specification. The output is a list of incompatible elements

§Example
let (error_list, compat_mask) = file.check_version_compatibility(AutosarVersion::Autosar_00050);
Source

pub fn set_filename<P: AsRef<Path>>( &self, new_filename: P, ) -> Result<(), AutosarDataError>

Set the filename of this arxml filename

This will not rename any existing file on disk, but the new filename will be used when writing the data.

§Example
file.set_filename("foo.arxml");
// or
file.set_filename(&Path::new("bar.arxml"));
Source

pub fn model(&self) -> Result<AutosarModel, AutosarDataError>

Get a reference to the AutosarModel object that contains this file

§Example
let model = AutosarModel::new();
let file = model.create_file("test", AutosarVersion::Autosar_00050).unwrap();
let m2 = file.model()?;
assert_eq!(model, m2);
§Errors

AutosarDataError::ItemDeleted: The model is no longer valid

Source

pub fn elements_dfs(&self) -> ArxmlFileElementsDfsIterator

Create a depth-first search iterator over all Elements in this file

In a multi-file model it will not return any elements from other files.

§Example
for (depth, elem) in file.elements_dfs() {
    // ...
}
Source

pub fn elements_dfs_with_max_depth( &self, max_depth: usize, ) -> ArxmlFileElementsDfsIterator

Create a depth first iterator over all Elements in this file, up to a maximum depth

In a multi-file model it will not return any elements from other files.

§Example
for (depth, elem) in file.elements_dfs_with_max_depth(1) {
    assert!(depth <= 1);
    // ...
}
Source

pub fn serialize(&self) -> Result<String, AutosarDataError>

Serialize the content of the file to a String

§Example
let text = file.serialize();
§Errors

AutosarDataError::ItemDeleted: The model is no longer valid AutosarDataError::EmptyFile: The file is empty and cannot be serialized

Source

pub fn xml_standalone(&self) -> Option<bool>

Return the standalone attribute from the xml header

Some tools set headers that include the standalone attribute. This attribute appears to be meaningless for arxml files.

It is preserved nontheless and can be retrieved with this function.

§Example
let model = AutosarModel::new();
let file_text = r#"<?xml version="1.0" encoding="utf-8" standalone="no"?>
<AUTOSAR xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_00050.xsd" xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</AUTOSAR>"#.as_bytes();
let (file, _warnings) = model.load_buffer(file_text, "filename.arxml", true).unwrap();
assert_eq!(file.xml_standalone(), Some(false));
Source

pub fn downgrade(&self) -> WeakArxmlFile

Create a weak reference to this ArxmlFile

A weak reference can be stored without preventing the file from being deallocated. The weak reference has to be upgraded in order to be used, which can fail if the file no longer exists.

See the documentation for Arc

§Example
let weak_file = file.downgrade();

Trait Implementations§

Source§

impl Clone for ArxmlFile

Source§

fn clone(&self) -> ArxmlFile

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ArxmlFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ArxmlFile

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ArxmlFile

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ArxmlFile

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.