Trait unsafe_io::AsUnsafeSocket[][src]

pub unsafe trait AsUnsafeSocket: AsUnsafeHandle {
    fn as_unsafe_socket(&self) -> UnsafeSocket;

    fn as_tcp_stream_view(&self) -> View<'_, TcpStream> { ... }
unsafe fn as_unscoped_tcp_stream_view(&self) -> View<'static, TcpStream> { ... }
fn as_tcp_listener_view(&self) -> View<'_, TcpListener> { ... }
unsafe fn as_unscoped_tcp_listener_view(&self) -> View<'static, TcpListener> { ... }
fn as_udp_socket_view(&self) -> View<'_, UdpSocket> { ... }
unsafe fn as_unscoped_udp_socket_view(&self) -> View<'static, UdpSocket> { ... }
fn eq_socket<Socketlike: AsUnsafeSocket>(&self, other: &Socketlike) -> bool { ... } }
Expand description

A trait for types which contain an unsafe socket and can expose it.

A type implementing AsUnsafeSocket guarantees that the return value from as_unsafe_socket on an instance of the type is a copy of a socket which is owned.

Safety

This trait is unsafe because types implementing it must guarantee they own their socket.

Required methods

Return the contained unsafe socket.

Provided methods

Utility for returning a value which dereferences to a &TcpStream or &mut TcpStream.

Note that AsUnsafeSocket may be implemented for types which are not TCP streams, and which don’t support all the methods on TcpStream.

Like as_tcp_stream_view, but returns a value which is not explicitly tied to the lifetime of self.

Safety

Callers must manually ensure that the view doesn’t outlive self.

Utility for returning a value which dereferences to a &TcpListener or &mut TcpListener.

Note that AsUnsafeSocket may be implemented for types which are not TCP listeners, and which don’t support all the methods on TcpListener.

Like as_tcp_listener_view, but returns a value which is not explicitly tied to the lifetime of self.

Safety

Callers must manually ensure that the view doesn’t outlive self.

Utility for returning a value which dereferences to a &UdpSocket or &mut UdpSocket.

Note that AsUnsafeSocket may be implemented for types which are not UDP sockets, and which don’t support all the methods on UdpSocket.

Like as_udp_socket_view, but returns a value which is not explicitly tied to the lifetime of self.

Safety

Callers must manually ensure that the view doesn’t outlive self.

Test whether self.as_unsafe_socket().as_unsafe_handle() is equal to other.as_unsafe_socket().as_unsafe_handle().

That this depends on the guarantee that types that implement AsUnsafeSocket own their resources, so we won’t erroneously compare dangling handles.

Implementors