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