Trait Socket
pub trait Socket:
Send
+ Sync
+ 'static {
// Required methods
fn local_addr(&self) -> Result<SocketAddress, Error>;
fn peer_addr(&self) -> Result<SocketAddress, Error>;
}Available on crate feature
net only.Expand description
Common information exposed by a Socket-like construct.
For now this is implemented for TCP and UDP, as these are the types that are relevant to Rama.
Required Methods§
fn local_addr(&self) -> Result<SocketAddress, Error>
fn local_addr(&self) -> Result<SocketAddress, Error>
Try to get the local address of the socket.
fn peer_addr(&self) -> Result<SocketAddress, Error>
fn peer_addr(&self) -> Result<SocketAddress, Error>
Try to get the remote address of the socket.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl Socket for TcpStream
impl Socket for TcpStream
fn local_addr(&self) -> Result<SocketAddress, Error>
fn peer_addr(&self) -> Result<SocketAddress, Error>
§impl Socket for UdpSocket
impl Socket for UdpSocket
fn local_addr(&self) -> Result<SocketAddress, Error>
fn peer_addr(&self) -> Result<SocketAddress, Error>
Implementors§
impl Socket for DatagramSocketGroup
impl Socket for MemoryDatagramSocket
impl Socket for MockSocket
impl Socket for NoProxyConnection
Available on crate features
dns and http-backend and http and std and tcp only.