Skip to content

Commit 9579655

Browse files
committed
Clean up feature flags
1 parent 3cfd331 commit 9579655

File tree

3 files changed

+107
-74
lines changed

3 files changed

+107
-74
lines changed

src/lib.rs

Lines changed: 61 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
//! # Skytable client [![Crates.io](https://img.shields.io/crates/v/skytable?style=flat-square)](https://crates.io/crates/skytable) [![Test](https://github.com/skytable/client-rust/actions/workflows/test.yml/badge.svg)](https://github.com/skytable/client-rust/actions/workflows/test.yml) [![docs.rs](https://img.shields.io/docsrs/skytable?style=flat-square)](https://docs.rs/skytable) [![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/skytable/client-rust?include_prereleases&style=flat-square)](https://github.com/skytable/client-rust/releases)
2-
//!
2+
//!
33
//! ## Introduction
4-
//!
4+
//!
55
//! This library is the official client for the free and open-source NoSQL database
66
//! [Skytable](https://github.com/skytable/skytable). First, go ahead and install Skytable by
77
//! following the instructions [here](https://docs.skytable.io/getting-started). This library supports
88
//! all Skytable versions that work with the [Skyhash 1.1 Protocol](https://docs.skytable.io/protocol/skyhash).
99
//! This version of the library was tested with the latest Skytable release
1010
//! (release [0.7.2](https://github.com/skytable/skytable/releases/v0.7.2)).
11-
//!
11+
//!
1212
//! ## Features
13-
//!
13+
//!
1414
//! - Sync API
1515
//! - Async API
1616
//! - TLS in both sync/async APIs
1717
//! - Connection pooling for sync/async
1818
//! - Use both sync/async APIs at the same time
1919
//! - Always up-to-date
20-
//!
20+
//!
2121
//! ## Using this library
22-
//!
22+
//!
2323
//! This library only ships with the bare minimum that is required for interacting with Skytable. Once you have
2424
//! Skytable installed and running, you're ready to follow this guide!
25-
//!
25+
//!
2626
//! We'll start by creating a new binary application and then running actions. Create a new binary application
2727
//! by running:
28-
//!
28+
//!
2929
//! ```shell
3030
//! cargo new skyapp
3131
//! ```
32-
//!
32+
//!
3333
//! **Tip**: You can see a full list of the available actions [here](https://docs.skytable.io/actions-overview).
34-
//!
34+
//!
3535
//! First add this to your `Cargo.toml` file:
36-
//!
36+
//!
3737
//! ```toml
3838
//! skytable = "0.7.0-alpha.2"
3939
//! ```
40-
//!
40+
//!
4141
//! Now open up your `src/main.rs` file and establish a connection to the server while also adding some
4242
//! imports:
43-
//!
43+
//!
4444
//! ```no_run
4545
//! use skytable::{Connection, Query, Element};
4646
//! fn main() -> std::io::Result<()> {
4747
//! let mut con = Connection::new("127.0.0.1", 2003)?;
4848
//! Ok(())
4949
//! }
5050
//! ```
51-
//!
51+
//!
5252
//! Now let's run a `Query`! Change the previous code block to:
53-
//!
53+
//!
5454
//! ```no_run
5555
//! use skytable::{error, Connection, Query, Element};
5656
//! fn main() -> Result<(), error::Error> {
@@ -61,132 +61,132 @@
6161
//! Ok(())
6262
//! }
6363
//! ```
64-
//!
64+
//!
6565
//! ## Running actions
66-
//!
66+
//!
6767
//! As noted [below](#binary-data), the default table is a key/value table with a binary key
6868
//! type and a binary value type. Let's go ahead and run some actions (we're assuming you're
6969
//! using the sync API; for async, simply change the import to `use skytable::actions::AsyncActions`).
70-
//!
70+
//!
7171
//! ### `SET`ting a key
72-
//!
72+
//!
7373
//! ```no_run
7474
//! use skytable::actions::Actions;
7575
//! use skytable::sync::Connection;
76-
//!
76+
//!
7777
//! let mut con = Connection::new("127.0.0.1", 2003).unwrap();
7878
//! con.set("hello", "world").unwrap();
7979
//! ```
80-
//!
80+
//!
8181
//! This will set the value of the key `hello` to `world` in the `default:default` entity.
82-
//!
82+
//!
8383
//! ### `GET`ting a key
84-
//!
84+
//!
8585
//! ```no_run
8686
//! use skytable::actions::Actions;
8787
//! use skytable::sync::Connection;
88-
//!
88+
//!
8989
//! let mut con = Connection::new("127.0.0.1", 2003).unwrap();
9090
//! let x: String = con.get("hello").unwrap();
9191
//! assert_eq!(x, "world");
9292
//! ```
93-
//!
93+
//!
9494
//! Way to go &mdash; you're all set! Now go ahead and run more advanced queries!
95-
//!
95+
//!
9696
//! ## Binary data
97-
//!
97+
//!
9898
//! The `default:default` keyspace has the following declaration:
99-
//!
99+
//!
100100
//! ```text
101101
//! Keymap { data:(binstr,binstr), volatile:false }
102102
//! ```
103-
//!
103+
//!
104104
//! This means that the default keyspace is ready to store binary data. Let's say
105105
//! you wanted to `SET` the value of a key called `bindata` to some binary data stored
106106
//! in a `Vec<u8>`. You can achieve this with the `RawString` type:
107-
//!
107+
//!
108108
//! ```no_run
109109
//! use skytable::actions::Actions;
110110
//! use skytable::sync::Connection;
111111
//! use skytable::types::RawString;
112-
//!
112+
//!
113113
//! let mut con = Connection::new("127.0.0.1", 2003).unwrap();
114114
//! let mybinarydata = RawString::from(vec![1, 2, 3, 4]);
115115
//! assert!(con.set("bindata", mybinarydata).unwrap());
116116
//! ```
117-
//!
117+
//!
118118
//! ## Going advanced
119-
//!
119+
//!
120120
//! Now that you know how you can run basic queries, check out the [`actions`] module documentation for learning
121121
//! to use actions and the [`types`] module documentation for implementing your own Skyhash serializable
122122
//! types. Need to meddle with DDL queries like creating and dropping tables? Check out the [`ddl`] module.
123123
//! You can also find some [examples here](https://github.com/skytable/client-rust/tree/v0.7.0-alpha.2/examples)
124-
//!
124+
//!
125125
//! ## Connection pooling
126-
//!
126+
//!
127127
//! This library supports using sync/async connection pools. See the [`pool`] module-level documentation for examples
128128
//! and information.
129-
//!
129+
//!
130130
//! ## Async API
131-
//!
131+
//!
132132
//! If you need to use an `async` API, just change your import to:
133-
//!
133+
//!
134134
//! ```toml
135135
//! skytable = { version = "0.7.0-alpha.2", features=["aio"], default-features = false }
136136
//! ```
137-
//!
137+
//!
138138
//! You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever
139139
//! necessary. Do note that you'll the [Tokio runtime](https://tokio.rs).
140-
//!
140+
//!
141141
//! ## Using both `sync` and `async` APIs
142-
//!
142+
//!
143143
//! With this client driver, it is possible to use both sync and `async` APIs **at the same time**. To do
144144
//! this, simply change your import to:
145-
//!
145+
//!
146146
//! ```toml
147147
//! skytable = { version="0.7.0-alpha.2", features=["sync", "aio"] }
148148
//! ```
149-
//!
149+
//!
150150
//! ## TLS
151-
//!
151+
//!
152152
//! If you need to use TLS features, this crate will let you do so with OpenSSL.
153-
//!
153+
//!
154154
//! ### Using TLS with sync interfaces
155-
//!
155+
//!
156156
//! ```toml
157157
//! skytable = { version="0.7.0-alpha.2", features=["sync","ssl"] }
158158
//! ```
159-
//!
159+
//!
160160
//! You can now use the async `sync::TlsConnection` object.
161-
//!
161+
//!
162162
//! ### Using TLS with async interfaces
163-
//!
163+
//!
164164
//! ```toml
165165
//! skytable = { version="0.7.0-alpha.2", features=["aio","aio-ssl"], default-features=false }
166166
//! ```
167-
//!
167+
//!
168168
//! You can now use the async `aio::TlsConnection` object.
169-
//!
169+
//!
170170
//! ### _Packed TLS_ setup
171-
//!
171+
//!
172172
//! If you want to pack OpenSSL with your crate, then for sync add `sslv` instead of `ssl` or
173173
//! add `aio-sslv` instead of `aio-ssl` for async. Adding this will statically link OpenSSL
174174
//! to your crate. Do note that you'll need a C compiler, GNU Make and Perl to compile OpenSSL
175175
//! and statically link against it.
176-
//!
176+
//!
177177
//! ## MSRV
178-
//!
178+
//!
179179
//! The MSRV for this crate is Rust 1.39. Need const generics? Add the `const-gen` feature to your
180180
//! dependency!
181-
//!
181+
//!
182182
//! ## Contributing
183-
//!
183+
//!
184184
//! Open-source, and contributions ... &mdash; they're always welcome! For ideas and suggestions,
185185
//! [create an issue on GitHub](https://github.com/skytable/client-rust/issues/new) and for patches,
186186
//! fork and open those pull requests [here](https://github.com/skytable/client-rust)!
187-
//!
187+
//!
188188
//! ## License
189-
//!
189+
//!
190190
//! This client library is distributed under the permissive
191191
//! [Apache-2.0 License](https://github.com/skytable/client-rust/blob/next/LICENSE). Now go build great apps!
192192
//!
@@ -217,13 +217,9 @@ mod util;
217217
pub mod actions;
218218
pub mod ddl;
219219
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+
}
227223
pub mod types;
228224
// endof public mods
229225
// private mods

