Trait nardol::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, {
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
Sends self
to given address
on UdpSocket.
fn 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.
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.
Sends self
to connected UdpSocket.
fn receive_from_connected(socket: UdpSocket) -> Result<Self, Error>
fn receive_from_connected(socket: UdpSocket) -> Result<Self, Error>
Receives a Self
on a connected UdpSocket.
fn 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.