mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
add TryFrom/From implementations (#1347)
* TryFrom<net::TcpListener> for TcpListener * TryFrom<net::TcpStream> for TcpStream * TryFrom<net::UdpSocket> for UdpSocket * TryFrom<net::UnixDatagram> for UnixDatagram * TryFrom<net::UnixListener> for UnixListener * TryFrom<net::UnixStream> for UnixStream * TryFrom<UnixDatagram> for mio_uds::UnixDatagram * TryFrom<File> for io::File * From<io::File> for File
This commit is contained in:
@@ -451,6 +451,18 @@ impl TryFrom<UdpSocket> for mio::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<net::UdpSocket> for UdpSocket {
|
||||
type Error = io::Error;
|
||||
|
||||
/// Consumes stream, returning the tokio I/O object.
|
||||
///
|
||||
/// This is equivalent to
|
||||
/// [`UdpSocket::from_std(stream, &Handle::default())`](UdpSocket::from_std).
|
||||
fn try_from(stream: net::UdpSocket) -> Result<Self, Self::Error> {
|
||||
Self::from_std(stream, &Handle::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for UdpSocket {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.io.get_ref().fmt(f)
|
||||
|
||||
Reference in New Issue
Block a user