Skip to main content

BorrowedSocket

Struct BorrowedSocket 

1.63.0 ยท Source
pub struct BorrowedSocket<'socket> { /* private fields */ }
Available on Windows only.
Expand description

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ยง

Sourceยง

impl BorrowedSocket<'_>

1.63.0 (const: 1.63.0) ยท Source

pub const unsafe 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.

Sourceยง

impl BorrowedSocket<'_>

1.63.0 ยท Source

pub fn try_clone_to_owned(&self) -> Result<OwnedSocket>

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

Trait Implementationsยง

1.63.0 ยท Sourceยง

impl AsRawSocket for BorrowedSocket<'_>

Sourceยง

fn as_raw_socket(&self) -> RawSocket

Extracts the raw socket. Read more
1.63.0 ยท Sourceยง

impl AsSocket for BorrowedSocket<'_>

Sourceยง

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

Borrows the socket.
1.63.0 ยท Sourceยง

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

Sourceยง

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
1.63.0 ยท Sourceยง

impl Debug for BorrowedSocket<'_>

Sourceยง

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

Formats the value using the given formatter. Read more
1.63.0 ยท Sourceยง

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

Auto Trait Implementationsยง

ยง

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>

Blanket Implementationsยง

Sourceยง

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

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

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

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

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

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

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

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

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

Sourceยง

fn into(self) -> U

Calls U::from(self).

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

Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

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

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.
Sourceยง

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

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.