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§
Sourcefn send_to<A>(self, socket: UdpSocket, addr: A) -> Result<(), Error>where
A: ToSocketAddrs,
fn send_to<A>(self, socket: UdpSocket, addr: A) -> Result<(), Error>where
A: ToSocketAddrs,
Sends self to given address on UdpSocket.
Sourcefn receive_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error>
fn receive_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error>
Receives a Self and a SocketAddr on a UdpSocket.
Sourcefn peek_from(socket: UdpSocket) -> Result<(Self, SocketAddr), Error>
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.
Sourcefn send_to_connected(self, socket: UdpSocket) -> Result<(), Error>
fn send_to_connected(self, socket: UdpSocket) -> Result<(), Error>
Sends self to connected UdpSocket.
Sourcefn receive_from_connected(socket: UdpSocket) -> Result<Self, Error>
fn receive_from_connected(socket: UdpSocket) -> Result<Self, Error>
Receives a Self on a connected UdpSocket.
Sourcefn peek_from_connected(socket: UdpSocket) -> Result<Self, Error>
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.