ntp_client/
lib.rs

1/*!
2### Example: Get time from an NTP server and sync systemtime
3```rust
4fn main() -> e_utils::AnyResult<()> {
5    let target = "0.pool.ntp.org:123";
6    let res = ntp_client::Client::new()
7        .target(target)?
8        .format(Some("%Y/%m/%d %H:%M:%S"))
9        .request()?;
10    let res_str = res.get_datetime_str().ok_or("error")?;
11    println!("UTC str -> {res_str}");
12    let datetime = res.get_datetime_utc().ok_or("get datetime utc")?;
13    ntp_client::sync_systemtime(datetime)?;
14    Ok(())
15}
16```
17*/
18
19#![doc = include_str!("../readme.md")]
20#![allow(
21  clippy::cognitive_complexity,
22  clippy::large_enum_variant,
23  clippy::module_inception,
24  clippy::needless_doctest_main
25)]
26#![deny(unused_must_use)]
27#![doc(test(no_crate_inject, attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))))]
28// #![warn(missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub)]
29
30
31pub mod formats;
32pub mod packet;
33pub use packet::Packet;
34pub mod client;
35pub use client::Client;
36#[cfg(feature = "sync-system")]
37mod sync_systemtime;
38#[cfg(feature = "sync-system")]
39pub use sync_systemtime::sync_systemtime;