Trait byztime::Context[][src]

pub trait Context: Sized {
    fn as_mut_ptr(&self) -> *mut byztime_ctx;
fn close(self) -> Result<()>; fn offset(&self) -> Result<(Timestamp, Timestamp, Timestamp)> { ... }
fn global_time(&self) -> Result<(Timestamp, Timestamp, Timestamp)> { ... }
fn get_drift(&self) -> i64 { ... }
fn set_drift(&self, drift_ppb: i64) { ... }
fn slew(
        &self,
        min_rate_ppb: i64,
        max_rate_ppb: i64,
        max_error: Option<Timestamp>
    ) -> Result<()> { ... }
fn step(&self) -> Result<()> { ... } }

Interface to common functionality of ConsumerContext and ProviderContext

Required methods

fn as_mut_ptr(&self) -> *mut byztime_ctx[src]

Return a raw pointer to the underlying byztime_sys::byztime_ctx.

fn close(self) -> Result<()>[src]

Close the timedata file. Calling this function rather than simply dropping the Context object allows graceful handling of disk failures or other I/O errors that emerge while closing the file. (The Drop instance handles such errors by panicking).

Loading content...

Provided methods

fn offset(&self) -> Result<(Timestamp, Timestamp, Timestamp)>[src]

Look up the current estimated offset (global clock - local clock) and error bounds and return it as (min, est, max).

fn global_time(&self) -> Result<(Timestamp, Timestamp, Timestamp)>[src]

Look up the current global time and error bounds and return them as (min, est, max).

It is important to be aware that min and max are bounds on the actual global time, not on other nodes’ estimation thereof. It is guranteed that other correct nodes’ ranges will overlap ours, that is, their min will be less than our max, and their max will be greater than our min. However, it is not guaranteed that other correct nodes’ est will be between our min and our max.

fn get_drift(&self) -> i64[src]

Return the drift rate, in parts per billion, that offset and global_time use in their error bound calculations.

fn set_drift(&self, drift_ppb: i64)[src]

Set the drift rate, in parts per billion, for offset and global_time to use in their error bound calculations.

fn slew(
    &self,
    min_rate_ppb: i64,
    max_rate_ppb: i64,
    max_error: Option<Timestamp>
) -> Result<()>
[src]

Begin slewing time estimates.

This function changes how est is calcuated in future calls to offset and global_time. When a context is first opened, time estimation is in “step” mode where the estimate is always the midpoint of the min and max. Such an estimate changes discontinuously every time a new data point is obtained, and can move backward.

Calling this function causes future estimates to be clamped such that they will be more consistent with each other. Specifically, if global_time returns an estimate of g₁ at local time l₁ and an estimate of g₂ at local time l₂, then g₂ will be clamped such that min_rate_ppb ≤ 10⁹ ⋅ (g₂ - g₁)/(l₂ - l₁) ≤ max_rate_ppb.

It is unwise to enter slew mode until the clock is known to be at least reasonably accurate: otherwise it may take a very long time to catch up with a large future correction. For this reason, this function accepts a maxerror parameter which will cause it to return an error and remain in step mode if (max-min)/2 ≥ max_error.

Calling this function while already in slew mode is equivalent to switching to step mode and then immediately back into slew mode: it will cause the estimate to catch up to the current midpoint by a one-time step.

A maximum rate of i64::MAX is treated as infinity. A call such as slew(0, i64::MAX, max_error) will allow the estimate to advance at arbitrarily high or low speed but never to move backward.

When in slew mode, it becomes possible to obtain (min,est,max) tuples such that est < min or est > max. This can happen a previous estimate with wide error bounds is superceded by a new estimate with narrower ones which do not include the previous estimate.

fn step(&self) -> Result<()>[src]

Go back into step mode following a previous call to slew.

Loading content...

Implementors

Loading content...