sntp_request 2.0.1

Tiny Rust library to request timestamp from NTP servers trough SNTP protocol.
Documentation
1
2
3
4
5
6
7
8
9
10
11
//! Basic example for how to obtain a raw NTP timestamp from main NTP server.

use sntp_request::SntpRequest;

fn main() {
    let sntp = SntpRequest::new();
    let timestamp = sntp.get_raw_time().unwrap();
    let nsec = (timestamp.frac as f64 / u32::max_value() as f64) * 1000.0;
    println!("seconds: {} frac: {}", timestamp.secs, timestamp.frac);
    println!("milliseconds: {}", nsec);
}