chrony-confile
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
.sourcesfiles - Validation -- Structural and semantic validation (no I/O required)
- Builder pattern -- Programmatic config generation with compile-time guarantees
- Include/confdir expansion -- Resolve
includeandconfdirdirectives - 100% safe Rust --
#![deny(unsafe_code)], zerounsafe - Minimal dependencies -- Only
thiserrorrequired;serdeis optional
Installation
[]
= "0.1"
Quick Start
use *;
// 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
// Validate
let errors = config.validate;
assert!;
// Serialize back (comments, formatting preserved)
println!;
// Build configs programmatically
let directive = new
.iburst
.prefer
.minpoll
.build;
MSRV
The minimum supported Rust version is 1.85 (edition 2024).
License
MIT