@@ -35,149 +35,20 @@ cargo new skyapp
35
35
First add this to your ` Cargo.toml ` file:
36
36
37
37
``` toml
38
- skytable = " 0.7 .0-alpha.4 "
38
+ skytable = " 0.8 .0-beta.1 "
39
39
```
40
40
41
- Now open up your ` src/main.rs ` file and establish a connection to the server while also adding some
42
- imports:
41
+ You're ready to go!
43
42
44
43
``` rust
45
- use skytable :: {Connection , Query , Element , SkyResult };
46
- fn main () -> SkyResult <()> {
47
- let mut con = Connection :: new (" 127.0.0.1" , 2003 )? ;
48
- Ok (())
49
- }
50
- ```
51
-
52
- Now let's run a ` Query ` ! Change the previous code block to:
53
-
54
- ``` rust
55
- use skytable :: {error, Connection , Query , Element };
56
- fn main () -> Result <(), error :: Error > {
57
- let mut con = Connection :: new (" 127.0.0.1" , 2003 )? ;
58
- let query = Query :: from (" heya" );
59
- let res : String = con . run_query (& query )? ;
60
- assert_eq! (res , " HEY!" );
61
- Ok (())
62
- }
63
- ```
64
-
65
- ## Running actions
66
-
67
- As noted [ below] ( #binary-data ) , the default table is a key/value table with a binary key
68
- type and a binary value type. Let's go ahead and run some actions (we're assuming you're
69
- using the sync API; for async, simply change the import to ` use skytable::actions::AsyncActions ` ).
70
-
71
- ### ` SET ` ting a key
72
-
73
- ``` rust
74
- use skytable :: actions :: Actions ;
75
- use skytable :: sync :: Connection ;
76
-
77
- let mut con = Connection :: new (" 127.0.0.1" , 2003 ). unwrap ();
78
- con . set (" hello" , " world" ). unwrap ();
79
- ```
80
-
81
- This will set the value of the key ` hello ` to ` world ` in the ` default:default ` entity.
82
-
83
- ### ` GET ` ting a key
84
-
85
- ``` rust
86
- use skytable :: actions :: Actions ;
87
- use skytable :: sync :: Connection ;
88
-
89
- let mut con = Connection :: new (" 127.0.0.1" , 2003 ). unwrap ();
90
- let x : String = con . get (" hello" ). unwrap ();
91
- assert_eq! (x , " world" );
92
- ```
93
-
94
- Way to go &mdash ; you're all set! Now go ahead and run more advanced queries!
95
-
96
- ## Binary data
97
-
98
- The ` default:default ` keyspace has the following declaration:
99
-
100
- ``` text
101
- Keymap { data:(binstr,binstr), volatile:false }
102
- ```
103
-
104
- This means that the default keyspace is ready to store binary data. Let's say
105
- you wanted to ` SET ` the value of a key called ` bindata ` to some binary data stored
106
- in a ` Vec<u8> ` . You can achieve this with the ` RawString ` type:
107
-
108
- ``` rust
109
- use skytable :: actions :: Actions ;
110
- use skytable :: sync :: Connection ;
111
- use skytable :: types :: RawString ;
112
-
113
- let mut con = Connection :: new (" 127.0.0.1" , 2003 ). unwrap ();
114
- let mybinarydata = RawString :: from (vec! [1 , 2 , 3 , 4 ]);
115
- assert! (con . set (" bindata" , mybinarydata ). unwrap ());
116
- ```
44
+ use skytable :: {Config , query};
117
45
118
- ## Going advanced
119
-
120
- Now that you know how you can run basic queries, check out the [ ` actions ` ] module documentation for learning
121
- to use actions and the [ ` types ` ] module documentation for implementing your own Skyhash serializable
122
- types. Need to meddle with DDL queries like creating and dropping tables? Check out the [ ` ddl ` ] module.
123
- You can also find some [ examples here] ( https://github.com/skytable/client-rust/tree/v0.7.0-alpha.4/examples )
124
-
125
- ## Connection pooling
126
-
127
- This library supports using sync/async connection pools. See the [ ` pool ` ] module-level documentation for examples
128
- and information.
129
-
130
- ## Async API
131
-
132
- If you need to use an ` async ` API, just change your import to:
133
-
134
- ``` toml
135
- skytable = { version = " 0.7.0-alpha.4" , features =[" aio" ], default-features = false }
136
- ```
137
-
138
- You can now establish a connection by using ` skytable::AsyncConnection::new() ` , adding ` .await ` s wherever
139
- necessary. Do note that you'll use the [ Tokio runtime] ( https://tokio.rs ) .
140
-
141
- ## Using both ` sync ` and ` async ` APIs
142
-
143
- With this client driver, it is possible to use both sync and ` async ` APIs ** at the same time** . To do
144
- this, simply change your import to:
145
-
146
- ``` toml
147
- skytable = { version =" 0.7.0-alpha.4" , features =[" sync" , " aio" ] }
148
- ```
149
-
150
- ## TLS
151
-
152
- If you need to use TLS features, this crate will let you do so with OpenSSL.
153
-
154
- ### Using TLS with sync interfaces
155
-
156
- ``` toml
157
- skytable = { version =" 0.7.0-alpha.4" , features =[" sync" ," ssl" ] }
158
- ```
159
-
160
- You can now use the async ` sync::TlsConnection ` object.
161
-
162
- ### Using TLS with async interfaces
163
-
164
- ``` toml
165
- skytable = { version =" 0.7.0-alpha.4" , features =[" aio" ," aio-ssl" ], default-features =false }
46
+ let mut db = Config :: new_default (" username" , " password" ). connect (). unwrap ();
47
+ let query = query! (" select username, password from myspace.mytbl WHERE username = ?" , your_fn_to_get_user ());
48
+ let (username , password ) = db . query_parse :: <(String , String )>(& query ). unwrap ();
166
49
```
167
50
168
- You can now use the async ` aio::TlsConnection ` object.
169
-
170
- ### _ Packed TLS_ setup
171
-
172
- If you want to pack OpenSSL with your crate, then for sync add ` sslv ` instead of ` ssl ` or
173
- add ` aio-sslv ` instead of ` aio-ssl ` for async. Adding this will statically link OpenSSL
174
- to your crate. Do note that you'll need a C compiler, GNU Make and Perl to compile OpenSSL
175
- and statically link against it.
176
-
177
- ## MSRV
178
-
179
- The MSRV for this crate is Rust 1.39. Need const generics? Add the ` const-gen ` feature to your
180
- dependency!
51
+ > ** Read [ docs here to learn BlueQL] ( https://docs.skytable.io/ ) **
181
52
182
53
## Contributing
183
54
0 commit comments