# Trait AsSocket

1.63.0 · Source

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

Available on Windows only.
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

Source§

### impl<T: AsSocket + ?Sized> AsSocket for UniqueRc<T>

1.63.0 · Source§

### impl<T: AsSocket> AsSocket for &T

1.63.0 · Source§

### impl<T: AsSocket> AsSocket for &mut T

1.71.0 · Source§

### impl<T: AsSocket> AsSocket for Box<T>

1.71.0 · Source§

### impl<T: AsSocket> AsSocket for Rc<T>

1.71.0 · Source§

### impl<T: AsSocket> AsSocket for Arc<T>

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> {}