Trait sntpc::NtpUdpSocket

source ·
pub trait NtpUdpSocket {
    // Required methods
    fn send_to<T: ToSocketAddrs>(&self, buf: &[u8], addr: T) -> Result<usize>;
    fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>;
}
Expand description

A trait encapsulating UDP socket interface required for SNTP client operations

Required Methods§

source

fn send_to<T: ToSocketAddrs>(&self, buf: &[u8], addr: T) -> Result<usize>

Send the given buffer to an address provided. On success, returns the number of bytes written.

Since multiple SocketAddr objects can hide behind the type (domain name can be resolved to multiple addresses), the method should send data to a single address available in addr

source

fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Receives a single datagram message on the socket. On success, returns the number of bytes read and the origin.

The function will be called with valid byte array buf of sufficient size to hold the message bytes

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NtpUdpSocket for UdpSocket

source§

fn send_to<T: ToSocketAddrs>(&self, buf: &[u8], addr: T) -> Result<usize, Error>

source§

fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr), Error>

Implementors§