[−][src]Struct rsntp::SntpClient
Blocking client instance
This is the main entry point of the blocking API.
Implementations
impl SntpClient
[src]
pub fn new() -> SntpClient
[src]
Creates a new instance with default parameters
Example
use rsntp::SntpClient; let client = SntpClient::new();
pub fn synchronize<A: ToServerAddrs>(
&self,
server_address: A
) -> Result<SynchronizationResult, SynchroniztationError>
[src]
&self,
server_address: A
) -> Result<SynchronizationResult, SynchroniztationError>
Synchronize with the server
Sends a request to the server, waits for the reply and processes it. 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.
If the supplied server address resolves to multiple addresses then only the first one is used.
Example
use rsntp::SntpClient; let client = SntpClient::new(); let result = client.synchronize("pool.ntp.org");
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(); client.set_timeout(Duration::from_secs(10));
pub fn set_bind_address(&mut self, address: SocketAddr)
[src]
Set UDP bind address
Sets the local address which is used to send/receive UDP packets. By default it is "0.0.0.0:0" which means that an IPv4 address and a port is chosen automatically.
To synchronize with IPv6 servers, you might need to set it to an IPv6 address.
Example
use rsntp::SntpClient; let mut client = SntpClient::new(); client.set_bind_address("192.168.0.1:0".parse().unwrap());
Trait Implementations
impl Clone for SntpClient
[src]
fn clone(&self) -> SntpClient
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SntpClient
[src]
impl Default for SntpClient
[src]
impl Hash for SntpClient
[src]
Auto Trait Implementations
impl RefUnwindSafe for SntpClient
[src]
impl Send for SntpClient
[src]
impl Sync for SntpClient
[src]
impl Unpin for SntpClient
[src]
impl UnwindSafe for SntpClient
[src]
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,
pub 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,