|
1 | 1 | //! # Skytable client [](https://crates.io/crates/skytable) [](https://github.com/skytable/client-rust/actions/workflows/test.yml) [](https://docs.rs/skytable) [](https://github.com/skytable/client-rust/releases) |
2 | | -//! |
| 2 | +//! |
3 | 3 | //! ## Introduction |
4 | | -//! |
| 4 | +//! |
5 | 5 | //! This library is the official client for the free and open-source NoSQL database |
6 | 6 | //! [Skytable](https://github.com/skytable/skytable). First, go ahead and install Skytable by |
7 | 7 | //! following the instructions [here](https://docs.skytable.io/getting-started). This library supports |
8 | 8 | //! all Skytable versions that work with the [Skyhash 1.1 Protocol](https://docs.skytable.io/protocol/skyhash). |
9 | 9 | //! This version of the library was tested with the latest Skytable release |
10 | 10 | //! (release [0.7.2](https://github.com/skytable/skytable/releases/v0.7.2)). |
11 | | -//! |
| 11 | +//! |
12 | 12 | //! ## Features |
13 | | -//! |
| 13 | +//! |
14 | 14 | //! - Sync API |
15 | 15 | //! - Async API |
16 | 16 | //! - TLS in both sync/async APIs |
17 | 17 | //! - Connection pooling for sync/async |
18 | 18 | //! - Use both sync/async APIs at the same time |
19 | 19 | //! - Always up-to-date |
20 | | -//! |
| 20 | +//! |
21 | 21 | //! ## Using this library |
22 | | -//! |
| 22 | +//! |
23 | 23 | //! This library only ships with the bare minimum that is required for interacting with Skytable. Once you have |
24 | 24 | //! Skytable installed and running, you're ready to follow this guide! |
25 | | -//! |
| 25 | +//! |
26 | 26 | //! We'll start by creating a new binary application and then running actions. Create a new binary application |
27 | 27 | //! by running: |
28 | | -//! |
| 28 | +//! |
29 | 29 | //! ```shell |
30 | 30 | //! cargo new skyapp |
31 | 31 | //! ``` |
32 | | -//! |
| 32 | +//! |
33 | 33 | //! **Tip**: You can see a full list of the available actions [here](https://docs.skytable.io/actions-overview). |
34 | | -//! |
| 34 | +//! |
35 | 35 | //! First add this to your `Cargo.toml` file: |
36 | | -//! |
| 36 | +//! |
37 | 37 | //! ```toml |
38 | 38 | //! skytable = "0.7.0-alpha.2" |
39 | 39 | //! ``` |
40 | | -//! |
| 40 | +//! |
41 | 41 | //! Now open up your `src/main.rs` file and establish a connection to the server while also adding some |
42 | 42 | //! imports: |
43 | | -//! |
| 43 | +//! |
44 | 44 | //! ```no_run |
45 | 45 | //! use skytable::{Connection, Query, Element}; |
46 | 46 | //! fn main() -> std::io::Result<()> { |
47 | 47 | //! let mut con = Connection::new("127.0.0.1", 2003)?; |
48 | 48 | //! Ok(()) |
49 | 49 | //! } |
50 | 50 | //! ``` |
51 | | -//! |
| 51 | +//! |
52 | 52 | //! Now let's run a `Query`! Change the previous code block to: |
53 | | -//! |
| 53 | +//! |
54 | 54 | //! ```no_run |
55 | 55 | //! use skytable::{error, Connection, Query, Element}; |
56 | 56 | //! fn main() -> Result<(), error::Error> { |
|
61 | 61 | //! Ok(()) |
62 | 62 | //! } |
63 | 63 | //! ``` |
64 | | -//! |
| 64 | +//! |
65 | 65 | //! ## Running actions |
66 | | -//! |
| 66 | +//! |
67 | 67 | //! As noted [below](#binary-data), the default table is a key/value table with a binary key |
68 | 68 | //! type and a binary value type. Let's go ahead and run some actions (we're assuming you're |
69 | 69 | //! using the sync API; for async, simply change the import to `use skytable::actions::AsyncActions`). |
70 | | -//! |
| 70 | +//! |
71 | 71 | //! ### `SET`ting a key |
72 | | -//! |
| 72 | +//! |
73 | 73 | //! ```no_run |
74 | 74 | //! use skytable::actions::Actions; |
75 | 75 | //! use skytable::sync::Connection; |
76 | | -//! |
| 76 | +//! |
77 | 77 | //! let mut con = Connection::new("127.0.0.1", 2003).unwrap(); |
78 | 78 | //! con.set("hello", "world").unwrap(); |
79 | 79 | //! ``` |
80 | | -//! |
| 80 | +//! |
81 | 81 | //! This will set the value of the key `hello` to `world` in the `default:default` entity. |
82 | | -//! |
| 82 | +//! |
83 | 83 | //! ### `GET`ting a key |
84 | | -//! |
| 84 | +//! |
85 | 85 | //! ```no_run |
86 | 86 | //! use skytable::actions::Actions; |
87 | 87 | //! use skytable::sync::Connection; |
88 | | -//! |
| 88 | +//! |
89 | 89 | //! let mut con = Connection::new("127.0.0.1", 2003).unwrap(); |
90 | 90 | //! let x: String = con.get("hello").unwrap(); |
91 | 91 | //! assert_eq!(x, "world"); |
92 | 92 | //! ``` |
93 | | -//! |
| 93 | +//! |
94 | 94 | //! Way to go — you're all set! Now go ahead and run more advanced queries! |
95 | | -//! |
| 95 | +//! |
96 | 96 | //! ## Binary data |
97 | | -//! |
| 97 | +//! |
98 | 98 | //! The `default:default` keyspace has the following declaration: |
99 | | -//! |
| 99 | +//! |
100 | 100 | //! ```text |
101 | 101 | //! Keymap { data:(binstr,binstr), volatile:false } |
102 | 102 | //! ``` |
103 | | -//! |
| 103 | +//! |
104 | 104 | //! This means that the default keyspace is ready to store binary data. Let's say |
105 | 105 | //! you wanted to `SET` the value of a key called `bindata` to some binary data stored |
106 | 106 | //! in a `Vec<u8>`. You can achieve this with the `RawString` type: |
107 | | -//! |
| 107 | +//! |
108 | 108 | //! ```no_run |
109 | 109 | //! use skytable::actions::Actions; |
110 | 110 | //! use skytable::sync::Connection; |
111 | 111 | //! use skytable::types::RawString; |
112 | | -//! |
| 112 | +//! |
113 | 113 | //! let mut con = Connection::new("127.0.0.1", 2003).unwrap(); |
114 | 114 | //! let mybinarydata = RawString::from(vec![1, 2, 3, 4]); |
115 | 115 | //! assert!(con.set("bindata", mybinarydata).unwrap()); |
116 | 116 | //! ``` |
117 | | -//! |
| 117 | +//! |
118 | 118 | //! ## Going advanced |
119 | | -//! |
| 119 | +//! |
120 | 120 | //! Now that you know how you can run basic queries, check out the [`actions`] module documentation for learning |
121 | 121 | //! to use actions and the [`types`] module documentation for implementing your own Skyhash serializable |
122 | 122 | //! types. Need to meddle with DDL queries like creating and dropping tables? Check out the [`ddl`] module. |
123 | 123 | //! You can also find some [examples here](https://github.com/skytable/client-rust/tree/v0.7.0-alpha.2/examples) |
124 | | -//! |
| 124 | +//! |
125 | 125 | //! ## Connection pooling |
126 | | -//! |
| 126 | +//! |
127 | 127 | //! This library supports using sync/async connection pools. See the [`pool`] module-level documentation for examples |
128 | 128 | //! and information. |
129 | | -//! |
| 129 | +//! |
130 | 130 | //! ## Async API |
131 | | -//! |
| 131 | +//! |
132 | 132 | //! If you need to use an `async` API, just change your import to: |
133 | | -//! |
| 133 | +//! |
134 | 134 | //! ```toml |
135 | 135 | //! skytable = { version = "0.7.0-alpha.2", features=["aio"], default-features = false } |
136 | 136 | //! ``` |
137 | | -//! |
| 137 | +//! |
138 | 138 | //! You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever |
139 | 139 | //! necessary. Do note that you'll the [Tokio runtime](https://tokio.rs). |
140 | | -//! |
| 140 | +//! |
141 | 141 | //! ## Using both `sync` and `async` APIs |
142 | | -//! |
| 142 | +//! |
143 | 143 | //! With this client driver, it is possible to use both sync and `async` APIs **at the same time**. To do |
144 | 144 | //! this, simply change your import to: |
145 | | -//! |
| 145 | +//! |
146 | 146 | //! ```toml |
147 | 147 | //! skytable = { version="0.7.0-alpha.2", features=["sync", "aio"] } |
148 | 148 | //! ``` |
149 | | -//! |
| 149 | +//! |
150 | 150 | //! ## TLS |
151 | | -//! |
| 151 | +//! |
152 | 152 | //! If you need to use TLS features, this crate will let you do so with OpenSSL. |
153 | | -//! |
| 153 | +//! |
154 | 154 | //! ### Using TLS with sync interfaces |
155 | | -//! |
| 155 | +//! |
156 | 156 | //! ```toml |
157 | 157 | //! skytable = { version="0.7.0-alpha.2", features=["sync","ssl"] } |
158 | 158 | //! ``` |
159 | | -//! |
| 159 | +//! |
160 | 160 | //! You can now use the async `sync::TlsConnection` object. |
161 | | -//! |
| 161 | +//! |
162 | 162 | //! ### Using TLS with async interfaces |
163 | | -//! |
| 163 | +//! |
164 | 164 | //! ```toml |
165 | 165 | //! skytable = { version="0.7.0-alpha.2", features=["aio","aio-ssl"], default-features=false } |
166 | 166 | //! ``` |
167 | | -//! |
| 167 | +//! |
168 | 168 | //! You can now use the async `aio::TlsConnection` object. |
169 | | -//! |
| 169 | +//! |
170 | 170 | //! ### _Packed TLS_ setup |
171 | | -//! |
| 171 | +//! |
172 | 172 | //! If you want to pack OpenSSL with your crate, then for sync add `sslv` instead of `ssl` or |
173 | 173 | //! add `aio-sslv` instead of `aio-ssl` for async. Adding this will statically link OpenSSL |
174 | 174 | //! to your crate. Do note that you'll need a C compiler, GNU Make and Perl to compile OpenSSL |
175 | 175 | //! and statically link against it. |
176 | | -//! |
| 176 | +//! |
177 | 177 | //! ## MSRV |
178 | | -//! |
| 178 | +//! |
179 | 179 | //! The MSRV for this crate is Rust 1.39. Need const generics? Add the `const-gen` feature to your |
180 | 180 | //! dependency! |
181 | | -//! |
| 181 | +//! |
182 | 182 | //! ## Contributing |
183 | | -//! |
| 183 | +//! |
184 | 184 | //! Open-source, and contributions ... — they're always welcome! For ideas and suggestions, |
185 | 185 | //! [create an issue on GitHub](https://github.com/skytable/client-rust/issues/new) and for patches, |
186 | 186 | //! fork and open those pull requests [here](https://github.com/skytable/client-rust)! |
187 | | -//! |
| 187 | +//! |
188 | 188 | //! ## License |
189 | | -//! |
| 189 | +//! |
190 | 190 | //! This client library is distributed under the permissive |
191 | 191 | //! [Apache-2.0 License](https://github.com/skytable/client-rust/blob/next/LICENSE). Now go build great apps! |
192 | 192 | //! |
@@ -217,13 +217,9 @@ mod util; |
217 | 217 | pub mod actions; |
218 | 218 | pub mod ddl; |
219 | 219 | pub mod error; |
220 | | -#[cfg(any( |
221 | | - feature = "sync", |
222 | | - feature = "pool", |
223 | | - feature = "aio", |
224 | | - feature = "aio-pool" |
225 | | -))] |
226 | | -pub mod pool; |
| 220 | +cfg_pool_any! { |
| 221 | + pub mod pool; |
| 222 | +} |
227 | 223 | pub mod types; |
228 | 224 | // endof public mods |
229 | 225 | // private mods |
|
0 commit comments