Crate sntp_request

Crate sntp_request 

Source
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§

SntpRequest
SNTP object which holds the socket handle to obtain timestamp from NTP servers.
SntpTimestamp
SNTP timestamp.

Constants§

POOL_NTP_ADDR
Default public NTP address.

Type Aliases§

SntpRawTimeResult
Specialized type for raw time result.
SntpUnixTimeResult
Specialized type for Unix time result.