ntp-timer 0.1.0

A lightweight NTP time synchronization library for Rust applications. Provides in-process cached global time with background sync and clock-jump detection.
Documentation
use thiserror::Error;

#[derive(Debug, Error)]
pub enum TimerError {
    #[error("NTP 错误: {0}")]
    NtpError(String),

    #[error("获取锁失败: {0}")]
    LockError(String),

    #[error("计时器未初始化")]
    NotInitialized,

    #[error("套接字错误: {0}")]
    SocketError(String),

    #[error("参数错误: {0}")]
    ConfigError(String),

    #[error("通道错误: {0}")]
    ChannelError(String),
}

impl From<anyhow::Error> for TimerError {
    fn from(err: anyhow::Error) -> Self {
        TimerError::NtpError(err.to_string())
    }
}