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