MCPcopy Create free account
hub / github.com/aws/clock-bound / ClockExt

Interface ClockExt

clock-bound/src/daemon/time/inner.rs:64–77  ·  view source on GitHub ↗

Extension trait for Clock that provides offset and RTT measurement functionality

Source from the content-addressed store, hash-verified

62}
63
64/// Extension trait for Clock that provides offset and RTT measurement functionality
65pub trait ClockExt<T: NanoType + Copy>: Clock<T> {
66 /// Get the offset and RTT measurement for this reading between this clock and another clock.
67 /// The "offset" is from the caller to the `other` clock - e.g. if `self` is running behind `other`,
68 /// we would expect a negative value, and if it `self` running ahead of `other`, we expect a positive value.
69 fn get_offset_and_rtt(&self, other: &impl Clock<T>) -> ClockOffsetAndRtt<T> {
70 let our_read1 = self.get_time();
71 let their_read = other.get_time();
72 let our_read2 = self.get_time();
73 let mid = our_read1.midpoint(our_read2);
74 let offset = mid - their_read;
75 let rtt = our_read2 - our_read1;
76 ClockOffsetAndRtt::new(offset, rtt)
77 }
78}
79
80/// Blanket implementation of `ClockExt` for all types that implement Clock

Callers 5

emit_clock_offsetsMethod · 0.80
to_clock_adjustedMethod · 0.80
clock_get_offset_and_rttFunction · 0.80

Implementers 1

inner.rsclock-bound/src/daemon/time/inner.rs

Calls

no outgoing calls

Tested by

no test coverage detected