chrony-confile 0.1.0

A full-featured Rust library for parsing, editing, validating, and serializing chrony configuration files
Documentation
  • Coverage
  • 37.05%
    289 out of 780 items documented31 out of 339 items with examples
  • Size
  • Source code size: 455.66 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.76 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • franckcl1989

chrony-confile

Crates.io Docs.rs License: MIT

A full-featured, production-grade Rust library for parsing, editing, validating, and serializing chrony configuration files.

Features

  • Complete directive coverage -- All 96 chrony directives supported
  • Lossless round-trip -- Parse, modify, serialize; comments and formatting preserved
  • Type-safe API -- Every value range-checked at compile time via newtypes
  • Strict and lenient modes -- Fail-fast for main configs, tolerant for .sources files
  • Validation -- Structural and semantic validation (no I/O required)
  • Builder pattern -- Programmatic config generation with compile-time guarantees
  • Include/confdir expansion -- Resolve include and confdir directives
  • 100% safe Rust -- #![deny(unsafe_code)], zero unsafe
  • Minimal dependencies -- Only thiserror required; serde is optional

Installation

[dependencies]
chrony-confile = "0.1"

Quick Start

use chrony_confile::prelude::*;

// Parse a configuration file
let config: ChronyConfig = r#"
    server ntp1.example.com iburst prefer
    server ntp2.example.com iburst
    pool pool.ntp.org maxsources 6
    driftfile /var/lib/chrony/drift
    allow 192.168.0.0/16
"#.parse()?;

// Iterate over directives
for server in config.find("server") {
    if let DirectiveKind::Server(s) = &server.kind {
        println!("Server: {} (iburst: {})", s.hostname, s.iburst);
    }
}

// Validate
let errors = config.validate();
assert!(errors.is_empty());

// Serialize back (comments, formatting preserved)
println!("{config}");

// Build configs programmatically
let directive = ServerBuilder::new("ntp.example.com")
    .iburst()
    .prefer()
    .minpoll(PollInterval::new(4)?)
    .build();

MSRV

The minimum supported Rust version is 1.85 (edition 2024).

License

MIT