pub trait Clock<Timescale>:
Clone
+ Send
+ 'static {
// Required methods
fn now(&self) -> Result<Timestamp<Timescale>, ClockError>;
fn set_frequency(
&self,
freq: f64,
) -> Result<Timestamp<Timescale>, ClockError>;
fn get_frequency(&self) -> Result<f64, ClockError>;
fn max_frequency(&self) -> Result<f64, ClockError>;
fn step_clock(
&self,
offset: Duration,
) -> Result<Timestamp<Timescale>, ClockError>;
fn error_estimate_update(
&self,
est_error: Duration,
max_error: Duration,
) -> Result<(), ClockError>;
fn leap_update(&self, leap_status: LeapStatus) -> Result<(), ClockError>;
fn synchronization_update(
&self,
synchronized: bool,
) -> Result<(), ClockError>;
}Expand description
Interface for a controllable clock This needs to be a trait as a single system can have multiple clocks which need different implementation for steering and/or now.
Required Methods§
Sourcefn now(&self) -> Result<Timestamp<Timescale>, ClockError>
fn now(&self) -> Result<Timestamp<Timescale>, ClockError>
Sourcefn set_frequency(&self, freq: f64) -> Result<Timestamp<Timescale>, ClockError>
fn set_frequency(&self, freq: f64) -> Result<Timestamp<Timescale>, ClockError>
Change the frequency of the clock, returning the time at which the change was applied. The frequency is in seconds per second deviation.
§Errors
Should return an error if the clock is unable to be steered by the requested amount.
Sourcefn get_frequency(&self) -> Result<f64, ClockError>
fn get_frequency(&self) -> Result<f64, ClockError>
Get the frequency of the clock, in seconds per second deviation
§Errors
Should return an error if the clock is unable to provide its current steering frequency.
Sourcefn max_frequency(&self) -> Result<f64, ClockError>
fn max_frequency(&self) -> Result<f64, ClockError>
Maximum frequency offset the clock is capable of, in seconds per second deviation.
§Errors
Should return an error if the maximum frequency offset could not be determined.
Sourcefn step_clock(
&self,
offset: Duration,
) -> Result<Timestamp<Timescale>, ClockError>
fn step_clock( &self, offset: Duration, ) -> Result<Timestamp<Timescale>, ClockError>
Change the current time of the clock by offset. Returns the time at which the change was applied.
§Errors
Should return an error if the clock cannot be stepped by the amount requested.
Sourcefn error_estimate_update(
&self,
est_error: Duration,
max_error: Duration,
) -> Result<(), ClockError>
fn error_estimate_update( &self, est_error: Duration, max_error: Duration, ) -> Result<(), ClockError>
Provide the system with our current best estimates for
the statistical error of the clock (est_error), and
the maximum deviation due to frequency error and
distance to the root clock.
§Errors
Should return an error if the error estimate update cannot be applied to the clock.
Sourcefn leap_update(&self, leap_status: LeapStatus) -> Result<(), ClockError>
fn leap_update(&self, leap_status: LeapStatus) -> Result<(), ClockError>
Change the indicators for upcoming leap seconds. Application should happen at the end of the UTC month.
§Errors
Should return an error if the status update cannot be applied to the clock.
Sourcefn synchronization_update(&self, synchronized: bool) -> Result<(), ClockError>
fn synchronization_update(&self, synchronized: bool) -> Result<(), ClockError>
Change the synchronization indicator.
§Errors
should return an error if the synchronization indicator cannot be updated
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".