Trait io_lifetimes::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§

source

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

Borrows the socket.

Implementors§

source§

impl AsSocket for TcpListener

source§

impl AsSocket for TcpStream

source§

impl AsSocket for UdpSocket

source§

impl AsSocket for BorrowedSocket<'_>

source§

impl AsSocket for OwnedSocket

source§

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

source§

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

1.71.0-nightly · source§

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

1.71.0-nightly · source§

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

1.71.0-nightly · 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> {}