#[repr(transparent)]pub struct BorrowedSocket<'socket> { /* private fields */ }
Available on Windows only.
Expand description
借来的套接字。
它有一个生命周期参数,将它与拥有套接字的事物的生命周期联系起来。
这使用 repr(transparent)
并具有主机套接字的表示形式,因此它可以在 FFI 中用于套接字作为参数传递的地方,它不会被捕获或消耗,并且它永远不会有值 INVALID_SOCKET
。
这种类型的 .to_owned()
实现返回另一个 BorrowedSocket
而不是 OwnedSocket
。它只是简单地复制原始套接字,然后在相同的生命周期下借用。
Implementations§
source§impl BorrowedSocket<'_>
impl BorrowedSocket<'_>
const: 1.63.0 · sourcepub const unsafe fn borrow_raw(socket: RawSocket) -> Self
pub const unsafe fn borrow_raw(socket: RawSocket) -> Self
返回一个包含给定原始套接字的 BorrowedSocket
。
Safety
raw
指向的资源在返回的 BorrowedSocket
期间必须保持打开状态,并且它不能具有值 INVALID_SOCKET
。
source§impl BorrowedSocket<'_>
impl BorrowedSocket<'_>
sourcepub fn try_clone_to_owned(&self) -> Result<OwnedSocket>
pub fn try_clone_to_owned(&self) -> Result<OwnedSocket>
创建一个新的 OwnedSocket
实例,该实例与现有 BorrowedSocket
实例共享相同的底层 object。
Trait Implementations§
source§impl AsRawSocket for BorrowedSocket<'_>
impl AsRawSocket for BorrowedSocket<'_>
source§fn as_raw_socket(&self) -> RawSocket
fn as_raw_socket(&self) -> RawSocket
提取原始套接字。 Read more
source§impl AsSocket for BorrowedSocket<'_>
impl AsSocket for BorrowedSocket<'_>
source§fn as_socket(&self) -> BorrowedSocket<'_>
fn as_socket(&self) -> BorrowedSocket<'_>
借用套接字。
source§impl<'socket> Clone for BorrowedSocket<'socket>
impl<'socket> Clone for BorrowedSocket<'socket>
source§fn clone(&self) -> BorrowedSocket<'socket>
fn clone(&self) -> BorrowedSocket<'socket>
返回值的副本。 Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
从
source
执行复制分配。 Read moresource§impl 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§
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
从拥有的值中借用。 Read more