statime/config/
instance.rs

1use crate::config::{ClockIdentity, SdoId};
2#[cfg(doc)]
3use crate::PtpInstance;
4
5/// Configuration for a [`PtpInstance`]
6///
7/// # Example
8/// A configuration with common default values:
9/// ```
10/// # use statime::config::{ClockIdentity, InstanceConfig, SdoId};
11/// let config = InstanceConfig {
12///     clock_identity: ClockIdentity::from_mac_address([1,2,3,4,5,6]),
13///     priority_1: 128,
14///     priority_2: 128,
15///     domain_number: 0,
16///     sdo_id: SdoId::default(),
17///     slave_only: false,
18///     path_trace: false,
19/// };
20/// ```
21#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
22pub struct InstanceConfig {
23    /// The unique identifier for this device within the PTP network.
24    pub clock_identity: ClockIdentity,
25
26    /// Priority of this clock while selecting a master clock.
27    ///
28    /// Lower values assign a higher priority.
29    pub priority_1: u8,
30
31    /// Tie-breaker priority during master clock selection on otherwise
32    /// identical instances.
33    ///
34    /// Lower values assign a higher priority.
35    pub priority_2: u8,
36
37    /// This and [`InstanceConfig::sdo_id`] together identify which domain a
38    /// [`PtpInstance`] belongs to.
39    ///
40    /// In general nodes will only communicate within their domain. See *IEEE
41    /// 1588-2019 table 2* for permitted combinations.
42    pub domain_number: u8,
43
44    /// See [`InstanceConfig::domain_number`].
45    pub sdo_id: SdoId,
46
47    /// Whether this node may never become a master in the network
48    pub slave_only: bool,
49
50    /// Whether the path trace option is enabled
51    pub path_trace: bool,
52}