chrony_candm/
lib.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: GPL-2.0-only
3
4//! This crate is a library for communicating with [Chrony](https://chrony.tuxfamily.org)'s
5//! control & monitoring interface. It provides programmatic access to information that you'd
6//! otherwise have to scrape from the output of `chronyc`.
7//!
8//! For simple use cases which involve non-privileged queries to the locally-running Chrony
9//! daemon, your main entry-point into the library will be the [blocking_query] function with
10//! a `server` argument of `&LOCAL_SERVER_ADDR`. For privileged commands, use [blocking_query_uds]
11//! instead (this will require permissions to write to the `/var/run/chrony` directory).
12//!
13//! ```no_run
14//! use chrony_candm::request::RequestBody;
15//! use chrony_candm::reply::ReplyBody;
16//! use chrony_candm::{blocking_query,LOCAL_SERVER_ADDR};
17//!
18//! let request_body = RequestBody::Tracking;
19//! let options = Default::default();
20//! let reply = blocking_query(request_body, options, &LOCAL_SERVER_ADDR)?;
21//! if let ReplyBody::Tracking(tracking) = reply.body {
22//!     println!("The current RMS offset is {} seconds.", tracking.rms_offset);
23//! }
24//! # Ok::<(), std::io::Error>(())
25//! ```
26//!
27//! Asynchronous applications can use [Client] instead of the standalone
28//! `blocking_query` and `blocking_query_uds` functions.
29
30extern crate self as chrony_candm; //We need this so that the fully qualified identifiers generated by macros can resolve
31
32#[cfg(feature = "with_tokio")]
33mod async_net;
34pub mod common;
35mod net;
36pub mod reply;
37pub mod request;
38
39#[cfg(feature = "with_tokio")]
40pub use async_net::*;
41pub use net::*;