[][src]Struct rsntp::SntpClient

pub struct SntpClient { /* fields omitted */ }

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]

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]

impl Debug for SntpClient[src]

impl Default for SntpClient[src]

impl Hash for SntpClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.