[][src]Trait stunxy::RW

pub trait RW: Send + Sync {
    fn local_addr(&self) -> Result<SocketAddr>;
fn send_to(&self, buf: &[u8], addr: SocketAddr) -> Result<usize>;
fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>;
fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>;
fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>;
fn read_timeout(&self) -> Result<Option<Duration>>;
fn write_timeout(&self) -> Result<Option<Duration>>; }

Represents an socket which can send data to and receive data from a certain address.

Required methods

fn local_addr(&self) -> Result<SocketAddr>

Returns the socket address that this socket was created from.

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

Sends data on the socket to the given address.

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

Receives a single datagram message on the socket.

fn set_read_timeout(&self, dur: Option<Duration>) -> Result<()>

Sets the read timeout to the timeout specified.

fn set_write_timeout(&self, dur: Option<Duration>) -> Result<()>

Sets the write timeout to the timeout specified.

fn read_timeout(&self) -> Result<Option<Duration>>

Returns the read timeout of this socket.

fn write_timeout(&self) -> Result<Option<Duration>>

Returns the write timeout of this socket.

Loading content...

Implementors

Loading content...