[−][src]Struct rsntp::SntpClient
Blocking SNTP client instance
This is the main entry point of the blocking API. It is an association between the local host and the remote server and can be reused, i.e. multiple synchronization can be executed with a single instance.
Methods
impl SntpClient
[src]
pub fn new(server_address: &str) -> Result<SntpClient, Error>
[src]
Creates a new instance.
The parameter is the server DNS name or IP addresss. It uses the default SNTP UDP port (123)
Example
use rsntp::SntpClient; let client = SntpClient::new("pool.ntp.org").unwrap();
pub fn with_socket_addr<T: ToSocketAddrs>(
socket_addr: T
) -> Result<SntpClient, Error>
[src]
socket_addr: T
) -> Result<SntpClient, Error>
Creates a new instance for the given socket addres.
Example
use rsntp::SntpClient; let socket_addr = ("pool.ntp.org", 123); let client = SntpClient::with_socket_addr(socket_addr).unwrap();
pub fn synchronize(
&self
) -> Result<SynchronizationResult, SynchroniztationError>
[src]
&self
) -> Result<SynchronizationResult, SynchroniztationError>
Synchronize with the server
It sends a request to the server, waits for the reply and processes that reply. This is a blocking call and can block for quite long time. After sending the request it waits for a timeout and if no reply is received then an error is returned.
Example
use rsntp::SntpClient; let socket_addr = ("pool.ntp.org", 123); let client = SntpClient::with_socket_addr(socket_addr).unwrap(); let result = client.synchronize();
pub fn set_timeout(&mut self, timeout: Duration)
[src]
Sets synchronization timeout
This sets the amount of time which the client waits for reply after the request has been sent. Default is 3 seconds.
Example
use rsntp::SntpClient; use std::time::Duration; let mut client = SntpClient::new("pool.ntp.org").unwrap(); client.set_timeout(Duration::from_secs(10));
Trait Implementations
impl Clone for SntpClient
[src]
fn clone(&self) -> SntpClient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SntpClient
[src]
impl Hash for SntpClient
[src]
Auto Trait Implementations
impl RefUnwindSafe for SntpClient
impl Send for SntpClient
impl Sync for SntpClient
impl Unpin for SntpClient
impl UnwindSafe for SntpClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,