Expand description
Tarantool C API bindings for Rust. This library contains the following Tarantool API’s:
- Box: spaces, indexes, sequences
- Fibers: fiber attributes, conditional variables, latches, async runtime
- CoIO
- Transactions
- Schema management
- Protocol implementation (net.box): CRUD, stored procedure call, triggers
- Alternative async protocol implementation (network::client): Async, coio based CRUD
- Tuple utils
- Decimal numbers
- Logging (see https://docs.rs/log/)
- Error handling
- Stored procedures
Caution! The library is currently under development. API may be unstable until version 1.0 is released.
§Features
- net_box- Enables protocol implementation (enabled by default)
- schema- Enables schema manipulation utils (WIP as for now)
§Prerequisites
- rustc 1.67.1 or newer
- tarantool 2.2
§Stored procedures
There are several ways Tarantool can call Rust code. It can use either a plugin, a Lua FFI module, or a stored procedure. In this file we only cover the third option, namely Rust stored procedures. Even though Tarantool always treats Rust routines just as “C functions”, we keep on using the “stored procedure” term as an agreed convention and also for historical reasons.
This tutorial contains the following simple steps:
- examples/easy- prints “hello world”;
- examples/harder- decodes a passed parameter value;
- examples/hardest- uses this library to do a DBMS insert;
- examples/read- uses this library to do a DBMS select;
- examples/write- uses this library to do a DBMS replace.
Our examples are a good starting point for users who want to confidently start writing their own stored procedures.
Re-exports§
Modules§
- auth
- clock
- The clockmodule returns time values derived from the Posix / C CLOCK_GETTIME function or equivalent.
- coio
- Cooperative input/output
- datetime
- define_str_ enum 
- error
- Error handling utils.
- ffi
- fiber
- Сooperative multitasking module with optional async runtime.
- index
- Box: indices
- log
- Logging utils. See “log” crate documentation for details
- msgpack
- net_box
- The net_boxmodule contains connector to remote Tarantool server instances via a network.
- network
- Sans-I/O network client for connecting to remote Tarantool server.
- proc
- schema
- sequence
- Box: sequences
- session
- Box: session
- space
- Box: spaces
- sql
- time
- Provides a custom Instantimplementation, based on tarantool fiber API.
- transaction
- Transaction management
- trigger
- tuple
- Tuples
- util
- uuid
- vclock
- Vector clock.
Macros§
- c_ptr
- Returns a *const std::ffi::c_charconstructed from the provided literal with a nul byte appended to the end. Use this to pass static c-strings when working with ffi.
- c_str
- Returns a std::ffi::CStrconstructed from the provided literal with a nul byte appended to the end. Use this when you need a&CStrfrom a string literal.
- define_dlsym_ reloc 
- define_enum_ with_ introspection 
- Auto-generate enum with some introspection facilities, including conversion from integers.
- define_str_ enum 
- Auto-generate enum that maps to a string.
- expr_count 
- offset_of 
- Returns an offset of the struct or tuple member in bytes.
- say_crit 
- say_debug 
- say_error 
- say_fatal 
- say_info 
- say_sys_ error 
- say_verbose 
- say_warn 
- set_and_ get_ error Deprecated 
- Set the last tarantool error and return it immediately.
- set_error 
- Set the last error.
- static_assert 
- static_ref 
- Exists to optimize code burden with access to mutable statics
and avoid annoying warnings by Clippy about in-place dereference.
It is pretty much a addr_of*/&rawwrapper without warnings, so it is developer responsibility to use it correctly, but it is not marked as unsafe in an expansion to prevent silly mistakes and to have an opportunity for reviewers to blame someone easily.
- tuple_from_ box_ api 
- unwrap_ok_ or 
- unwrap_or 
- update
- Update a tuple or index.
- upsert
- Upsert a tuple or index.
Functions§
- lua_state 
- Create a new lua state with an isolated stack. The new state has access to all the global and tarantool data (Lua variables, tables, modules, etc.).
Type Aliases§
Attribute Macros§
- proc
- #[tarantool::proc]is a macro attribute for creating stored procedure functions.