Skip to content

Commit

Permalink
upgrade ntex, drop direct futures dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Apr 3, 2021
1 parent 47f737a commit 9a184f4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-redis"
version = "0.1.0"
version = "0.1.1"
authors = ["ntex contributors <[email protected]>"]
description = "Redis client"
documentation = "https://docs.rs/ntex-redis"
Expand All @@ -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"
env_logger = "0.8"
20 changes: 10 additions & 10 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -88,9 +87,10 @@ impl Future for CommandResult {
type Output = Result<Response, Error>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
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,
}
}
}
5 changes: 2 additions & 3 deletions src/connector.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/simple.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/transport.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9a184f4

Please sign in to comment.