Struct BorrowedSocket

struct BorrowedSocket<'socket> { ... }

A borrowed socket.

This has a lifetime parameter to tie it to the lifetime of something that owns the socket.

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 an argument, it is not captured or consumed, and it never has the value INVALID_SOCKET.

This type's .to_owned() implementation returns another BorrowedSocket rather than an OwnedSocket. It just makes a trivial copy of the raw socket, which is then borrowed under the same lifetime.

Implementations

impl BorrowedSocket<'_>

fn try_clone_to_owned(self: &Self) -> Result<OwnedSocket>

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

impl BorrowedSocket<'_>

unsafe const fn borrow_raw(socket: RawSocket) -> Self

Returns a BorrowedSocket holding the given raw socket.

Safety

The resource pointed to by socket must remain open for the duration of the returned BorrowedSocket, and it must not have the value INVALID_SOCKET.

impl AsRawSocket for BorrowedSocket<'_>

fn as_raw_socket(self: &Self) -> RawSocket

impl AsSocket for BorrowedSocket<'_>

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

impl Debug for BorrowedSocket<'_>

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

impl<'socket> Clone for BorrowedSocket<'socket>

fn clone(self: &Self) -> BorrowedSocket<'socket>

impl<'socket> Copy for BorrowedSocket<'socket>

impl<'socket> Freeze for BorrowedSocket<'socket>

impl<'socket> RefUnwindSafe for BorrowedSocket<'socket>

impl<'socket> Send for BorrowedSocket<'socket>

impl<'socket> Sync for BorrowedSocket<'socket>

impl<'socket> Unpin for BorrowedSocket<'socket>

impl<'socket> UnsafeUnpin for BorrowedSocket<'socket>

impl<'socket> UnwindSafe for BorrowedSocket<'socket>

impl<T> Any for BorrowedSocket<'socket>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for BorrowedSocket<'socket>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for BorrowedSocket<'socket>

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

impl<T> CloneToUninit for BorrowedSocket<'socket>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for BorrowedSocket<'socket>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for BorrowedSocket<'socket>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for BorrowedSocket<'socket>

fn into(self: 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 for BorrowedSocket<'socket>

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

impl<T, U> TryInto for BorrowedSocket<'socket>

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