mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-24 03:42:59 +01:00
ActixStream readiness methods return Ready object (#293)
This commit is contained in:
parent
945479e0c3
commit
0c73f13c8b
@ -1,6 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## Unreleased - 2021-xx-xx
|
## Unreleased - 2021-xx-xx
|
||||||
|
* `ActixStream::{poll_read_ready, poll_write_ready}` would return `Ready` in Ok variant. [#293]
|
||||||
|
|
||||||
|
[#293] https://github.com/actix/actix-net/pull/293
|
||||||
|
|
||||||
|
|
||||||
## 2.1.0 - 2021-02-24
|
## 2.1.0 - 2021-02-24
|
||||||
|
@ -26,7 +26,7 @@ macros = ["actix-macros"]
|
|||||||
actix-macros = { version = "0.2.0", optional = true }
|
actix-macros = { version = "0.2.0", optional = true }
|
||||||
|
|
||||||
futures-core = { version = "0.3", default-features = false }
|
futures-core = { version = "0.3", default-features = false }
|
||||||
tokio = { version = "1.2", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
|
tokio = { version = "1.3", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1.2", features = ["full"] }
|
tokio = { version = "1.2", features = ["full"] }
|
||||||
|
@ -72,9 +72,14 @@ pub mod signal {
|
|||||||
pub mod net {
|
pub mod net {
|
||||||
//! TCP/UDP/Unix bindings (mostly Tokio re-exports).
|
//! TCP/UDP/Unix bindings (mostly Tokio re-exports).
|
||||||
|
|
||||||
use std::task::{Context, Poll};
|
use std::{
|
||||||
|
future::Future,
|
||||||
|
io,
|
||||||
|
task::{Context, Poll},
|
||||||
|
};
|
||||||
|
|
||||||
use tokio::io::{AsyncRead, AsyncWrite};
|
pub use tokio::io::Ready;
|
||||||
|
use tokio::io::{AsyncRead, AsyncWrite, Interest};
|
||||||
pub use tokio::net::UdpSocket;
|
pub use tokio::net::UdpSocket;
|
||||||
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
pub use tokio::net::{TcpListener, TcpSocket, TcpStream};
|
||||||
|
|
||||||
@ -86,32 +91,40 @@ pub mod net {
|
|||||||
/// Poll stream and check read readiness of Self.
|
/// Poll stream and check read readiness of Self.
|
||||||
///
|
///
|
||||||
/// See [tokio::net::TcpStream::poll_read_ready] for detail on intended use.
|
/// See [tokio::net::TcpStream::poll_read_ready] for detail on intended use.
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>>;
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>>;
|
||||||
|
|
||||||
/// Poll stream and check write readiness of Self.
|
/// Poll stream and check write readiness of Self.
|
||||||
///
|
///
|
||||||
/// See [tokio::net::TcpStream::poll_write_ready] for detail on intended use.
|
/// See [tokio::net::TcpStream::poll_write_ready] for detail on intended use.
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>>;
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActixStream for TcpStream {
|
impl ActixStream for TcpStream {
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
TcpStream::poll_read_ready(self, cx)
|
let ready = self.ready(Interest::READABLE);
|
||||||
|
tokio::pin!(ready);
|
||||||
|
ready.poll(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
TcpStream::poll_write_ready(self, cx)
|
let ready = self.ready(Interest::WRITABLE);
|
||||||
|
tokio::pin!(ready);
|
||||||
|
ready.poll(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
impl ActixStream for UnixStream {
|
impl ActixStream for UnixStream {
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
UnixStream::poll_read_ready(self, cx)
|
let ready = self.ready(Interest::READABLE);
|
||||||
|
tokio::pin!(ready);
|
||||||
|
ready.poll(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
UnixStream::poll_write_ready(self, cx)
|
let ready = self.ready(Interest::WRITABLE);
|
||||||
|
tokio::pin!(ready);
|
||||||
|
ready.poll(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::{ActixStream, Ready};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::counter::Counter;
|
use actix_utils::counter::Counter;
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
@ -80,11 +80,11 @@ impl<T: ActixStream> AsyncWrite for TlsStream<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_read_ready((&**self).get_ref().get_ref().get_ref(), cx)
|
T::poll_read_ready((&**self).get_ref().get_ref().get_ref(), cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_write_ready((&**self).get_ref().get_ref().get_ref(), cx)
|
T::poll_write_ready((&**self).get_ref().get_ref().get_ref(), cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::{ActixStream, Ready};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::counter::{Counter, CounterGuard};
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
use futures_core::{future::LocalBoxFuture, ready};
|
use futures_core::{future::LocalBoxFuture, ready};
|
||||||
@ -82,11 +82,11 @@ impl<T: ActixStream> AsyncWrite for TlsStream<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_read_ready((&**self).get_ref(), cx)
|
T::poll_read_ready((&**self).get_ref(), cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_write_ready((&**self).get_ref(), cx)
|
T::poll_write_ready((&**self).get_ref(), cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||||
use actix_rt::net::ActixStream;
|
use actix_rt::net::{ActixStream, Ready};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use actix_utils::counter::{Counter, CounterGuard};
|
use actix_utils::counter::{Counter, CounterGuard};
|
||||||
use futures_core::future::LocalBoxFuture;
|
use futures_core::future::LocalBoxFuture;
|
||||||
@ -82,11 +82,11 @@ impl<T: ActixStream> AsyncWrite for TlsStream<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
impl<T: ActixStream> ActixStream for TlsStream<T> {
|
||||||
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_read_ready((&**self).get_ref().0, cx)
|
T::poll_read_ready((&**self).get_ref().0, cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
|
fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<Ready>> {
|
||||||
T::poll_write_ready((&**self).get_ref().0, cx)
|
T::poll_write_ready((&**self).get_ref().0, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user