Expand description
An async Tarantool client that speaks the binary protocol natively, is typed end to end, and stays out of your way.
use serde::{Deserialize, Serialize};
use tarant::{Client, Iter, Update};
#[derive(Serialize, Deserialize)]
struct User {
id: u64,
name: String,
age: u32,
}
let client = Client::connect("tarantool://app:secret@127.0.0.1:3301").await?;
let users = client.space::<User>("users");
users.insert(&User { id: 1, name: "ann".into(), age: 30 }).await?;
let ann: Option<User> = users.get(1).await?;
let adults: Vec<User> = users.index("age").select(18).iterator(Iter::Ge).limit(100).await?;
users.update(1, Update::new().set(3, 31)).await?;§How it fits together
- One connection, many requests. A
Clientis a cheap handle onto a background task that owns the socket. Requests are pipelined and matched to replies by theirsync, so concurrent callers never queue behind one another. Cloning aClientshares that connection. - Types at the boundary. A tuple is anything
serdeturns into aMessagePackarray: a struct, a tuple, aVec. Keys (Key), call arguments (Args) and field operations (Update) are checked by the compiler before a byte reaches the wire. - Errors you can branch on. A server rejection arrives as
ServerErrorcarrying the numericErrorCodeand the full error stack — match onErrorCode::TUPLE_FOUND, never on a message string. - Reconnects that keep their promises. A dropped link is re-established
with backoff, the handshake replayed and every
Watcherre-subscribed. Requests that were in flight fail withError::Closed, because the client cannot know whether the server ran them. - Nothing unsafe, nothing hidden.
#![forbid(unsafe_code)], every public item documented, no panics on user input.
§Feature flags
uuid— acceptuuid::Uuiddirectly as a key field.
§Compatibility
Requires Tarantool 3.0 or later for space operations: the client addresses
spaces and indexes by name, which the protocol gained in 3.0, so there is
no schema fetch and no id cache to go stale. Against 2.10–2.11, call,
eval, transactions and watchers still work; Client::server_info
reports what the handshake negotiated.
Re-exports§
Modules§
- sql
- SQL over the binary protocol:
box.executeandbox.prepare, from Rust. - types
- Tarantool’s extension value types:
Decimal,Uuid,Datetime,Interval.
Structs§
- Client
- A connection to a Tarantool instance.
- Connect
Options - Connection settings for a
Client. - Error
Code - A Tarantool error code (
box.error.*,errcode.h). - Index
- A secondary index, reached with
Space::index. - Page
- One page of a
Select::pagewalk: the rows, and where to resume. - Paged
- A
Selectthat will return aPage. Await it. - Push
Call - A running call whose function pushes values before it returns.
- Select
- A select in the making.
- Server
Error - An error raised by the server, decoded from the
MP_ERRORextension. - Server
Info - What the server told us about itself during the handshake.
- Space
- Typed CRUD over one space, addressed by name.
- Stream
- An ordered request sequence, and the scope of an interactive transaction.
- TxOptions
- How a transaction behaves: isolation, and how long the server waits.
- Update
- An ordered list of field operations.
- Watcher
- A live subscription to a broadcast key.
Enums§
- Error
- Every failure a tarant operation can produce.
- Feature
- Protocol features, as listed in
iproto_features.h. - Field
Ref - A field to modify: a 1-based position or a JSON path.
- Isolation
- Isolation level of a stream transaction.
- Iter
- How
selectwalks an index. - Reconnect
- Reconnection policy after the connection is lost.
- Value
- A dynamically typed
MessagePackvalue, re-exported fromrmpv.
Constants§
- DEFAULT_
PORT - Default iproto port.
Traits§
- Args
- Arguments of a stored-procedure call or a Lua
eval. - Key
- A lookup key: one or more field values, in index order.
Type Aliases§
- Result
- A specialised
Resultfor tarant operations.