veddb_client/
lib.rs

1//! # VedDB Client
2//!
3//! Official Rust client for VedDB - High-performance shared memory KV store with Pub/Sub capabilities.
4//!
5//! ## Features
6//!
7//! - **Synchronous and Asynchronous APIs** - Choose between blocking and non-blocking operations
8//! - **Connection Pooling** - Efficiently manage multiple connections to VedDB servers
9//! - **Automatic Reconnection** - Handle network issues gracefully
10//! - **Pipelining** - Send multiple commands without waiting for responses
11//! - **Pub/Sub Support** - Subscribe to channels and patterns
12//!
13//! ## Example
14//! ```no_run
15//! use veddb_client::{Client, Result};
16//!
17//! #[tokio::main]
18//! async fn main() -> Result<()> {
19//!     // Connect to a VedDB server
20//!     let client = Client::connect("127.0.0.1:50051".parse()?).await?;
21//!     
22//!     // Set a value
23//!     client.set("my_key", "my_value").await?;
24//!     
25//!     // Get a value
26//!     let value: Vec<u8> = client.get("my_key").await?;
27//!     println!("Got value: {:?}", value);
28//!     
29//!     Ok(())
30//! }
31//! ```
32
33#![warn(missing_docs)]
34#![warn(rustdoc::missing_crate_level_docs)]
35#![forbid(unsafe_code)]
36
37mod connection;
38mod error;
39mod types;
40
41pub use connection::{Client, ClientBuilder, Connection, ConnectionPool};
42pub use error::Error;
43pub use types::{Command, Response, StatusCode};
44
45/// Custom result type for VedDB operations
46pub type Result<T> = std::result::Result<T, Error>;
47
48/// Re-export of the `bytes` crate for convenience
49pub use bytes;
50
51/// Re-export of the `tracing` crate for convenience
52#[cfg(feature = "tracing")]
53pub use tracing;
54
55#[cfg(test)]
56mod tests {
57    use super::*;
58
59    #[tokio::test]
60    async fn test_error_conversion() {
61        // Test that we can convert from io::Error
62        let io_error = std::io::Error::new(std::io::ErrorKind::Other, "test");
63        let error: Error = io_error.into();
64        assert!(matches!(error, Error::Io(_)));
65        
66        // Test that we can convert from string
67        let error: Error = "test error".into();
68        assert!(matches!(error, Error::Other(_)));
69    }
70}