pub struct ArxmlFile(/* private fields */);
Expand description
An Autosar arxml file
Implementations§
Source§impl ArxmlFile
impl ArxmlFile
Sourcepub fn filename(&self) -> PathBuf
pub fn filename(&self) -> PathBuf
Get the filename of this ArxmlFile
§Example
println!("filename is : {}", file.filename().display());
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);
§Errors
AutosarDataError::VersionIncompatibleData
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 set_filename<P: AsRef<Path>>(
&self,
new_filename: P,
) -> Result<(), AutosarDataError>
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"));
Sourcepub fn model(&self) -> Result<AutosarModel, AutosarDataError>
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
Sourcepub fn elements_dfs(&self) -> ArxmlFileElementsDfsIterator
pub fn elements_dfs(&self) -> ArxmlFileElementsDfsIterator
Sourcepub fn elements_dfs_with_max_depth(
&self,
max_depth: usize,
) -> ArxmlFileElementsDfsIterator
pub fn elements_dfs_with_max_depth( &self, max_depth: usize, ) -> ArxmlFileElementsDfsIterator
Sourcepub fn serialize(&self) -> Result<String, AutosarDataError>
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
Sourcepub fn xml_standalone(&self) -> Option<bool>
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));
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§
impl Eq for ArxmlFile
Auto Trait Implementations§
impl Freeze for ArxmlFile
impl !RefUnwindSafe for ArxmlFile
impl Send for ArxmlFile
impl Sync for ArxmlFile
impl Unpin for ArxmlFile
impl !UnwindSafe for ArxmlFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.