#[repr(transparent)]pub struct BorrowedSocket<'socket> {
socket: NotAllOnes<RawSocket>,
_phantom: PhantomData<&'socket OwnedSocket>,
}
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.
Fields§
§socket: NotAllOnes<RawSocket>
§_phantom: PhantomData<&'socket OwnedSocket>
Implementations§
Source§impl BorrowedSocket<'_>
impl BorrowedSocket<'_>
1.63.0 (const: 1.63.0) · Sourcepub const unsafe fn borrow_raw(socket: RawSocket) -> Self
pub const unsafe fn borrow_raw(socket: RawSocket) -> Self
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 value
INVALID_SOCKET
.
Source§impl BorrowedSocket<'_>
impl BorrowedSocket<'_>
1.63.0 · Sourcepub fn try_clone_to_owned(&self) -> Result<OwnedSocket>
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<'_>
impl AsRawSocket for BorrowedSocket<'_>
Source§fn as_raw_socket(&self) -> RawSocket
fn as_raw_socket(&self) -> RawSocket
1.63.0 · Source§impl AsSocket for BorrowedSocket<'_>
impl AsSocket for BorrowedSocket<'_>
Source§fn as_socket(&self) -> BorrowedSocket<'_>
fn as_socket(&self) -> BorrowedSocket<'_>
1.63.0 · Source§impl<'socket> Clone for BorrowedSocket<'socket>
impl<'socket> Clone for BorrowedSocket<'socket>
Source§fn clone(&self) -> BorrowedSocket<'socket>
fn clone(&self) -> BorrowedSocket<'socket>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more1.63.0 · Source§impl Debug for BorrowedSocket<'_>
impl Debug for BorrowedSocket<'_>
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> UnwindSafe for BorrowedSocket<'socket>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties
)[Self]
. Read more