Skip to main content

ember_client/
lib.rs

1//! ember-client: async Rust client for ember.
2//!
3//! Connects to an ember server over TCP (or TLS) and exposes a typed async
4//! API covering all common commands. Raw RESP3 frames are available via
5//! [`Client::send`] when you need something not covered by the typed methods.
6//!
7//! # Quick start
8//!
9//! ```no_run
10//! use ember_client::Client;
11//!
12//! #[tokio::main]
13//! async fn main() -> Result<(), ember_client::ClientError> {
14//!     let mut client = Client::connect("127.0.0.1", 6379).await?;
15//!
16//!     client.set("greeting", "hello").await?;
17//!     let value = client.get("greeting").await?;
18//!     println!("{value:?}"); // Some(b"hello")
19//!
20//!     Ok(())
21//! }
22//! ```
23//!
24//! # Pipelining
25//!
26//! Send multiple commands in one round-trip using [`Pipeline`]:
27//!
28//! ```no_run
29//! use ember_client::{Client, Pipeline};
30//!
31//! #[tokio::main]
32//! async fn main() -> Result<(), ember_client::ClientError> {
33//!     let mut client = Client::connect("127.0.0.1", 6379).await?;
34//!
35//!     let frames = client.execute_pipeline(
36//!         Pipeline::new()
37//!             .set("a", "1")
38//!             .set("b", "2")
39//!             .get("a")
40//!             .get("b"),
41//!     ).await?;
42//!
43//!     println!("{} responses", frames.len());
44//!     Ok(())
45//! }
46//! ```
47
48mod commands;
49mod connection;
50mod pipeline;
51pub mod subscriber;
52#[cfg(feature = "tls")]
53pub mod tls;
54#[cfg(feature = "vector")]
55pub mod vector;
56
57pub use commands::{ScanPage, SlowlogEntry};
58pub use connection::{Client, ClientError};
59pub use ember_protocol::types::Frame;
60pub use pipeline::Pipeline;
61pub use subscriber::{Message, Subscriber};
62#[cfg(feature = "tls")]
63pub use tls::TlsClientConfig;
64#[cfg(feature = "vector")]
65pub use vector::SimResult;