tarantool_rs/
lib.rs

1// TODO:
2//
3// Features:
4//
5// * [ ] connections pooling
6// * [ ] chunked responses (tt feature)
7// * [ ] streaming responses for select
8// * [ ] background schema fetching, reloading and invalidating
9// * [ ] triggers on connection events (connect/disconnect/schema reloading)
10// * [ ] graceful shutdown protocol
11//
12// Other
13//
14// * [ ] check or remove all unsafes, panic
15// * [ ] tests
16// * [ ] bump version to 0.1.0
17// * [ ] remove unused dependencies
18
19//! `tarantool-rs` - Asyncronous Tokio-based client for Tarantool.
20//!
21//! This crate provide async connector and necessary abstractions for interaction with Tarantool instance.
22//!
23//! ## Example
24//!
25//! ```no_run
26//! # use rmpv::Value;
27//! # use serde::Deserialize;
28//! use tarantool_rs::{Connection, ExecutorExt, IteratorType};
29//!
30//! # #[tokio::main]
31//! # async fn main() -> Result<(), anyhow::Error> {
32//! # pretty_env_logger::init();
33//! // Create connection to Tarantool instace
34//! let conn = Connection::builder().build("127.0.0.1:3301").await?;
35//!
36//! // Execute Lua code with one argument, returning this argument
37//! let number: u64 = conn.eval("return ...", (42, )).await?.decode_result()?;
38//! assert_eq!(number, 42);
39//!
40//! // Call Lua function 'rand' (assuming it exists and return 42)
41//! let number: u64 = conn.call("rand", ()).await?.decode_first()?;
42//! assert_eq!(number, 42);
43//!
44//! // Get 'clients' space with 2 fields - 'id' and 'name'
45//! let clients_space = conn.space("clients").await?.expect("Space exists");
46//!
47//! // Insert tuple into 'clients' space
48//! clients_space.insert((1, "John Doe")).await?;
49//!
50//! // Select tuples from clients space using primary index
51//! let clients: Vec<(i64, String)> = clients_space
52//!     .select(None, None, None, (1, ))
53//!     .await?;
54//! # Ok(())
55//! # }
56//! ````
57//!
58//! ## Features
59//!
60//! * [x] authorization
61//! * [x] evaluating Lua expressions
62//! * [x] remote function calling
63//! * [x] CRUD operations
64//! * [x] transaction control (begin/commit/rollback)
65//! * [x] reconnection in background
66//! * [ ] SQL requests
67//! * [ ] chunked responses
68//! * [ ] watchers and events
69//! * [ ] connection pooling
70//! * [ ] automatic schema fetching and reloading
71//! * [ ] graceful shutdown protocol support
72//! * [ ] pre Tarantool 2.10 versions support
73//! * [ ] customizable connection features (streams/watchers/mvcc)
74//! * [ ] custom Tarantool MP types (UUID, ...)
75//! * [ ] ...
76
77pub use rmpv::Value;
78
79#[doc(inline)]
80pub use self::{
81    builder::{ConnectionBuilder, ReconnectInterval},
82    client::*,
83    codec::consts::{IteratorType, TransactionIsolationLevel},
84    errors::Error,
85    tuple::{Tuple, TupleElement},
86};
87
88pub mod errors;
89pub mod utils;
90
91mod builder;
92mod client;
93mod codec;
94mod transport;
95mod tuple;
96
97/// Alias for [`std::result::Result<T, crate::Error>`].
98pub type Result<T> = std::result::Result<T, Error>;