UdpMessage

Trait UdpMessage 

Source
pub trait UdpMessage<'a>
where Self: Default + ToRon + FromRon<'a> + TryInto<Packet> + TryFrom<Packet>, Error: From<<Self as TryInto<Packet>>::Error> + From<<Self as TryFrom<Packet>>::Error>, <Self as TryInto<Packet>>::Error: Into<Error> + Debug, <Self as TryFrom<Packet>>::Error: Into<Error> + Debug,
{ // Provided methods fn send_to<A>(self, socket: UdpSocket, addr: A) -> Result<(), Error> where A: ToSocketAddrs { ... } fn receive_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error> { ... } fn peek_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error> { ... } fn send_to_connected(self, socket: UdpSocket) -> Result<(), Error> { ... } fn receive_from_connected(socket: UdpSocket) -> Result<Self, Error> { ... } fn peek_from_connected(socket: UdpSocket) -> Result<Self, Error> { ... } }
Expand description

Trait that allows implementor to send and receive itself on UdpSocket with provided methods.

Provided Methods§

Source

fn send_to<A>(self, socket: UdpSocket, addr: A) -> Result<(), Error>
where A: ToSocketAddrs,

Sends self to given address on UdpSocket.

Source

fn receive_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error>

Receives a Self and a SocketAddr on a UdpSocket.

Source

fn peek_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error>

Peeks on data on socket, if valid data are received a Self is created and returned together with a SocketAddr.

Since UdpSocket::peek_from is used to retrieve data, calling this again returns the same data.

Source

fn send_to_connected(self, socket: UdpSocket) -> Result<(), Error>

Sends self to connected UdpSocket.

Source

fn receive_from_connected(socket: UdpSocket) -> Result<Self, Error>

Receives a Self on a connected UdpSocket.

Source

fn peek_from_connected(socket: UdpSocket) -> Result<Self, Error>

Peeks on data on a connected socket, if valid data are received a Self is created.

Since UdpSocket::peek is used to retrieve data, calling this again returns the same data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§