autosar_data_abstraction/communication/physical_channel/
lin.rs1use crate::{
2 AbstractionElement, AutosarAbstractionError, IdentifiableAbstractionElement, abstraction_element,
3 communication::{
4 AbstractPhysicalChannel, LinCluster, LinCommunicationConnector, LinFrameTriggering, PhysicalChannel,
5 },
6};
7use autosar_data::{Element, ElementName};
8
9#[derive(Debug, Clone, PartialEq, Eq, Hash)]
13pub struct LinPhysicalChannel(Element);
14abstraction_element!(LinPhysicalChannel, LinPhysicalChannel);
15impl IdentifiableAbstractionElement for LinPhysicalChannel {}
16
17impl LinPhysicalChannel {
18 pub fn cluster(&self) -> Result<LinCluster, AutosarAbstractionError> {
37 let cluster_elem = self.0.named_parent()?.unwrap();
38 LinCluster::try_from(cluster_elem)
39 }
40
41 pub fn frame_triggerings(&self) -> impl Iterator<Item = LinFrameTriggering> + Send + use<> {
43 self.0
44 .get_sub_element(ElementName::FrameTriggerings)
45 .into_iter()
46 .flat_map(|elem| elem.sub_elements())
47 .filter_map(|elem| LinFrameTriggering::try_from(elem).ok())
48 }
49}
50
51impl From<LinPhysicalChannel> for PhysicalChannel {
52 fn from(channel: LinPhysicalChannel) -> Self {
53 PhysicalChannel::Lin(channel)
54 }
55}
56
57impl AbstractPhysicalChannel for LinPhysicalChannel {
58 type CommunicationConnectorType = LinCommunicationConnector;
59}