mirror of
https://github.com/async-rs/async-std.git
synced 2025-04-24 17:26:51 +00:00
switch to async-io
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
This commit is contained in:
parent
8886039ac5
commit
25e0e1abdc
8 changed files with 20 additions and 18 deletions
|
@ -24,6 +24,7 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
|
|||
[features]
|
||||
default = [
|
||||
"std",
|
||||
"async-io",
|
||||
"async-task",
|
||||
"kv-log-macro",
|
||||
"log",
|
||||
|
@ -77,6 +78,7 @@ futures-timer = { version = "3.0.2", optional = true }
|
|||
surf = { version = "1.0.3", optional = true }
|
||||
|
||||
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||
async-io = { version = "0.1.5", optional = true }
|
||||
smol = { version = "0.1.17", optional = true }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::future::Future;
|
|||
use std::net::SocketAddr;
|
||||
use std::pin::Pin;
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use crate::io;
|
||||
use crate::net::{TcpStream, ToSocketAddrs};
|
||||
|
@ -81,7 +81,7 @@ impl TcpListener {
|
|||
let addrs = addrs.to_socket_addrs().await?;
|
||||
|
||||
for addr in addrs {
|
||||
match Async::<std::net::TcpListener>::bind(&addr) {
|
||||
match Async::<std::net::TcpListener>::bind(addr) {
|
||||
Ok(listener) => {
|
||||
return Ok(TcpListener { watcher: listener });
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ cfg_unix! {
|
|||
|
||||
impl IntoRawFd for TcpListener {
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.watcher.into_raw_fd()
|
||||
self.watcher.into_inner().unwrap().into_raw_fd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ cfg_windows! {
|
|||
|
||||
impl IntoRawSocket for TcpListener {
|
||||
fn into_raw_socket(self) -> RawSocket {
|
||||
self.watcher.into_raw_socket()
|
||||
self.watcher.into_inner().unwrap().into_raw_socket()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::io::{IoSlice, IoSliceMut};
|
|||
use std::net::SocketAddr;
|
||||
use std::pin::Pin;
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use crate::io::{self, Read, Write};
|
||||
use crate::net::ToSocketAddrs;
|
||||
|
@ -77,7 +77,7 @@ impl TcpStream {
|
|||
let addrs = addrs.to_socket_addrs().await?;
|
||||
|
||||
for addr in addrs {
|
||||
match Async::<std::net::TcpStream>::connect(&addr).await {
|
||||
match Async::<std::net::TcpStream>::connect(addr).await {
|
||||
Ok(stream) => {
|
||||
return Ok(TcpStream {
|
||||
watcher: Arc::new(stream),
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::io;
|
|||
use std::net::SocketAddr;
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use crate::net::ToSocketAddrs;
|
||||
use crate::utils::Context as _;
|
||||
|
@ -74,7 +74,7 @@ impl UdpSocket {
|
|||
let addrs = addrs.to_socket_addrs().await?;
|
||||
|
||||
for addr in addrs {
|
||||
match Async::<std::net::UdpSocket>::bind(&addr) {
|
||||
match Async::<std::net::UdpSocket>::bind(addr) {
|
||||
Ok(socket) => {
|
||||
return Ok(UdpSocket { watcher: socket });
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ cfg_unix! {
|
|||
|
||||
impl IntoRawFd for UdpSocket {
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.watcher.into_raw_fd()
|
||||
self.watcher.into_inner().unwrap().into_raw_fd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ cfg_windows! {
|
|||
|
||||
impl IntoRawSocket for UdpSocket {
|
||||
fn into_raw_socket(self) -> RawSocket {
|
||||
self.watcher.into_raw_socket()
|
||||
self.watcher.into_inner().unwrap().into_raw_socket()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::fmt;
|
|||
use std::net::Shutdown;
|
||||
use std::os::unix::net::UnixDatagram as StdUnixDatagram;
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use super::SocketAddr;
|
||||
use crate::io;
|
||||
|
@ -335,6 +335,6 @@ impl FromRawFd for UnixDatagram {
|
|||
|
||||
impl IntoRawFd for UnixDatagram {
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.watcher.into_raw_fd()
|
||||
self.watcher.into_inner().unwrap().into_raw_fd()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::future::Future;
|
|||
use std::os::unix::net::UnixListener as StdUnixListener;
|
||||
use std::pin::Pin;
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use super::SocketAddr;
|
||||
use super::UnixStream;
|
||||
|
@ -217,6 +217,6 @@ impl FromRawFd for UnixListener {
|
|||
|
||||
impl IntoRawFd for UnixListener {
|
||||
fn into_raw_fd(self) -> RawFd {
|
||||
self.watcher.into_raw_fd()
|
||||
self.watcher.into_inner().unwrap().into_raw_fd()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::net::Shutdown;
|
|||
use std::os::unix::net::UnixStream as StdUnixStream;
|
||||
use std::pin::Pin;
|
||||
|
||||
use smol::Async;
|
||||
use async_io::Async;
|
||||
|
||||
use super::SocketAddr;
|
||||
use crate::io::{self, Read, Write};
|
||||
|
|
|
@ -61,7 +61,7 @@ pub(crate) trait Context {
|
|||
|
||||
#[cfg(all(not(target_os = "unknown"), feature = "default"))]
|
||||
mod timer {
|
||||
pub type Timer = smol::Timer;
|
||||
pub type Timer = async_io::Timer;
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "unstable", feature = "default"))]
|
||||
|
@ -69,7 +69,7 @@ pub(crate) fn timer_after(dur: std::time::Duration) -> timer::Timer {
|
|||
#[cfg(all(not(target_os = "unknown"), feature = "default"))]
|
||||
once_cell::sync::Lazy::force(&crate::rt::RUNTIME);
|
||||
|
||||
Timer::after(dur)
|
||||
Timer::new(dur)
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
|
@ -84,7 +84,7 @@ mod timer {
|
|||
pub(crate) struct Timer(futures_timer::Delay);
|
||||
|
||||
impl Timer {
|
||||
pub(crate) fn after(dur: std::time::Duration) -> Self {
|
||||
pub(crate) fn new(dur: std::time::Duration) -> Self {
|
||||
Timer(futures_timer::Delay::new(dur))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue