pub trait Transceiver {
type IntoError: Into<Error>;
// Required methods
fn addr(&self) -> SocketAddr;
fn recv(
&self,
buf: &mut [u8],
) -> Result<Option<(usize, SocketAddr)>, Self::IntoError>;
fn send(
&self,
buf: &[u8],
addr: SocketAddr,
) -> Result<usize, Self::IntoError>;
}Expand description
A trait for sending and receiving data.
Both the server and client use a statically dispatched generic type T: Transceiver to send and receive data,
which allows you to use any type that implements this trait as your network socket for a netcode server or client.
See NetcodeSocket for an example implementation.
This is also the default implementation used by the server and client.
Required Associated Types§
Required Methods§
Sourcefn addr(&self) -> SocketAddr
fn addr(&self) -> SocketAddr
Returns the local address of the socket (i.e. the address it is bound to).
Mostly used for generating and validating ConnectTokens.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".