pub struct Socket<Tx, Rx> {
pub send: Tx,
pub recv: Rx,
pub local_addr: SocketAddr,
pub peer_addr: SocketAddr,
pub capabilities: SocketCapabilities,
}
Expand description
A connected datagram socket with separate send
and recv
halves.
Socket
abstracts over both real UDP-based connections and in-process
tunneled flows like (multi-hop) MASQUE flows. It uses the
datagram_socket
traits for this purpose.
Fields§
§send: Tx
The sending half of the connection. This generally supports concurrent senders.
recv: Rx
The receiving half of the connection. This is generally owned by a single caller.
local_addr: SocketAddr
The address of the local endpoint.
peer_addr: SocketAddr
The address of the remote endpoint.
capabilities: SocketCapabilities
The SocketCapabilities
to use for this socket.
By default, Socket
s are constructed with all capabilities
disabled. On Linux, you can use apply_max_capabilities()
to (try
to) enable all supported capabilities.
Implementations§
Source§impl<Tx, Rx> Socket<Tx, Rx>where
Tx: DatagramSocketSend,
Rx: DatagramSocketRecv,
impl<Tx, Rx> Socket<Tx, Rx>where
Tx: DatagramSocketSend,
Rx: DatagramSocketRecv,
Sourcepub fn as_udp_socket(&self) -> Option<&UdpSocket>
pub fn as_udp_socket(&self) -> Option<&UdpSocket>
Sourcepub fn apply_max_capabilities(&mut self, max_send_udp_payload_size: usize)
pub fn apply_max_capabilities(&mut self, max_send_udp_payload_size: usize)
Tries to enable all sockopts supported by the crate for this socket.
This does nothing unless send
and recv
refer to the same UDP socket
FD. See SocketCapabilities::apply_all_and_get_compatibility
for
details.
Trait Implementations§
Auto Trait Implementations§
impl<Tx, Rx> Freeze for Socket<Tx, Rx>
impl<Tx, Rx> RefUnwindSafe for Socket<Tx, Rx>where
Tx: RefUnwindSafe,
Rx: RefUnwindSafe,
impl<Tx, Rx> Send for Socket<Tx, Rx>
impl<Tx, Rx> Sync for Socket<Tx, Rx>
impl<Tx, Rx> Unpin for Socket<Tx, Rx>
impl<Tx, Rx> UnwindSafe for Socket<Tx, Rx>where
Tx: UnwindSafe,
Rx: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more