statime/observability/
parent.rs

1use crate::{
2    config::{ClockIdentity, ClockQuality},
3    datastructures::{common::PortIdentity, datasets::InternalParentDS},
4};
5
6/// A concrete implementation of the PTP Parent dataset (IEEE1588-2019 section
7/// 8.2.3)
8///
9/// These fields aren't implemented, because they are currently unused:
10/// - parentStats
11/// - observedParentOffsetScaledLogVariance
12/// - observedParentClockPhaseChangeRate
13
14#[derive(Copy, Clone, Debug, Eq, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16pub struct ParentDS {
17    /// See *IEEE1588-2019 section 8.2.3.2*.
18    pub parent_port_identity: PortIdentity,
19    /// See *IEEE1588-2019 section 8.2.3.6*.
20    pub grandmaster_identity: ClockIdentity,
21    /// See *IEEE1588-2019 section 8.2.3.7*.
22    pub grandmaster_clock_quality: ClockQuality,
23    /// See *IEEE1588-2019 section 8.2.3.8*.
24    pub grandmaster_priority_1: u8,
25    /// See *IEEE1588-2019 section 8.2.3.9*.
26    pub grandmaster_priority_2: u8,
27}
28
29impl From<&InternalParentDS> for ParentDS {
30    fn from(v: &InternalParentDS) -> Self {
31        Self {
32            parent_port_identity: v.parent_port_identity,
33            grandmaster_identity: v.grandmaster_identity,
34            grandmaster_clock_quality: v.grandmaster_clock_quality,
35            grandmaster_priority_1: v.grandmaster_priority_1,
36            grandmaster_priority_2: v.grandmaster_priority_2,
37        }
38    }
39}