#![deny(unsafe_code)]
# configuration files.\n\
\n\
This crate provides complete coverage of all 96 chrony directives with a type-safe API,\n\
lossless round-trip serialization (comments and formatting preserved), and optional\n\
`include`/`confdir` expansion.\n\
\n\
# Quick Start\n\
\n\
```rust\n\
use chrony_confile::prelude::*;\n\
\n\
let config: ChronyConfig = r#\"\n\
server ntp1.example.com iburst prefer\n \
server ntp2.example.com iburst\n \
pool pool.ntp.org maxsources 6\n \
driftfile /var/lib/chrony/drift\n \
allow 192.168.0.0/16\n \
\"#.parse()?;\n\
\n\
// Iterate over directives with a specific name\n\
for directive in config.find(\"server\") {\n\
if let DirectiveKind::Server(s) = &directive.kind {\n\
println!(\"NTP source: {}\", s.hostname);\n\
}\n\
}\n\
\n\
// Validate the configuration\n\
let errors = config.validate();\n\
\n\
// Serialize back to string (lossless)\n\
let output = config.to_string();\n\
# Ok::<_, chrony_confile::ParseError>(())\n\
```\n\
\n\
# Modules\n\
\n\
- **`ast`** -- All AST types representing chrony directives and configuration structure\n\
- **`parser`** -- Parsing logic for chrony config files and .sources files\n\
- **`ser`** -- Serialization (`Display` trait impls, optional `serde`)\n\
- **`validator`** -- Structural and semantic validation\n\
- **`builder`** -- Builder pattern for programmatic config generation\n\
- **`expand`** -- Include/confdir expansion\n\
- **`error`** -- Error types for parsing, validation, and value construction\n\
- **`span`** -- Source location tracking\n\
- **`values`** -- Bounded integer newtypes with range checking\n\
\n\
# Feature Flags\n\
\n\
- `serde` (optional) -- Enables `Serialize` for `ChronyConfig`\n\
"]
pub mod error;
pub mod span;
pub mod values;
pub mod ast;
pub mod parser;
pub mod ser;
pub mod validator;
pub mod builder;
pub mod expand;
pub use ast::ChronyConfig;
pub use ast::source_file::SourceFile;
pub use error::{ParseError, DirectiveError, ValueError};
pub use span::Span;
pub use ast::Directive;
pub use ast::DirectiveKind;
pub use ast::DirectiveCategory;
pub use ast::ConfigNode;
pub use values::{
PollInterval, UdpPort, Dscp, Stratum, SamplesCount, PollTarget,
NtpVersion, PpsRate, SchedPriority, PtpDomain, ClientLogSize,
TxBuffers, NtsProcesses,
};
pub use ast::source::{
ServerConfig, PoolConfig, PeerConfig, RefClockConfig, RefClockDriverKind,
SourceConnectivity, AddressFamily, SelectOptions, AllowDenyConfig,
RateLimitConfig, NtsRateLimitConfig, SmoothTimeConfig, BroadcastConfig,
LocalConfig, InitStepSlewConfig,
};
pub use ast::ntp::{
BindAddressConfig, BindDeviceConfig, ClientLogLimitConfig,
NtpSignDSocketConfig, NtsPortConfig, NtsServerCertConfig,
NtsServerKeyConfig, NtsProcessesConfig, MaxNtsConnectionsConfig,
NtsNtpServerConfig, NtsRotateConfig, PortConfig, CmdRateLimitConfig,
};
pub use ast::cmd::{
BindCmdAddressConfig, BindCmdDeviceConfig, CmdPortConfig,
OpenCommandsConfig,
};
pub use ast::clock::{
ClockPrecisionConfig, CorrTimeRatioConfig, DriftFileConfig,
FallbackDriftConfig, LeapSecTzConfig, LeapSecListConfig,
MakeStepConfig, MaxChangeConfig, MaxClockErrorConfig, MaxDriftConfig,
MaxUpdateSkewConfig, MaxSlewRateConfig, TempCompConfig,
LeapSecMode,
};
pub use ast::selection::{
AuthSelectMode, CombineLimitConfig, MaxDistanceConfig, MaxJitterConfig,
MinSourcesConfig, ReselectDistConfig, StratumWeightConfig,
};
pub use ast::log::{
LogConfig, LogBannerConfig, LogChangeConfig, LogDirConfig,
};
pub use ast::rtc::{
HwClockFileConfig, RtcAutoTrimConfig, RtcDeviceConfig, RtcFileConfig,
};
pub use ast::hw::{
HwTimestampConfig, HwTsTimeoutConfig, MaxTxBuffersConfig,
PtpPortConfig, PtpDomainConfig, HwTsRxFilter,
};
pub use ast::nts::NtsAeadsConfig;
pub use ast::misc::{
ConfDirConfig, IncludeConfig, SourceDirConfig, MailOnChangeConfig,
PidFileConfig, SchedPriorityConfig, UserConfig, KeyFileConfig,
AcquisitionPortConfig, DscpConfig, DumpDirConfig, NtsDumpDirConfig,
NtsRefreshConfig, NtsTrustedCertsConfig, NoCertTimeCheckConfig,
RefreshConfig, MaxSamplesConfig, MinSamplesConfig,
};
pub use ast::source_file::{SourceEntry, SourceNode};
pub use builder::{ServerBuilder, PoolBuilder};
pub use expand::ExpandOptions;
impl std::str::FromStr for ChronyConfig {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::parse(s)
}
}
pub mod prelude {
pub use crate::ast::*;
pub use crate::builder::*;
pub use crate::error::*;
pub use crate::span::*;
pub use crate::values::*;
pub use crate::validator::Validate;
pub use crate::ChronyConfig;
pub use crate::SourceFile;
pub use std::str::FromStr;
}