pub trait AsSocket {
// Required method
fn as_socket(&self) -> BorrowedSocket<'_>;
}
Available on Windows only.
Expand description
从底层对象借用套接字的 trait。
Required Methods§
sourcefn as_socket(&self) -> BorrowedSocket<'_>
fn as_socket(&self) -> BorrowedSocket<'_>
借用套接字。
Implementors§
impl AsSocket for TcpListener
impl AsSocket for TcpStream
impl AsSocket for UdpSocket
impl AsSocket for BorrowedSocket<'_>
impl AsSocket for OwnedSocket
impl<T: AsSocket> AsSocket for &T
impl<T: AsSocket> AsSocket for &mut T
impl<T: AsSocket> AsSocket for Box<T>
impl<T: AsSocket> AsSocket for Rc<T>
impl<T: AsSocket> AsSocket for Arc<T>
这个 impl 允许在 Arc 上实现需要 AsSocket
的 traits。
use std::net::UdpSocket;
use std::sync::Arc;
trait MyTrait: AsSocket {}
impl MyTrait for Arc<UdpSocket> {}
impl MyTrait for Box<UdpSocket> {}
Run