statime/config/instance.rs
1use crate::config::{ClockIdentity, ClockQuality, 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, ClockQuality};
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/// clock_quality: ClockQuality::default(),
20/// };
21/// ```
22#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
23pub struct InstanceConfig {
24 /// The unique identifier for this device within the PTP network.
25 pub clock_identity: ClockIdentity,
26
27 /// Priority of this clock while selecting a master clock.
28 ///
29 /// Lower values assign a higher priority.
30 pub priority_1: u8,
31
32 /// Tie-breaker priority during master clock selection on otherwise
33 /// identical instances.
34 ///
35 /// Lower values assign a higher priority.
36 pub priority_2: u8,
37
38 /// This and [`InstanceConfig::sdo_id`] together identify which domain a
39 /// [`PtpInstance`] belongs to.
40 ///
41 /// In general nodes will only communicate within their domain. See *IEEE
42 /// 1588-2019 table 2* for permitted combinations.
43 pub domain_number: u8,
44
45 /// See [`InstanceConfig::domain_number`].
46 pub sdo_id: SdoId,
47
48 /// Whether this node may never become a master in the network
49 pub slave_only: bool,
50
51 /// Whether the path trace option is enabled
52 pub path_trace: bool,
53
54 /// A description of the accuracy and type of the local clock.
55 pub clock_quality: ClockQuality,
56}