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
}
};pub fn new_with_path(
clock_bound_d_socket: PathBuf
) -> Result<ClockBoundClient, ClockBoundCError>
pub fn new_with_path(
clock_bound_d_socket: PathBuf
) -> Result<ClockBoundClient, ClockBoundCError>
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
}
};