@@ -7,7 +7,7 @@ use std::time::Duration;
7
7
use tokio:: net:: ToSocketAddrs ;
8
8
use tokio:: runtime:: Runtime ;
9
9
10
- pub use crate :: client :: Message ;
10
+ pub use crate :: clients :: Message ;
11
11
12
12
/// Established connection with a Redis server.
13
13
///
@@ -18,7 +18,7 @@ pub use crate::client::Message;
18
18
/// Requests are issued using the various methods of `Client`.
19
19
pub struct BlockingClient {
20
20
/// The asynchronous `Client`.
21
- inner : crate :: client :: Client ,
21
+ inner : crate :: clients :: Client ,
22
22
23
23
/// A `current_thread` runtime for executing operations on the asynchronous
24
24
/// client in a blocking manner.
@@ -33,7 +33,7 @@ pub struct BlockingClient {
33
33
/// called.
34
34
pub struct BlockingSubscriber {
35
35
/// The asynchronous `Subscriber`.
36
- inner : crate :: client :: Subscriber ,
36
+ inner : crate :: clients :: Subscriber ,
37
37
38
38
/// A `current_thread` runtime for executing operations on the asynchronous
39
39
/// `Subscriber` in a blocking manner.
@@ -43,43 +43,43 @@ pub struct BlockingSubscriber {
43
43
/// The iterator returned by `Subscriber::into_iter`.
44
44
struct SubscriberIterator {
45
45
/// The asynchronous `Subscriber`.
46
- inner : crate :: client :: Subscriber ,
46
+ inner : crate :: clients :: Subscriber ,
47
47
48
48
/// A `current_thread` runtime for executing operations on the asynchronous
49
49
/// `Subscriber` in a blocking manner.
50
50
rt : Runtime ,
51
51
}
52
52
53
- /// Establish a connection with the Redis server located at `addr`.
54
- ///
55
- /// `addr` may be any type that can be asynchronously converted to a
56
- /// `SocketAddr`. This includes `SocketAddr` and strings. The `ToSocketAddrs`
57
- /// trait is the Tokio version and not the `std` version.
58
- ///
59
- /// # Examples
60
- ///
61
- /// ```no_run
62
- /// use mini_redis::blocking_client;
63
- ///
64
- /// fn main() {
65
- /// let client = match blocking_client::connect("localhost:6379") {
66
- /// Ok(client) => client,
67
- /// Err(_) => panic!("failed to establish connection"),
68
- /// };
69
- /// # drop(client);
70
- /// }
71
- /// ```
72
- pub fn connect < T : ToSocketAddrs > ( addr : T ) -> crate :: Result < BlockingClient > {
73
- let rt = tokio:: runtime:: Builder :: new_current_thread ( )
74
- . enable_all ( )
75
- . build ( ) ?;
53
+ impl BlockingClient {
54
+ /// Establish a connection with the Redis server located at `addr`.
55
+ ///
56
+ /// `addr` may be any type that can be asynchronously converted to a
57
+ /// `SocketAddr`. This includes `SocketAddr` and strings. The `ToSocketAddrs`
58
+ /// trait is the Tokio version and not the `std` version.
59
+ ///
60
+ /// # Examples
61
+ ///
62
+ /// ```no_run
63
+ /// use mini_redis::clients::BlockingClient;
64
+ ///
65
+ /// fn main() {
66
+ /// let client = match BlockingClient::connect("localhost:6379") {
67
+ /// Ok(client) => client,
68
+ /// Err(_) => panic!("failed to establish connection"),
69
+ /// };
70
+ /// # drop(client);
71
+ /// }
72
+ /// ```
73
+ pub fn connect < T : ToSocketAddrs > ( addr : T ) -> crate :: Result < BlockingClient > {
74
+ let rt = tokio:: runtime:: Builder :: new_current_thread ( )
75
+ . enable_all ( )
76
+ . build ( ) ?;
76
77
77
- let inner = rt. block_on ( crate :: client :: connect ( addr) ) ?;
78
+ let inner = rt. block_on ( crate :: clients :: Client :: connect ( addr) ) ?;
78
79
79
- Ok ( BlockingClient { inner, rt } )
80
- }
80
+ Ok ( BlockingClient { inner, rt } )
81
+ }
81
82
82
- impl BlockingClient {
83
83
/// Get the value of key.
84
84
///
85
85
/// If the key does not exist the special value `None` is returned.
@@ -89,10 +89,10 @@ impl BlockingClient {
89
89
/// Demonstrates basic usage.
90
90
///
91
91
/// ```no_run
92
- /// use mini_redis::blocking_client ;
92
+ /// use mini_redis::clients::BlockingClient ;
93
93
///
94
94
/// fn main() {
95
- /// let mut client = blocking_client ::connect("localhost:6379").unwrap();
95
+ /// let mut client = BlockingClient ::connect("localhost:6379").unwrap();
96
96
///
97
97
/// let val = client.get("foo").unwrap();
98
98
/// println!("Got = {:?}", val);
@@ -115,10 +115,10 @@ impl BlockingClient {
115
115
/// Demonstrates basic usage.
116
116
///
117
117
/// ```no_run
118
- /// use mini_redis::blocking_client ;
118
+ /// use mini_redis::clients::BlockingClient ;
119
119
///
120
120
/// fn main() {
121
- /// let mut client = blocking_client ::connect("localhost:6379").unwrap();
121
+ /// let mut client = BlockingClient ::connect("localhost:6379").unwrap();
122
122
///
123
123
/// client.set("foo", "bar".into()).unwrap();
124
124
///
@@ -149,13 +149,13 @@ impl BlockingClient {
149
149
/// favorable.
150
150
///
151
151
/// ```no_run
152
- /// use mini_redis::blocking_client ;
152
+ /// use mini_redis::clients::BlockingClient ;
153
153
/// use std::thread;
154
154
/// use std::time::Duration;
155
155
///
156
156
/// fn main() {
157
157
/// let ttl = Duration::from_millis(500);
158
- /// let mut client = blocking_client ::connect("localhost:6379").unwrap();
158
+ /// let mut client = BlockingClient ::connect("localhost:6379").unwrap();
159
159
///
160
160
/// client.set_expires("foo", "bar".into(), ttl).unwrap();
161
161
///
@@ -191,10 +191,10 @@ impl BlockingClient {
191
191
/// Demonstrates basic usage.
192
192
///
193
193
/// ```no_run
194
- /// use mini_redis::blocking_client ;
194
+ /// use mini_redis::clients::BlockingClient ;
195
195
///
196
196
/// fn main() {
197
- /// let mut client = blocking_client ::connect("localhost:6379").unwrap();
197
+ /// let mut client = BlockingClient ::connect("localhost:6379").unwrap();
198
198
///
199
199
/// let val = client.publish("foo", "bar".into()).unwrap();
200
200
/// println!("Got = {:?}", val);
0 commit comments