tarantool_rs/codec/
consts.rs

1/// IPROTO map keys.
2///
3/// Describes only keys, used in this crate.
4///
5/// See details [here](https://github.com/tarantool/tarantool/blob/master/src/box/iproto_constants.h#L62).
6pub mod keys {
7    pub const REQUEST_TYPE: u8 = 0x00;
8    pub const RESPONSE_CODE: u8 = 0x00;
9    pub const SQL_INFO_ROW_COUNT: u8 = 0x00;
10    pub const SYNC: u8 = 0x01;
11    pub const SCHEMA_VERSION: u8 = 0x05;
12    pub const STREAM_ID: u8 = 0x0a;
13    pub const SPACE_ID: u8 = 0x10;
14    pub const INDEX_ID: u8 = 0x11;
15    pub const LIMIT: u8 = 0x12;
16    pub const OFFSET: u8 = 0x13;
17    pub const ITERATOR: u8 = 0x14;
18    pub const INDEX_BASE: u8 = 0x15;
19    pub const KEY: u8 = 0x20;
20    pub const TUPLE: u8 = 0x21;
21    pub const FUNCTION_NAME: u8 = 0x22;
22    pub const USER_NAME: u8 = 0x23;
23    pub const EXPR: u8 = 0x27;
24    pub const OPS: u8 = 0x28;
25    pub const DATA: u8 = 0x30;
26    pub const ERROR_24: u8 = 0x31;
27    pub const SQL_TEXT: u8 = 0x40;
28    pub const SQL_BIND: u8 = 0x41;
29    pub const SQL_INFO: u8 = 0x42;
30    pub const SQL_STMT_ID: u8 = 0x43;
31    pub const ERROR: u8 = 0x52;
32    pub const VERSION: u8 = 0x54;
33    pub const FEATURES: u8 = 0x55;
34    pub const TIMEOUT: u8 = 0x56;
35    pub const TXN_ISOLATION: u8 = 0x59;
36}
37
38/// Request type constants.
39///
40/// Describes only types, used in this crate.
41///
42/// See details [here](https://github.com/tarantool/tarantool/blob/master/src/box/iproto_constants.h).
43#[derive(Copy, Clone, Debug)]
44#[repr(u8)]
45pub enum RequestType {
46    Ok = 0,
47    Select = 1,
48    Insert = 2,
49    Replace = 3,
50    Update = 4,
51    Delete = 5,
52    /// CALL request - wraps result into [tuple, tuple, ...] format
53    Call16 = 6,
54    Auth = 7,
55    Eval = 8,
56    Upsert = 9,
57    /// CALL request - returns arbitrary MessagePack
58    Call = 10,
59    /// Execute an SQL statement
60    Execute = 11,
61    Nop = 12,
62    Prepare = 13,
63    Begin = 14,
64    Commit = 15,
65    Rollback = 16,
66    Ping = 64,
67    Id = 73,
68    Watch = 74,
69    Unwatch = 75,
70    Event = 76,
71    /// Non-final response type
72    Chunk = 128,
73}
74
75pub mod response_codes {
76    pub const OK: u32 = 0x0;
77    pub const ERROR_RANGE_START: u32 = 0x8000;
78    pub const ERROR_RANGE_END: u32 = 0x8FFF;
79}
80
81/// Transaction isolation level.
82///
83/// See docs [here](https://www.tarantool.io/en/doc/latest/concepts/atomic/txn_mode_mvcc/#txn-mode-mvcc-options).
84#[derive(Copy, Clone, Debug)]
85#[repr(u8)]
86pub enum TransactionIsolationLevel {
87    /// Use the default level from box.cfg (default),
88    Default = 0,
89    /// Read changes that are committed but not confirmed yet.
90    ReadCommited = 1,
91    /// Read confirmed changes.
92    ReadConfirmed = 2,
93    /// Determine isolation level automatically.
94    BestEffort = 3,
95}
96
97impl Default for TransactionIsolationLevel {
98    fn default() -> Self {
99        Self::Default
100    }
101}
102
103/// Iterator type for `select` requests.
104///
105/// For details check Tarantool documantation <https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/pairs/>.
106#[derive(Copy, Clone, Debug)]
107#[repr(u8)]
108pub enum IteratorType {
109    Eq = 0,
110    Req = 1,
111    All = 2,
112    Lt = 3,
113    Le = 4,
114    Ge = 5,
115    Gt = 6,
116    BitsAllSet = 7,
117    BitsAnySet = 8,
118    BitsAlLNotSet = 9,
119    Overlaps = 10,
120    Neighvor = 11,
121}
122
123impl Default for IteratorType {
124    fn default() -> Self {
125        Self::Eq
126    }
127}