Skip to content

Commit 19ec37a

Browse files
committed
update api usage
1 parent ed9b887 commit 19ec37a

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ env_logger = "0.9"
3333

3434
[patch.crates-io]
3535
ntex = { git = "https://github.com/ntex-rs/ntex.git" }
36+
ntex-rt = { git = "https://github.com/ntex-rs/ntex.git" }
3637
ntex-io = { git = "https://github.com/ntex-rs/ntex.git" }
3738
ntex-tls = { git = "https://github.com/ntex-rs/ntex.git" }

src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,31 @@ impl Client {
3030
ntex::rt::spawn(async move {
3131
poll_fn(|cx| loop {
3232
match ready!(io.poll_recv(&Codec, cx)) {
33-
Some(Ok(item)) => {
33+
Ok(Some(item)) => {
3434
if let Some(tx) = queue2.borrow_mut().pop_front() {
3535
let _ = tx.send(Ok(item));
3636
} else {
3737
log::error!("Unexpected redis response: {:?}", item);
3838
}
3939
continue;
4040
}
41-
Some(Err(Either::Left(e))) => {
41+
Err(Either::Left(e)) => {
4242
if let Some(tx) = queue2.borrow_mut().pop_front() {
4343
let _ = tx.send(Err(e));
4444
}
4545
queue2.borrow_mut().clear();
4646
let _ = ready!(io.poll_shutdown(cx));
4747
return Poll::Ready(());
4848
}
49-
Some(Err(Either::Right(e))) => {
49+
Err(Either::Right(e)) => {
5050
if let Some(tx) = queue2.borrow_mut().pop_front() {
5151
let _ = tx.send(Err(e.into()));
5252
}
5353
queue2.borrow_mut().clear();
5454
let _ = ready!(io.poll_shutdown(cx));
5555
return Poll::Ready(());
5656
}
57-
None => return Poll::Ready(()),
57+
Ok(None) => return Poll::Ready(()),
5858
}
5959
})
6060
.await

src/connector.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ where
8787
}
8888

8989
/// Use custom boxed connector
90-
pub fn boxed_connector<U>(
91-
self,
92-
connector: U,
93-
) -> RedisConnector<A, U>
90+
pub fn boxed_connector<U>(self, connector: U) -> RedisConnector<A, U>
9491
where
9592
U: Service<Request = Connect<A>, Response = IoBoxed, Error = connect::ConnectError>,
9693
{

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub fn gen_random_key() -> String {
7878
use rand::distributions::Alphanumeric;
7979
use rand::{thread_rng, Rng};
8080

81-
let key: String = thread_rng().sample_iter(&Alphanumeric).take(12).map(char::from).collect();
81+
let key: String = thread_rng()
82+
.sample_iter(&Alphanumeric)
83+
.take(12)
84+
.map(char::from)
85+
.collect();
8286
key
8387
}

src/simple.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ impl SimpleClient {
2525
self.io.encode(cmd.to_request(), &Codec)?;
2626

2727
poll_fn(|cx| match ready!(self.io.poll_recv(&Codec, cx)) {
28-
Some(Ok(item)) => Poll::Ready(U::to_output(
28+
Ok(Some(item)) => Poll::Ready(U::to_output(
2929
item.into_result().map_err(CommandError::Error)?,
3030
)),
31-
Some(Err(Either::Left(err))) => Poll::Ready(Err(CommandError::Protocol(err))),
32-
Some(Err(Either::Right(err))) => Poll::Ready(Err(CommandError::Protocol(err.into()))),
33-
None => Poll::Ready(Err(CommandError::Protocol(Error::Disconnected))),
31+
Err(Either::Left(err)) => Poll::Ready(Err(CommandError::Protocol(err))),
32+
Err(Either::Right(err)) => Poll::Ready(Err(CommandError::Protocol(err.into()))),
33+
Ok(None) => Poll::Ready(Err(CommandError::Protocol(Error::Disconnected))),
3434
})
3535
.await
3636
}

0 commit comments

Comments
 (0)