1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// TODO:
//
// Features:
//
// * [ ] connections pooling
// * [ ] chunked responses (tt feature)
// * [ ] streaming responses for select
// * [ ] background schema fetching, reloading and invalidating
// * [ ] triggers on connection events (connect/disconnect/schema reloading)
// * [ ] graceful shutdown protocol
//
// Other
//
// * [ ] check or remove all unsafes, panic
// * [ ] tests
// * [ ] bump version to 0.1.0
// * [ ] remove unused dependencies

//! `tarantool-rs` - Asyncronous Tokio-based client for Tarantool.
//!
//! This crate provide async connector and necessary abstractions for interaction with Tarantool instance.
//!
//! ## Example
//!
//! ```no_run
//! # use rmpv::Value;
//! # use serde::Deserialize;
//! use tarantool_rs::{Connection, ExecutorExt, IteratorType};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), anyhow::Error> {
//! # pretty_env_logger::init();
//! // Create connection to Tarantool instace
//! let conn = Connection::builder().build("127.0.0.1:3301").await?;
//!
//! // Execute Lua code with one argument, returning this argument
//! let number: u64 = conn.eval("return ...", (42, )).await?.decode_result()?;
//! assert_eq!(number, 42);
//!
//! // Call Lua function 'rand' (assuming it exists and return 42)
//! let number: u64 = conn.call("rand", ()).await?.decode_first()?;
//! assert_eq!(number, 42);
//!
//! // Get 'clients' space with 2 fields - 'id' and 'name'
//! let clients_space = conn.space("clients").await?.expect("Space exists");
//!
//! // Insert tuple into 'clients' space
//! clients_space.insert((1, "John Doe")).await?;
//!
//! // Select tuples from clients space using primary index
//! let clients: Vec<(i64, String)> = clients_space
//!     .select(None, None, None, (1, ))
//!     .await?;
//! # Ok(())
//! # }
//! ````
//!
//! ## Features
//!
//! * [x] authorization
//! * [x] evaluating Lua expressions
//! * [x] remote function calling
//! * [x] CRUD operations
//! * [x] transaction control (begin/commit/rollback)
//! * [x] reconnection in background
//! * [ ] SQL requests
//! * [ ] chunked responses
//! * [ ] watchers and events
//! * [ ] connection pooling
//! * [ ] automatic schema fetching and reloading
//! * [ ] graceful shutdown protocol support
//! * [ ] pre Tarantool 2.10 versions support
//! * [ ] customizable connection features (streams/watchers/mvcc)
//! * [ ] custom Tarantool MP types (UUID, ...)
//! * [ ] ...

pub use rmpv::Value;

#[doc(inline)]
pub use self::{
    builder::{ConnectionBuilder, ReconnectInterval},
    client::*,
    codec::consts::{IteratorType, TransactionIsolationLevel},
    errors::Error,
    tuple::{Tuple, TupleElement},
};

pub mod errors;
pub mod utils;

mod builder;
mod client;
mod codec;
mod transport;
mod tuple;

/// Alias for [`std::result::Result<T, crate::Error>`].
pub type Result<T> = std::result::Result<T, Error>;