Skip to content

Commit 8d934d1

Browse files
committed
Add some sensibly derived Debugs
1 parent 0ddf8b1 commit 8d934d1

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis-async"
3-
version = "0.4.3"
3+
version = "0.4.4"
44
authors = ["Ben Ashford <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
readme = "README.md"

src/client/paired.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2018 Ben Ashford
2+
* Copyright 2017-2019 Ben Ashford
33
*
44
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
55
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -168,7 +168,7 @@ impl Future for PairedConnectionInner {
168168
type SendPayload = (resp::RespValue, oneshot::Sender<resp::RespValue>);
169169

170170
/// A shareable and cheaply cloneable connection to which Redis commands can be sent
171-
#[derive(Clone)]
171+
#[derive(Debug, Clone)]
172172
pub struct PairedConnection {
173173
out_tx_c:
174174
Reconnect<SendPayload, mpsc::UnboundedSender<SendPayload>, error::Error, error::Error>,
@@ -209,7 +209,8 @@ pub fn paired_connect(
209209
Box::new(con_f)
210210
},
211211
)
212-
}).map(|out_tx_c| PairedConnection { out_tx_c })
212+
})
213+
.map(|out_tx_c| PairedConnection { out_tx_c })
213214
.map_err(|()| error::Error::EndOfStream)
214215
}
215216

@@ -235,7 +236,7 @@ impl PairedConnection {
235236
_ => {
236237
return Either::B(future::err(error::internal(
237238
"Command must be a RespValue::Array",
238-
)))
239+
)));
239240
}
240241
}
241242

src/client/pubsub.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2018 Ben Ashford
2+
* Copyright 2017-2019 Ben Ashford
33
*
44
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
55
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -204,7 +204,7 @@ impl Future for PubsubConnectionInner {
204204
}
205205

206206
/// A shareable reference to subscribe to PUBSUB topics
207-
#[derive(Clone)]
207+
#[derive(Debug, Clone)]
208208
pub struct PubsubConnection {
209209
out_tx_c:
210210
Reconnect<PubsubEvent, mpsc::UnboundedSender<PubsubEvent>, error::Error, error::Error>,
@@ -239,7 +239,8 @@ pub fn pubsub_connect(
239239
Box::new(con_f)
240240
},
241241
)
242-
}).map(|out_tx_c| PubsubConnection { out_tx_c })
242+
})
243+
.map(|out_tx_c| PubsubConnection { out_tx_c })
243244
.map_err(|()| error::Error::EndOfStream)
244245
}
245246

src/reconnect.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 Ben Ashford
2+
* Copyright 2018-2019 Ben Ashford
33
*
44
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
55
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
@@ -9,6 +9,7 @@
99
*/
1010

1111
use std::error as std_error;
12+
use std::fmt;
1213
use std::sync::{Arc, RwLock};
1314
use std::time::Duration;
1415

@@ -34,6 +35,15 @@ pub(crate) struct Reconnect<A, T, RE, CE> {
3435
conn_fn: Arc<Fn() -> Box<Future<Item = T, Error = CE> + Send> + Send + Sync>,
3536
}
3637

38+
impl<A, T, RE, CE> fmt::Debug for Reconnect<A, T, RE, CE>
39+
where
40+
T: fmt::Debug,
41+
{
42+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
43+
write!(f, "Reconnect {{ state: {:?} }}", self.state)
44+
}
45+
}
46+
3747
pub(crate) fn reconnect<A, T, RE, CE, W, C>(
3848
w: W,
3949
c: C,
@@ -55,6 +65,7 @@ where
5565
r.reconnect().map(|()| r)
5666
}
5767

68+
#[derive(Debug)]
5869
enum ReconnectState<T> {
5970
NotConnected,
6071
Connected(T),

0 commit comments

Comments
 (0)