#[repr(transparent)]
pub struct BorrowedSocket<'socket> { /* private fields */ }
🔬 This is a nightly-only experimental API. (io_safety #87074)
This is supported 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

🔬 This is a nightly-only experimental API. (io_safety #87074)

Return a BorrowedSocket holding the given raw socket.

Safety

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

Trait Implementations

Extracts the raw socket. Read more

🔬 This is a nightly-only experimental API. (io_safety #87074)

Borrows the socket.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.