rsntp
An RFC 4330 compliant Simple Network Time Protocol (SNTP) client library for Rust.
rsntp
provides both a synchronous (blocking) and an (optional) asynchronous API which allows
synchronization with SNTPv4 servers. Time and date handling is based on the chrono
crate.
Usage
Add this to your Cargo.toml
:
[]
= "1.0.2"
Obtain the current local time with the blocking API:
use SntpClient;
use ;
let client = new;
let result = client.synchronize.unwrap;
let local_time: = from;
println!;
And a function which uses the asynchronous API to obtain local time:
use AsyncSntpClient;
use ;
async
Disabling asynchronous API
The asynchronous API is compiled in by default but you can optionally disable it. This removes
dependency to tokio
which reduces crate dependencies significantly.
[]
= { = "1.0.2", = false }