Crate tarantool_rs

source ·
Expand description

tarantool-rs - Asyncronous Tokio-based client for Tarantool.

This crate provide async connector and necessary abstractions for interaction with Tarantool instance.

Example

use tarantool_rs::{Connection, ExecutorExt, IteratorType};

// 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?;

Features

  • authorization
  • evaluating Lua expressions
  • remote function calling
  • CRUD operations
  • transaction control (begin/commit/rollback)
  • 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, …)

Modules

  • Errors module.
  • Schema (spaces and indices) helper types.
  • Various helpers.

Structs

Enums

Traits

  • Type, which can make requests to Tarantool and create streams and transactions.
  • Helper trait around Executor trait, which allows to send specific requests with any type, implementing Execitor trait.
  • Trait, describing type, which can be encoded into MessagePack tuple.

Type Aliases