pub struct NtpClient;Expand description
SNTP client for network-based time synchronization.
Queries an NTP server via UDP and returns the estimated clock offset. This is intentionally simple (single-packet, no association state) and is suitable for one-shot synchronization of distributed camera systems where NTP precision (≈ 1–50 ms) is adequate.
§Example
use oximedia_align::temporal::{NtpClient, NtpConfig};
let config = NtpConfig {
server: "pool.ntp.org".to_string(),
port: 123,
timeout_ms: 3_000,
};
// In production; requires network access:
// let delta = NtpClient::query_offset(&config).unwrap();
// println!("Clock offset: {} ms", delta.offset_ms);Implementations§
Source§impl NtpClient
impl NtpClient
Sourcepub fn query_offset(config: &NtpConfig) -> AlignResult<TimeDelta>
pub fn query_offset(config: &NtpConfig) -> AlignResult<TimeDelta>
Query an NTP server and compute the clock offset for the local clock.
Makes a single SNTP request (Mode 3 / Client) and parses the 48-byte NTP response packet to extract the four timestamps required for the RFC 4330 §5 offset formula.
§Errors
Returns AlignError::SyncError if:
- The server address cannot be resolved.
- The UDP socket cannot be bound or the send/receive fails.
- The response is shorter than 48 bytes or has an invalid leap/mode.
Auto Trait Implementations§
impl Freeze for NtpClient
impl RefUnwindSafe for NtpClient
impl Send for NtpClient
impl Sync for NtpClient
impl Unpin for NtpClient
impl UnsafeUnpin for NtpClient
impl UnwindSafe for NtpClient
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.