Expand description
Custom error types for the NTP server. Custom error types for the NTP server.
All public APIs continue to return io::Result<T> for backward compatibility.
Internally, errors are constructed as NtpServerError variants and converted
to io::Error automatically via From<NtpServerError> for io::Error.
Users who want programmatic error matching can downcast via
io::Error::get_ref():
use ntp_server::error::NtpServerError;
match result {
Ok(()) => println!("server running"),
Err(e) => {
if let Some(srv_err) = e.get_ref()
.and_then(|inner| inner.downcast_ref::<NtpServerError>())
{
match srv_err {
NtpServerError::Protocol(p) => eprintln!("protocol error: {p}"),
NtpServerError::Nts(n) => eprintln!("NTS error: {n}"),
_ => eprintln!("server error: {srv_err}"),
}
}
}
}Enumsยง
- Config
Error - Server configuration errors.
- NtpServer
Error - Errors that can occur during NTP server operations.
- NtsError
- NTS (Network Time Security) server-side errors.
- Parse
Error - Errors that can occur during buffer-based NTP packet parsing or serialization.
- Protocol
Error - NTP protocol validation errors for incoming client requests.