cdrs_tokio/
lib.rs

1//! **cdrs** is a native Cassandra DB client written in Rust.
2//!
3//! ## Getting started
4//!
5//! This example configures a cluster consisting of a single node, and uses round-robin load balancing.
6//!
7//! ```no_run
8//! use cdrs_tokio::cluster::session::{TcpSessionBuilder, SessionBuilder};
9//! use cdrs_tokio::cluster::NodeTcpConfigBuilder;
10//! use cdrs_tokio::load_balancing::RoundRobinLoadBalancingStrategy;
11//! use std::sync::Arc;
12//!
13//! #[tokio::main]
14//! async fn main() {
15//!     let cluster_config = NodeTcpConfigBuilder::new()
16//!         .with_contact_point("127.0.0.1:9042".into())
17//!         .build()
18//!         .await
19//!         .unwrap();
20//!     let session = TcpSessionBuilder::new(RoundRobinLoadBalancingStrategy::new(), cluster_config)
21//!         .build()
22//!         .await
23//!         .unwrap();
24//!
25//!     let create_ks = "CREATE KEYSPACE IF NOT EXISTS test_ks WITH REPLICATION = { \
26//!                      'class' : 'SimpleStrategy', 'replication_factor' : 1 };";
27//!     session
28//!         .query(create_ks)
29//!         .await
30//!         .expect("Keyspace create error");
31//! }
32//! ```
33//!
34//! ## Nodes and load balancing
35//!
36//! In order to maximize efficiency, the driver needs to be appropriately configured for given use
37//! case. Please look at available [load balancers](crate::load_balancing) and
38//! [node distance evaluators](crate::load_balancing::node_distance_evaluator) to pick the optimal
39//! solution when building the [`Session`](crate::cluster::session::Session). Topology-aware load
40//! balancing is preferred when dealing with multi-node clusters, otherwise simpler strategies might
41//! prove more efficient.
42
43#[macro_use]
44mod macros;
45
46pub mod cluster;
47pub mod envelope_parser;
48pub mod load_balancing;
49
50pub mod frame_encoding;
51pub mod future;
52pub mod retry;
53pub mod speculative_execution;
54pub mod statement;
55pub mod transport;
56
57pub use cassandra_protocol::authenticators;
58pub use cassandra_protocol::compression;
59pub use cassandra_protocol::consistency;
60pub use cassandra_protocol::error;
61pub use cassandra_protocol::frame;
62pub use cassandra_protocol::query;
63pub use cassandra_protocol::types;
64
65pub type Error = error::Error;
66pub type Result<T> = error::Result<T>;
67
68#[cfg(feature = "derive")]
69pub use cdrs_tokio_helpers_derive::{DbMirror, IntoCdrsValue, TryFromRow, TryFromUdt};