From 9a184f427d2fa40dd6b9f6032a7ea5df2c201c2a Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 3 Apr 2021 23:06:58 +0600 Subject: [PATCH] upgrade ntex, drop direct futures dependency --- CHANGES.md | 4 ++++ Cargo.toml | 9 ++++----- src/client.rs | 20 ++++++++++---------- src/connector.rs | 5 ++--- src/simple.rs | 7 +++---- src/transport.rs | 6 ++---- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 07f53dc..cfeb0c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [0.1.1] - 2021-04-04 + +* upgrade ntex, drop direct futures dependency + ## [0.1.0] - 2021-03-10 * Initial release diff --git a/Cargo.toml b/Cargo.toml index 70186e6..5fe2603 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ntex-redis" -version = "0.1.0" +version = "0.1.1" authors = ["ntex contributors "] description = "Redis client" documentation = "https://docs.rs/ntex-redis" @@ -21,13 +21,12 @@ openssl = ["ntex/openssl"] rustls = ["ntex/rustls"] [dependencies] -ntex = "0.3.7" -derive_more = "0.99.5" -futures = "0.3.13" +ntex = "0.3.14" +derive_more = "0.99" itoa = "0.4.5" btoi = "0.4.2" log = "0.4" [dev-dependencies] rand = "0.8" -env_logger = "0.8" \ No newline at end of file +env_logger = "0.8" diff --git a/src/client.rs b/src/client.rs index 3e31cb1..be8b07a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,8 +1,5 @@ -use std::fmt; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{fmt, future::Future, pin::Pin, task::Context, task::Poll}; -use futures::{ready, Future, FutureExt}; use ntex::channel::{mpsc, pool}; use ntex::service::Service; @@ -32,11 +29,13 @@ impl Client { where T: Command, { - self.call(cmd.to_request()).map(|result| { - result + let fut = self.call(cmd.to_request()); + + async move { + fut.await .map_err(CommandError::Protocol) .and_then(|res| T::to_output(res.into_result().map_err(CommandError::Error)?)) - }) + } } /// Delete all the keys of the currently selected DB. @@ -88,9 +87,10 @@ impl Future for CommandResult { type Output = Result; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - match ready!(Pin::new(&mut self.rx).poll(cx)) { - Ok(res) => Poll::Ready(res), - Err(_) => Poll::Ready(Err(Error::Disconnected)), + match Pin::new(&mut self.rx).poll(cx) { + Poll::Ready(Ok(res)) => Poll::Ready(res), + Poll::Ready(Err(_)) => Poll::Ready(Err(Error::Disconnected)), + Poll::Pending => Poll::Pending, } } } diff --git a/src/connector.rs b/src/connector.rs index e60fb8b..705f36d 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -1,4 +1,5 @@ -use futures::Future; +use std::future::Future; + use ntex::channel::mpsc; use ntex::codec::{AsyncRead, AsyncWrite, Framed}; use ntex::connect::{self, Address, Connect, Connector}; @@ -10,8 +11,6 @@ use ntex::connect::openssl::{OpensslConnector, SslConnector}; #[cfg(feature = "rustls")] use ntex::connect::rustls::{ClientConfig, RustlsConnector}; -#[cfg(feature = "rustls")] -use std::sync::Arc; use super::codec::Codec; use super::errors::ConnectError; diff --git a/src/simple.rs b/src/simple.rs index 0ed31e7..dc8e9ee 100644 --- a/src/simple.rs +++ b/src/simple.rs @@ -1,5 +1,5 @@ -use futures::{SinkExt, StreamExt}; use ntex::codec::{AsyncRead, AsyncWrite, Framed}; +use ntex::util::{next, send}; use super::cmd::Command; use super::codec::Codec; @@ -33,9 +33,8 @@ where where U: Command, { - self.framed.send(cmd.to_request()).await?; - self.framed - .next() + send(&mut self.framed, cmd.to_request()).await?; + next(&mut self.framed) .await .ok_or_else(|| CommandError::Protocol(Error::Disconnected))? .map_err(Into::into) diff --git a/src/transport.rs b/src/transport.rs index 1b0c696..d248a9e 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -1,10 +1,8 @@ -use std::collections::VecDeque; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{collections::VecDeque, future::Future, pin::Pin, task::Context, task::Poll}; -use futures::{Future, Stream}; use ntex::channel::{mpsc, pool}; use ntex::codec::{AsyncRead, AsyncWrite, Framed}; +use ntex::Stream; use super::codec::{Codec, Request, Response}; use super::errors::Error;