pub struct AutosarModelAbstraction(/* private fields */);
Expand description
The AutosarModelAbstraction
wraps an AutosarModel
and provides additional functionality
Implementations§
Source§impl AutosarModelAbstraction
impl AutosarModelAbstraction
Sourcepub fn new(model: AutosarModel) -> Self
pub fn new(model: AutosarModel) -> Self
Create a new AutosarModelAbstraction
from an AutosarModel
Sourcepub fn create<P: AsRef<Path>>(file_name: P, version: AutosarVersion) -> Self
pub fn create<P: AsRef<Path>>(file_name: P, version: AutosarVersion) -> Self
create a new AutosarModelAbstraction
with an empty AutosarModel
You must specify a file name for the initial file in the model. This file is not created on disk immediately.
The model also needs an AutosarVersion
.
Sourcepub fn from_file<P: AsRef<Path>>(
file_name: P,
) -> Result<Self, AutosarAbstractionError>
pub fn from_file<P: AsRef<Path>>( file_name: P, ) -> Result<Self, AutosarAbstractionError>
create an AutosarModelAbstraction
from a file on disk
Sourcepub fn model(&self) -> &AutosarModel
pub fn model(&self) -> &AutosarModel
Get the underlying AutosarModel
from the abstraction model
Sourcepub fn root_element(&self) -> Element
pub fn root_element(&self) -> Element
Get the root element of the model
Sourcepub fn packages(&self) -> impl Iterator<Item = ArPackage> + Send + 'static
pub fn packages(&self) -> impl Iterator<Item = ArPackage> + Send + 'static
iterate over all top-level packages
Sourcepub fn get_or_create_package(
&self,
path: &str,
) -> Result<ArPackage, AutosarAbstractionError>
pub fn get_or_create_package( &self, path: &str, ) -> Result<ArPackage, AutosarAbstractionError>
Get a package by its path or create it if it does not exist
Sourcepub fn create_file(
&self,
file_name: &str,
version: AutosarVersion,
) -> Result<ArxmlFile, AutosarAbstractionError>
pub fn create_file( &self, file_name: &str, version: AutosarVersion, ) -> Result<ArxmlFile, AutosarAbstractionError>
Create a new file in the model
Sourcepub fn load_file<P: AsRef<Path>>(
&self,
file_name: P,
strict: bool,
) -> Result<(ArxmlFile, Vec<AutosarDataError>), AutosarAbstractionError>
pub fn load_file<P: AsRef<Path>>( &self, file_name: P, strict: bool, ) -> Result<(ArxmlFile, Vec<AutosarDataError>), AutosarAbstractionError>
Load a file into the model
Sourcepub fn files(&self) -> impl Iterator<Item = ArxmlFile> + Send + 'static
pub fn files(&self) -> impl Iterator<Item = ArxmlFile> + Send + 'static
iterate over all files in the model
Sourcepub fn write(&self) -> Result<(), AutosarAbstractionError>
pub fn write(&self) -> Result<(), AutosarAbstractionError>
write the model to disk, creating or updating all files in the model
Sourcepub fn get_element_by_path(&self, path: &str) -> Option<Element>
pub fn get_element_by_path(&self, path: &str) -> Option<Element>
Get an element by its path
Sourcepub fn find_system(&self) -> Option<System>
pub fn find_system(&self) -> Option<System>
find an existing SYSTEM in the model, if it exists
§Example
let model = AutosarModelAbstraction::create("filename", AutosarVersion::Autosar_00048);
let system = package.create_system("System", SystemCategory::SystemExtract)?;
if let Some(sys_2) = model.find_system() {
assert_eq!(system, sys_2);
}
Trait Implementations§
Source§impl Clone for AutosarModelAbstraction
impl Clone for AutosarModelAbstraction
Source§fn clone(&self) -> AutosarModelAbstraction
fn clone(&self) -> AutosarModelAbstraction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AutosarModelAbstraction
impl Debug for AutosarModelAbstraction
Source§impl PartialEq for AutosarModelAbstraction
impl PartialEq for AutosarModelAbstraction
impl Eq for AutosarModelAbstraction
impl StructuralPartialEq for AutosarModelAbstraction
Auto Trait Implementations§
impl Freeze for AutosarModelAbstraction
impl !RefUnwindSafe for AutosarModelAbstraction
impl Send for AutosarModelAbstraction
impl Sync for AutosarModelAbstraction
impl Unpin for AutosarModelAbstraction
impl !UnwindSafe for AutosarModelAbstraction
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.