mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +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:
@@ -130,6 +130,18 @@ impl TryFrom<UnixStream> for mio_uds::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<net::UnixStream> for UnixStream {
|
||||
type Error = io::Error;
|
||||
|
||||
/// Consumes stream, returning the tokio I/O object.
|
||||
///
|
||||
/// This is equivalent to
|
||||
/// [`UnixStream::from_std(stream, &Handle::default())`](UnixStream::from_std).
|
||||
fn try_from(stream: net::UnixStream) -> io::Result<Self> {
|
||||
Self::from_std(stream, &Handle::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncRead for UnixStream {
|
||||
unsafe fn prepare_uninitialized_buffer(&self, _: &mut [u8]) -> bool {
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user