BorrowedSocket in std::os::windows::io - Rust (original) (raw)
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 valueINVALID_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.
1.63.0 (const: 1.63.0) · Source
Returns 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 valueINVALID_SOCKET
.
1.63.0 · Source
Creates a new OwnedSocket
instance that shares the same underlying object as the existing BorrowedSocket
instance.