Expand description
sntp_request
Tiny Rust library to request timestamp from NTP servers trough SNTP protocol.
§Example
The example below shows how to obtain precise timestamp from main NTP server:
use chrono::{Local, TimeZone};
use sntp_request::SntpRequest;
fn main() {
let sntp = SntpRequest::new();
let timestamp = Local.timestamp_opt(sntp.get_unix_time().unwrap(), 0);
println!("{}", timestamp.unwrap());
}
Structs§
- Sntp
Request - SNTP object which holds the socket handle to obtain timestamp from NTP servers.
- Sntp
Timestamp - SNTP timestamp.
Constants§
- POOL_
NTP_ ADDR - Default public NTP address.
Type Aliases§
- Sntp
RawTime Result - Specialized type for raw time result.
- Sntp
Unix Time Result - Specialized type for Unix time result.