pub struct Config {
pub sync_interval_secs: u64,
pub clock_jump_threshold_secs: i64,
pub ntp_servers: Vec<String>,
pub max_retries: usize,
pub socket_timeout_secs: u64,
pub initial_retry_interval_secs: u64,
}Expand description
NTP 计时器的配置
支持 Builder 模式,便于自定义
Fields§
§sync_interval_secs: u64后台同步间隔(秒),默认值:600
clock_jump_threshold_secs: i64时钟跳跃检测阈值(秒),默认值:5
ntp_servers: Vec<String>NTP 服务器列表
max_retries: usize最大重试次数,默认值:10
socket_timeout_secs: u64套接字超时时间(秒),默认值:5
initial_retry_interval_secs: u64初始重试间隔(秒),默认值:1
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_sync_interval(self, secs: u64) -> Self
pub fn with_sync_interval(self, secs: u64) -> Self
设置后台同步间隔
Sourcepub fn with_jump_threshold(self, secs: i64) -> Self
pub fn with_jump_threshold(self, secs: i64) -> Self
设置时钟跳跃检测阈值
Sourcepub fn with_ntp_servers(self, servers: Vec<String>) -> Self
pub fn with_ntp_servers(self, servers: Vec<String>) -> Self
设置 NTP 服务器列表
Sourcepub fn with_max_retries(self, retries: usize) -> Self
pub fn with_max_retries(self, retries: usize) -> Self
设置最大重试次数
Sourcepub fn with_socket_timeout(self, secs: u64) -> Self
pub fn with_socket_timeout(self, secs: u64) -> Self
设置套接字超时
Sourcepub fn with_initial_retry_interval(self, secs: u64) -> Self
pub fn with_initial_retry_interval(self, secs: u64) -> Self
设置初始重试间隔
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more