io_lifetimes

Trait AsSocket

1.63.0 · Source
pub trait AsSocket {
    // Required method
    fn as_socket(&self) -> BorrowedSocket<'_>;
}
Expand description

A trait to borrow the socket from an underlying object.

Required Methods§

1.63.0 · Source

fn as_socket(&self) -> BorrowedSocket<'_>

Borrows the socket.

Implementors§

1.63.0 · Source§

impl AsSocket for TcpListener

1.63.0 · Source§

impl AsSocket for TcpStream

1.63.0 · Source§

impl AsSocket for UdpSocket

1.63.0 · Source§

impl AsSocket for BorrowedSocket<'_>

1.63.0 · Source§

impl AsSocket for OwnedSocket

1.63.0 · Source§

impl<T> AsSocket for &T
where T: AsSocket,

1.63.0 · Source§

impl<T> AsSocket for &mut T
where T: AsSocket,

1.71.0 · Source§

impl<T> AsSocket for Box<T>
where T: AsSocket,

1.71.0 · Source§

impl<T> AsSocket for Rc<T>
where T: AsSocket,

1.71.0 · Source§

impl<T> AsSocket for Arc<T>
where T: AsSocket,

This impl allows implementing traits that require AsSocket on Arc.

use std::net::UdpSocket;
use std::sync::Arc;

trait MyTrait: AsSocket {}
impl MyTrait for Arc<UdpSocket> {}
impl MyTrait for Box<UdpSocket> {}