Struct autosar_data::ArxmlFile
source · [−]pub struct ArxmlFile(_);Expand description
An Autosar arxml file
Implementations
sourceimpl ArxmlFile
impl ArxmlFile
sourcepub fn set_filename<P: AsRef<Path>>(&self, new_filename: P)
pub fn set_filename<P: AsRef<Path>>(&self, new_filename: P)
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"));sourcepub fn version(&self) -> AutosarVersion
pub fn version(&self) -> AutosarVersion
sourcepub fn set_version(
&self,
new_ver: AutosarVersion
) -> Result<(), AutosarDataError>
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);Possible Errors
- AutosarDataError::VersionIncompatible the existing data is not compatible with the new version
sourcepub fn check_version_compatibility(
&self,
target_version: AutosarVersion
) -> (Vec<CompatibilityError>, u32)
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);sourcepub fn project(&self) -> Result<AutosarProject, AutosarDataError>
pub fn project(&self) -> Result<AutosarProject, AutosarDataError>
Get a reference to the AutosarProject object that contains this file
Example
let project = AutosarProject::new();
let file = project.create_file("test", AutosarVersion::Autosar_00050).unwrap();
let p2 = file.project()?;
assert_eq!(project, p2);Possible Errors
AutosarDataError::ItemDeleted: The project is no longer valid
sourcepub fn root_element(&self) -> Element
pub fn root_element(&self) -> Element
Get a referenct to the root <AUTOSAR ...> element of this file
Example
let autosar_element = file.root_element();sourcepub fn elements_dfs(&self) -> ElementsDfsIterator
pub fn elements_dfs(&self) -> ElementsDfsIterator
sourcepub fn downgrade(&self) -> WeakArxmlFile
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
Auto Trait Implementations
impl !RefUnwindSafe for ArxmlFile
impl Send for ArxmlFile
impl Sync for ArxmlFile
impl Unpin for ArxmlFile
impl !UnwindSafe for ArxmlFile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more