Struct autosar_data_specification::ElementType
source · pub struct ElementType(_);
Expand description
ElementType is an abstraction over element types in the specification.
It provides no public fields, but it has methods to get all the info needed to parse an arxml element.
Implementations§
source§impl ElementType
impl ElementType
sourcepub fn get_sub_element_version_mask(
&self,
element_indices: &[usize]
) -> Option<u32>
pub fn get_sub_element_version_mask( &self, element_indices: &[usize] ) -> Option<u32>
get the version mask of a sub element
sourcepub fn get_sub_element_multiplicity(
&self,
element_indices: &[usize]
) -> Option<ElementMultiplicity>
pub fn get_sub_element_multiplicity( &self, element_indices: &[usize] ) -> Option<ElementMultiplicity>
get the multiplicity of a sub element within the current ElementType
The sub element is identified by an indx list, as returned by find_sub_element()
sourcepub fn get_sub_element_container_mode(
&self,
element_indices: &[usize]
) -> ContentMode
pub fn get_sub_element_container_mode( &self, element_indices: &[usize] ) -> ContentMode
get the ContentMode of the container of a sub element of the current ElementType
The sub element is identified by an index list, as returned by find_sub_element()
sourcepub fn find_sub_element(
&self,
target_name: ElementName,
version: u32
) -> Option<(ElementType, Vec<usize>)>
pub fn find_sub_element( &self, target_name: ElementName, version: u32 ) -> Option<(ElementType, Vec<usize>)>
find a sub element in the specification of the current ElementType
Note: Version here is NOT an AutosarVersion, it is a u32. it is a bitmask which can contain multiple AutosarVersions, or any version by using u32::MAX
In almost all cases this is simple: there is a flat list of sub elements that either contains the target_name or not. The result in those simple cases is a vec with one entry which is the index of the element in the list. There are a handfull of complicated situations though, where the list of sub elements contains groups of elements that have a different ContentMode than the other elements.
For example:
PRM-CHAR (Sequence)
-> Element: COND
-> Group (Choice)
-> Group (Sequence)
-> Group (Choice)
-> Group (Sequence)
-> Element: ABS
-> Element: TOL
-> Group (Sequence)
-> Element: MIN
-> Element: TYP
-> Element: MAX
-> Element: PRM-UNIT
-> Element: TEXT
-> Element: REMARK
When searching for TOL in PRM-CHAR, the result should be Some(vec![1, 0, 0, 0, 1])!
sourcepub fn find_common_group(
&self,
element_indices: &[usize],
element_indices2: &[usize]
) -> ElementType
pub fn find_common_group( &self, element_indices: &[usize], element_indices2: &[usize] ) -> ElementType
find the commmon group of two subelements of the current ElementType
The subelements are identified by their index lists, returned by find_sub_element().
In simple cases without sub-groups of elements, the “common group” is simply the current ElementType.
sourcepub fn is_named_in_version(&self, version: AutosarVersion) -> bool
pub fn is_named_in_version(&self, version: AutosarVersion) -> bool
are elements of this elementType named in the given Autosar version
Named elements must have a SHORT-NAME sub element. For some elements this depends on the Autosar version.
One example of this is END-2-END-METHOD-PROTECTION-PROPS, which was first defined in Autosar_00048, but only has a name in Autosar_00050.
sourcepub fn content_mode(&self) -> ContentMode
pub fn content_mode(&self) -> ContentMode
get the content mode for this ElementType
sourcepub fn chardata_spec(&self) -> Option<&'static CharacterDataSpec>
pub fn chardata_spec(&self) -> Option<&'static CharacterDataSpec>
get the character data spec for this ElementType
sourcepub fn find_attribute_spec(
&self,
attrname: AttributeName
) -> Option<AttributeSpec>
pub fn find_attribute_spec( &self, attrname: AttributeName ) -> Option<AttributeSpec>
find the spec for a single attribute by name
sourcepub fn attribute_spec_iter(&self) -> AttrDefinitionsIter ⓘ
pub fn attribute_spec_iter(&self) -> AttrDefinitionsIter ⓘ
create an iterator over all attribute definitions in the current ElementType
sourcepub fn sub_element_spec_iter(&self) -> SubelemDefinitionsIter ⓘ
pub fn sub_element_spec_iter(&self) -> SubelemDefinitionsIter ⓘ
create an iterator over all sub elements of the current ElementType
sourcepub fn is_ordered(&self) -> bool
pub fn is_ordered(&self) -> bool
Is the current ElementType ordered
It his is true, then the position of the sub elements of this element is semantically meaningful and they may not be sorted / re-ordered without changing the meaning of the file.
An example of this is ARGUMENTS in BSW-MODULE-ENTRY. ARGUMENTS is ordered, because each of its SW-SERVICE-ARG sub elements represents a function argument
sourcepub fn splittable(&self) -> u32
pub fn splittable(&self) -> u32
Is the current ElementType splittable
This function returns a bitfield that indicates in which versions (if any) the ElementType is marked as splittable. A splittable element may be split across multiple arxml files
sourcepub fn splittable_in(&self, version: AutosarVersion) -> bool
pub fn splittable_in(&self, version: AutosarVersion) -> bool
Is the current ElementType splittable in the given version
A splittable element may be split across multiple arxml files
sourcepub fn reference_dest_value(&self, other: &ElementType) -> Option<EnumItem>
pub fn reference_dest_value(&self, other: &ElementType) -> Option<EnumItem>
find the correct EnumItem to use in the DEST attribute when referring from this element to the other element
Returns Some(enum_item) it the reference is possible, and None otherwise.
Example:
When referring to a <CAN-TP-CONNECTION><IDENT><SHORT-NAME>foo...
the referrring <PHYSICAL-REQUEST-REF [...]>
must set DEST=“TP-CONNECTION-IDENT”
Trait Implementations§
source§impl Clone for ElementType
impl Clone for ElementType
source§fn clone(&self) -> ElementType
fn clone(&self) -> ElementType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ElementType
impl Debug for ElementType
source§impl Hash for ElementType
impl Hash for ElementType
source§impl PartialEq<ElementType> for ElementType
impl PartialEq<ElementType> for ElementType
source§fn eq(&self, other: &ElementType) -> bool
fn eq(&self, other: &ElementType) -> bool
self
and other
values to be equal, and is used
by ==
.