src/pool.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,20 @@
8181
8282
// re-exports
8383
// sync
84-
cfg_sync! {
85-
#[cfg(feature = "pool")]
86-
/// [`r2d2`](https://docs.rs/r2d2)'s error type// async
84+
cfg_sync_pool! {
85+
/// [`r2d2`](https://docs.rs/r2d2)'s error type
8786
pub use r2d2::Error as r2d2Error;
88-
#[cfg(feature = "pool")]
8987
pub use self::sync_impls::Pool;
9088
cfg_sync_ssl_any! {
91-
#[cfg(feature = "pool")]
9289
pub use self::sync_impls::TlsPool;
9390
}
9491
}
9592
// async
96-
cfg_async! {
97-
#[cfg(feature = "aio-pool")]
93+
cfg_async_pool! {
9894
/// [`bb8`](https://docs.rs/bb8)'s error type
9995
pub use bb8::RunError as bb8Error;
100-
#[cfg(feature = "aio-pool")]
10196
pub use self::async_impls::Pool as AsyncPool;
10297
cfg_async_ssl_any! {
103-
#[cfg(feature = "aio-pool")]
10498
pub use self::async_impls::TlsPool as AsyncTlsPool;
10599
}
106100
}

src/util.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ macro_rules! cfg_sync {
8181
};
8282
}
8383

84+
macro_rules! cfg_sync_pool {
85+
($($body:item)*) => {
86+
$(
87+
#[cfg(all(feature = "sync", feature= "pool"))]
88+
#[cfg_attr(docsrs, doc(cfg(all(feature = "sync", feature = "pool"))))]
89+
$body
90+
)*
91+
};
92+
}
93+
8494
macro_rules! cfg_async {
8595
($($body:item)*) => {
8696
$(
@@ -91,6 +101,16 @@ macro_rules! cfg_async {
91101
};
92102
}
93103

104+
macro_rules! cfg_async_pool {
105+
($($body:item)*) => {
106+
$(
107+
#[cfg(all(feature = "aio", feature= "aio-pool"))]
108+
#[cfg_attr(docsrs, doc(cfg(all(feature = "aio", feature = "aio-pool"))))]
109+
$body
110+
)*
111+
};
112+
}
113+
94114
macro_rules! cfg_dbg {
95115
($($body:item)*) => {
96116
$(
@@ -100,3 +120,26 @@ macro_rules! cfg_dbg {
100120
)*
101121
};
102122
}
123+
124+
macro_rules! cfg_pool_any {
125+
($($body:item)*) => {
126+
$(
127+
#[cfg(any(
128+
feature = "sync",
129+
feature = "pool",
130+
feature = "aio",
131+
feature = "aio-pool"
132+
))]
133+
#[cfg_attr(
134+
docsrs,
135+
doc(cfg(any(
136+
feature = "sync",
137+
feature = "pool",
138+
feature = "aio",
139+
feature = "aio-pool"
140+
)))
141+
)]
142+
$body
143+
)*
144+
};
145+
}

0 commit comments

Comments
 (0)