File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change
1
+ //! Hello world server.
2
+ //!
3
+ //! A simple client that connects to a mini-redis server, sets key "hello" with value "world",
4
+ //! and gets it from the server after
5
+ //!
6
+ //! You can test this out by running:
7
+ //!
8
+ //! cargo run --bin server
9
+ //!
10
+ //! And then in another terminal run:
11
+ //!
12
+ //! cargo run --example hello_world
13
+
14
+ #![ warn( rust_2018_idioms) ]
15
+
16
+ use mini_redis:: { client, Result } ;
17
+
1
18
#[ tokio:: main]
2
- async fn main ( ) {
3
- unimplemented ! ( ) ;
19
+ pub async fn main ( ) -> Result < ( ) > {
20
+ // Open a connection to the mini-redis address.
21
+ let mut client = client:: connect ( "127.0.0.1:6379" ) . await ?;
22
+
23
+ // Set the key "hello" with value "world"
24
+ client. set ( "hello" , "world" . into ( ) ) . await ?;
25
+
26
+ // Get key "hello"
27
+ let result = client. get ( "hello" ) . await ?;
28
+
29
+ println ! ( "got value from the server; success={:?}" , result. is_some( ) ) ;
30
+
31
+ Ok ( ( ) )
4
32
}
You can’t perform that action at this time.
0 commit comments