Struct OwnedSocket

#[repr(transparent)]
pub struct OwnedSocket { pub(in ::os::windows::io::socket) socket: NotAllOnes<RawSocket> }

An owned socket.

This closes the socket on drop.

This uses repr(transparent) and has the representation of a host socket, so it can be used in FFI in places where a socket is passed as a consumed argument or returned as an owned value, and it never has the value INVALID_SOCKET.

Fields

socket: NotAllOnes<RawSocket>

Implementations

impl OwnedSocket

fn try_clone(&self) -> Result<Self>

Creates a new OwnedSocket instance that shares the same underlying object as the existing OwnedSocket instance.

fn set_no_inherit(&self) -> Result<()>

Trait Implementations

impl AsRawSocket for OwnedSocket

fn as_raw_socket(&self) -> RawSocket

impl AsSocket for OwnedSocket

fn as_socket(&self) -> BorrowedSocket<'_>

impl Debug for OwnedSocket

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Drop for OwnedSocket

fn drop(&mut self)

impl From<TcpListener> for OwnedSocket

fn from(tcp_listener: TcpListener) -> OwnedSocket

Takes ownership of a TcpListener's socket.

impl From<TcpStream> for OwnedSocket

fn from(tcp_stream: TcpStream) -> OwnedSocket

Takes ownership of a TcpStream's socket.

impl From<UdpSocket> for OwnedSocket

fn from(udp_socket: UdpSocket) -> OwnedSocket

Takes ownership of a UdpSocket's underlying socket.

impl FromRawSocket for OwnedSocket

unsafe fn from_raw_socket(socket: RawSocket) -> Self

impl IntoRawSocket for OwnedSocket

fn into_raw_socket(self) -> RawSocket

Auto Trait Implementations

impl Freeze for OwnedSocket

impl RefUnwindSafe for OwnedSocket

impl Send for OwnedSocket

impl Sync for OwnedSocket

impl Unpin for OwnedSocket

impl UnsafeUnpin for OwnedSocket

impl UnwindSafe for OwnedSocket

Blanket Implementations

impl<T> Any for OwnedSocket where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for OwnedSocket where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for OwnedSocket where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for OwnedSocket

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for OwnedSocket where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for OwnedSocket

impl<T, U> Into<U> for OwnedSocket where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for OwnedSocket where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for OwnedSocket where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>