Struct clock_bound_c::ClockBoundClient[][src]

pub struct ClockBoundClient { /* fields omitted */ }
Expand description

A structure for holding a client to communicate with ClockBoundD.

Implementations

Create a new ClockBoundClient using the default clockboundd.sock path at “/run/clockboundd/clockboundd.sock”.

Examples
use clock_bound_c::ClockBoundClient;
let client = match ClockBoundClient::new(){
    Ok(client) => client,
    Err(e) => {
        println!("Couldn't create client: {}", e);
        return
    }
};

Create a new ClockBoundClient using a defined clockboundd.sock path.

The expected default socket path is at “/run/clockboundd/clockboundd.sock”, but if a different desired location has been set up this allows its usage.

If using the default location at “/run/clockboundd/clockboundd.sock”, use new() instead.

Arguments
  • clock_bound_d_socket - The path at which the clockboundd.sock lives.
Examples
use clock_bound_c::ClockBoundClient;
let client = match ClockBoundClient::new_with_path(std::path::PathBuf::from("/run/clockboundd/clockboundd.sock")){
    Ok(client) => client,
    Err(e) => {
        println!("Couldn't create client: {}", e);
        return
    }
};

Returns the bounds of the current system time +/- the error calculated from chrony.

Examples
use clock_bound_c::ClockBoundClient;
let client = match ClockBoundClient::new(){
    Ok(client) => client,
    Err(e) => {
        println!("Couldn't create client: {}", e);
        return
    }
};
let response = match client.now(){
    Ok(response) => response,
    Err(e) => {
        println!("Couldn't complete now request: {}", e);
        return
    }
};

Returns true if the provided timestamp is before the earliest error bound. Otherwise, returns false.

Arguments
  • before_time - A timestamp, represented as nanoseconds since the Unix Epoch, that is tested against the earliest error bound.
Examples
use clock_bound_c::ClockBoundClient;
let client = match ClockBoundClient::new(){
    Ok(client) => client,
    Err(e) => {
        println!("Couldn't create client: {}", e);
        return
    }
};
// Using 0 which equates to the Unix Epoch
let response = match client.before(0){
    Ok(response) => response,
    Err(e) => {
        println!("Couldn't complete before request: {}", e);
        return
    }
};

Returns true if the provided timestamp is after the latest error bound. Otherwise, returns false.

Arguments
  • after_time - A timestamp, represented as nanoseconds since the Unix Epoch, that is tested against the latest error bound.
Examples
use clock_bound_c::ClockBoundClient;
let client = match ClockBoundClient::new(){
    Ok(client) => client,
    Err(e) => {
        println!("Couldn't create client: {}", e);
        return
    }
};
// Using 0 which equates to the Unix Epoch
let response = match client.after(0){
    Ok(response) => response,
    Err(e) => {
        println!("Couldn't complete after request: {}", e);
        return
    }
};

Trait Implementations

Remove the client socket file when a ClockBoundClient is dropped.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.