pub struct TimeSyncTracker { /* private fields */ }Expand description
Tracks remote time sources and performs leader/source selection decisions.
Implementations§
Source§impl TimeSyncTracker
impl TimeSyncTracker
Sourcepub fn new(cfg: TimeSyncConfig) -> Self
pub fn new(cfg: TimeSyncConfig) -> Self
Creates a tracker with the supplied time sync configuration.
Sourcepub fn config(&self) -> TimeSyncConfig
pub fn config(&self) -> TimeSyncConfig
Returns the tracker’s active configuration.
Sourcepub fn current_source(&self) -> Option<&TimeSyncSource>
pub fn current_source(&self) -> Option<&TimeSyncSource>
Returns the currently selected remote source, if any.
Sourcepub fn refresh(&mut self, now_ms: u64) -> TimeSyncUpdate
pub fn refresh(&mut self, now_ms: u64) -> TimeSyncUpdate
Removes stale sources and re-runs source selection.
Sourcepub fn best_active_source(&self, now_ms: u64) -> Option<&TimeSyncSource>
pub fn best_active_source(&self, now_ms: u64) -> Option<&TimeSyncSource>
Returns the best currently active remote source according to priority and sender ID.
Sourcepub fn local_candidate_priority(
&self,
now_ms: u64,
has_usable_time: bool,
) -> Option<u64>
pub fn local_candidate_priority( &self, now_ms: u64, has_usable_time: bool, ) -> Option<u64>
Returns the effective local candidate priority if the node may lead at now_ms.
Sourcepub fn leader(
&self,
now_ms: u64,
has_usable_time: bool,
) -> Option<TimeSyncLeader>
pub fn leader( &self, now_ms: u64, has_usable_time: bool, ) -> Option<TimeSyncLeader>
Returns the elected leader between the local node and active remote sources.
Sourcepub fn local_announce_priority(
&self,
now_ms: u64,
has_usable_time: bool,
) -> Option<u64>
pub fn local_announce_priority( &self, now_ms: u64, has_usable_time: bool, ) -> Option<u64>
Returns the priority to advertise in local announce packets when leading.
Sourcepub fn should_announce(&self, now_ms: u64, has_usable_time: bool) -> bool
pub fn should_announce(&self, now_ms: u64, has_usable_time: bool) -> bool
Returns true when the local node should currently emit announce packets.
Sourcepub fn should_serve(&self, now_ms: u64, has_usable_time: bool) -> bool
pub fn should_serve(&self, now_ms: u64, has_usable_time: bool) -> bool
Returns true when the local node should currently answer incoming requests.
Sourcepub fn handle_announce(
&mut self,
pkt: &Packet,
recv_ms: u64,
) -> TelemetryResult<TimeSyncUpdate>
pub fn handle_announce( &mut self, pkt: &Packet, recv_ms: u64, ) -> TelemetryResult<TimeSyncUpdate>
Updates tracker state from an incoming announce packet.
Sourcepub fn is_source_active(&self, now_ms: u64) -> bool
pub fn is_source_active(&self, now_ms: u64) -> bool
Returns true when the current remote source is still within the active timeout window.
Trait Implementations§
Source§impl Clone for TimeSyncTracker
impl Clone for TimeSyncTracker
Source§fn clone(&self) -> TimeSyncTracker
fn clone(&self) -> TimeSyncTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more