1use chrono::Utc;
4use clock_bound_c::ClockBoundClient;
5use std::env;
6use std::thread::sleep;
7use std::time::Duration;
8
9fn main() {
10 let args: Vec<String> = env::args().collect();
11 let clock_bound_d_socket = &args[1];
12
13 let client =
14 match ClockBoundClient::new_with_path(std::path::PathBuf::from(clock_bound_d_socket)) {
15 Ok(client) => client,
16 Err(e) => {
17 println!("Could not create client: {}", e);
18 return;
19 }
20 };
21
22 let timestamp = Utc::now().timestamp_nanos() as u64;
24
25 let response = match client.before(timestamp) {
27 Ok(response) => response,
28 Err(e) => {
29 println!("Couldn't complete before request: {}", e);
30 return;
31 }
32 };
33
34 if response.before == false {
38 println!(
39 "{} nanoseconds since the Unix Epoch is not before the current time's error bounds.",
40 timestamp
41 )
42 } else if response.before == true {
43 println!(
44 "{} nanoseconds since the Unix Epoch is before the current time's error bounds.",
45 timestamp
46 )
47 }
48
49 println!("Waiting 1 second...");
50
51 sleep(Duration::from_secs(1));
54
55 let response = match client.before(timestamp) {
57 Ok(response) => response,
58 Err(e) => {
59 println!("Couldn't complete before request: {}", e);
60 return;
61 }
62 };
63
64 if response.before == false {
65 println!(
66 "{} nanoseconds since the Unix Epoch is not before the current time's error bounds.",
67 timestamp
68 )
69 } else if response.before == true {
70 println!(
71 "{} nanoseconds since the Unix Epoch is before the current time's error bounds.",
72 timestamp
73 )
74 }
75}