#[repr(transparent)]pub struct BorrowedSocket<'socket> { /* private fields */ }
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
sourceimpl BorrowedSocket<'_>
impl BorrowedSocket<'_>
sourcepub unsafe fn borrow_raw(socket: RawSocket) -> Self
pub unsafe fn borrow_raw(socket: RawSocket) -> Self
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
sourceimpl AsRawSocket for BorrowedSocket<'_>
impl AsRawSocket for BorrowedSocket<'_>
sourcefn as_raw_socket(&self) -> RawSocket
fn as_raw_socket(&self) -> RawSocket
Extracts the raw socket. Read more
sourceimpl AsSocket for BorrowedSocket<'_>
impl AsSocket for BorrowedSocket<'_>
sourceimpl<'socket> Clone for BorrowedSocket<'socket>
impl<'socket> Clone for BorrowedSocket<'socket>
sourcefn clone(&self) -> BorrowedSocket<'socket>
fn clone(&self) -> BorrowedSocket<'socket>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BorrowedSocket<'_>
impl Debug for BorrowedSocket<'_>
impl<'socket> Copy for BorrowedSocket<'socket>
Auto Trait Implementations
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> UnwindSafe for BorrowedSocket<'socket>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
Uses borrowed data to replace owned data, usually by cloning. Read more