World guest
Aggregate imports for components running inside Tarantool.
Consumers may include this world for the complete host API or import individual interfaces directly to keep their contract minimal.
- Imports:
- interface
tarantool:tarantool/types@0.2.0 - interface
tarantool:tarantool/metrics@0.2.0 - interface
tarantool:tarantool/msgpack@0.2.0 - interface
tarantool:tarantool/database@0.2.0 - interface
tarantool:tarantool/log@0.2.0 - interface
tarantool:tarantool/error@0.2.0 - interface
tarantool:tarantool/session@0.2.0 - interface
tarantool:tarantool/transaction@0.2.0 - interface
tarantool:tarantool/index@0.2.0 - interface
tarantool:tarantool/sequence@0.2.0 - interface
tarantool:tarantool/key-def@0.2.0 - interface
tarantool:tarantool/tuple-format@0.2.0 - interface
tarantool:tarantool/box-tuple@0.2.0
- interface
Import interface tarantool:tarantool/types@0.2.0
Types
type msgpack-value
Exactly one complete MessagePack value encoded as bytes.
The byte sequence must contain one value and no trailing bytes. Functions further constrain its shape where required, for example to an array or a map. Values returned by the host are copied into guest-owned memory.
type error-code
u32
Numeric Tarantool error code.
This is the original unsigned code reported by Tarantool, including codes
unknown to this version of the WIT package. Consumers must preserve and
accept any u32 value. Symbolic ER_* names belong to the Tarantool
version that produced the error and are not part of this contract.
record box-error
Represents an error returned by Tarantool operations.
The numeric code is preserved exactly as reported by Tarantool. Consumers must handle codes they do not recognize. No closed error category is included because Tarantool's error set and classifications may evolve.
Record Fields
-
code:error-codeRaw IPROTO or internal Tarantool error code.
-
Human-readable error message.
-
Host-provided error type, for example "ClientError" or "SocketError".
-
Source file where the error originated (if available).
-
Line number in the source file where the error was raised.
record space
Identifies a Tarantool space by its numeric ID.
Record Fields
id:u32Unique identifier of the space.
record index
Identifies a Tarantool index and its parent space.
Record Fields
-
id:u32Index ID within its parent space.
-
Numeric ID of the parent space.
record log-context
Optional guest source location attached to a log message.
Record Fields
-
Name of the source file generating the log.
-
Line number in the source file generating the log.
enum log-level
Defines the severity levels used in Tarantool logging.
See https://www.tarantool.io/en/doc/latest/reference/reference_capi/say/.
Enum Cases
-
Recoverable error.
-
Severe error.
-
Warning.
-
Informational message.
-
Verbose message.
-
Debug-level message.
record session
Represents a client session in Tarantool by its ID.
Record Fields
id:u64Unique session identifier.
enum transaction-isolation
Isolation levels available for Tarantool transactions.
Enum Cases
-
Use Tarantool's configured default isolation level.
-
Let Tarantool choose the isolation level for the transaction.
-
Read only committed, but not unconfirmed changes.
-
Read only confirmed changes.
-
Read only changes confirmed on any cluster node.
enum iterator-type
Iterator types for index scans in Tarantool.
See https://www.tarantool.io/en/doc/latest/reference/reference_capi/box_index/.
Enum Cases
-
Equal.
-
Reverse equal.
-
Full scan (all tuples).
-
Less than.
-
Less than or equal.
-
Greater than or equal.
-
Greater than.
-
Bitmask: all bits set.
-
Bitmask: any bit set.
-
Bitmask: all bits not set.
-
Range overlaps.
-
Spatial index neighbor.
-
Next prefix in ascending order.
-
Previous prefix in descending order.
record sequence
Identifies a sequence that already exists in Tarantool.
The WIT interface changes sequence state but does not create schema objects. See https://www.tarantool.io/en/doc/latest/platform/ddl_dml/sequences/.
Record Fields
id:u32Numeric identifier of the sequence in Tarantool.
flags key-part-flags
Flags used to modify behavior of key parts in index definitions.
Flags members
-
Allows NULL values in this key part.
-
Exclude NULL values when comparing key parts.
enum collation
Built-in Tarantool collation identifiers supported by this contract.
Case ordinals correspond to the built-in IDs in Tarantool's _collation
system space. User-defined collations are outside this closed enum.
Enum Cases
-
0
-
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 (de__phonebook)
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61 (es__traditional)
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73 (fi__phonebook)
-
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
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193 (si__dictionary)
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214 (sv__reformed)
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262 (zh__big5han)
-
263
-
264
-
265 (zh__gb2312han)
-
266
-
267
-
268 (zh__pinyin)
-
269
-
270
-
271 (zh__stroke)
-
272
-
273
-
274 (zh__zhuyin)
-
275
enum field-type
Field types supported by key definitions.
Enum Cases
record key-part
Definition of a single key part in a Tarantool index.
Record Fields
-
Field index in the tuple (0-based).
-
Type required for the selected field.
-
Optional collation name for string comparison.
-
JSON path for multikey indexes (if applicable). If set, `field-type` refers to the nested field type.
-
flags:key-part-flagsNullable/exclude-null flags for this key part.
record box-tuple
Opaque host-issued handle to a Tarantool tuple.
The handle is meaningful only in the component instance that created it.
Consumers must not construct or modify handle values. Each returned
handle owns one reference unless documented otherwise and must be
released with the public release function from the
tarantool:tarantool/box-tuple interface. This is an interface function,
not a method on this record.
Record Fields
record key-def
Opaque host-issued handle to a Tarantool key definition.
The handle is meaningful only in the component instance that created it.
Consumers must not construct or modify handle values. Each returned
handle is owned and must be released with the public release function
from the tarantool:tarantool/key-def interface. This is an interface
function, not a method on this record.
Record Fields
record tuple-format
Opaque host-issued handle to a Tarantool tuple format.
Each box-tuple has an associated tuple-format. The default format
(see tarantool:tarantool/tuple-format::default) is used for tuples not
attached to any space.
The handle is meaningful only in the component instance that created it.
Consumers must not construct or modify handle values. Each returned
handle owns one reference unless documented otherwise and must be
released with the public release function from the
tarantool:tarantool/tuple-format interface. This is an interface
function, not a method on this record.
Record Fields
type tuple-field
A copied tuple field encoded as one complete MessagePack value.
Import interface tarantool:tarantool/metrics@0.2.0
Functions
uptime: func
Returns the current uptime of the instance in seconds.
Corresponds to box.info.uptime.
Returns
- Uptime in seconds as a floating-point value (
f64).
Return values
Import interface tarantool:tarantool/msgpack@0.2.0
Types
type box-error
type msgpack-value
Functions
from-json: func
Converts a JSON value to MessagePack.
The input must contain one JSON value. The output contains the equivalent value encoded as one complete MessagePack value.
Parameters
json: A string containing one valid JSON value.
Returns
- The corresponding MessagePack value.
Errors
- A
box-errorifjsonis malformed or cannot be represented.
Params
Return values
- result<
msgpack-value,box-error>
to-json: func
Converts a MessagePack value to JSON.
Only values representable by the JSON data model are accepted. MessagePack extension values, binary values, and maps with non-string keys may fail. The returned JSON is not a canonical serialization.
Parameters
value: One complete MessagePack value.
Returns
- A string containing the equivalent JSON value.
Errors
- A
box-errorifvalueis malformed or has no JSON representation.
Params
value:msgpack-value
Return values
- result<
string,box-error>
Import interface tarantool:tarantool/database@0.2.0
Types
type space
type box-error
type index
type box-tuple
type msgpack-value
Functions
schema-version: func
Returns the current schema version of the database.
The version changes when Tarantool modifies schema objects such as spaces or indexes.
Returns
- The current unsigned schema version.
Return values
space-by-name: func
Retrieves a space object by its name.
The returned record contains a catalog ID and does not own host state.
Parameters
name: The name of the space to retrieve.
Returns
somewith the space, ornoneif no space has this name.
Params
Return values
index-by-name: func
Retrieves an index object by name within a space.
The returned record contains catalog IDs and does not own host state.
Parameters
space: The space to search within.name: The name of the index to retrieve.
Returns
somewith the index, ornoneif the space has no index with this name.
Params
Return values
insert: func
Inserts a new tuple into a space.
The tuple must be one complete MessagePack array:
[field1, field2, ...].
Parameters
space: The target space.tup: One complete MessagePack array containing the tuple fields.
Returns
- An owned handle to the inserted tuple. The caller must eventually
release it with the public
releasefunction from thetarantool:tarantool/box-tupleinterface.
Params
space:spacetup:msgpack-value
Return values
update: func
Updates an existing tuple by key in the specified index.
keymust be a MessagePack array identifying the tuple, for example[1].opsmust be a MessagePack array of operations, for example[["=", 2, 30]].
Parameters
index: The index to use for locating the tuple.key: One complete MessagePack array containing exactly one item per index part.ops: One complete MessagePack array whose items are update-operation arrays.
Returns
somewith an owned handle to the updated tuple, ornoneif no tuple matches the key. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Params
index:indexkey:msgpack-valueops:msgpack-value
Return values
replace: func
Replaces an existing tuple or inserts a new one.
Parameters
space: The space to operate on.tup: One complete MessagePack array containing the new tuple fields.
Returns
- An owned handle to the replaced tuple. The caller must eventually
release it with the public
releasefunction from thetarantool:tarantool/box-tupleinterface.
Params
space:spacetup:msgpack-value
Return values
upsert: func
Performs an UPSERT operation: update if exists, insert otherwise.
Parameters
index: The index used for key lookup.tup: One complete MessagePack tuple array to insert.ops: One complete MessagePack array whose items are update-operation arrays.
Returns
ok(())after Tarantool applies the upsert.
Errors
- A
box-errorif the tuple, key, or operations are invalid, or if the operation otherwise fails.
Params
index:indextup:msgpack-valueops:msgpack-value
Return values
- result<_,
box-error>
delete: func
Deletes a tuple by key from the specified index.
The key must be encoded as a MessagePack array, for example [1].
Parameters
index: The index used for key lookup.key: One complete MessagePack array containing exactly one item per index part.
Returns
somewith an owned handle to the deleted tuple, ornoneif no tuple matches the key. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Params
index:indexkey:msgpack-value
Return values
truncate: func
Removes all tuples from the space.
This operation is equivalent to SQL's TRUNCATE TABLE.
Parameters
space: The target space to truncate.
Returns
ok(())after the space is empty.
Params
Return values
- result<_,
box-error>
Import interface tarantool:tarantool/log@0.2.0
Types
type log-level
type log-context
Functions
write: func
Writes a message to the Tarantool log.
The interface exposes non-terminating log levels only. Formatting and level-specific convenience helpers belong in guest libraries.
Parameters
level: Message severity.message: Message text.context: Optional guest source location.
Params
level:log-levelmessage:stringcontext: option<log-context>
Import interface tarantool:tarantool/error@0.2.0
Types
type box-error
type error-code
Functions
new: func
Creates a copied error value.
Corresponds to box.error.new{ ... }.
Parameters
code: Raw numeric Tarantool error code. Codes unknown to this WIT package are accepted without remapping.message: The error message.
Returns
- A new
box-errorvalue.
Params
code:error-codemessage:string
Return values
new-with-location: func
Creates a copied error value with a source location.
Corresponds to box.error.new{ ... }.
Parameters
code: Raw numeric Tarantool error code. Codes unknown to this WIT package are accepted without remapping.message: The error message.file: File name.line: Line number in file.
Returns
- A new
box-errorvalue.
Params
code:error-codemessage:stringfile: option<string>line: option<u32>
Return values
set: func
Sets the given error as the current "last error".
Corresponds to box.error.set(err).
Parameters
err: The error to set.
Params
err:box-error
last: func
Returns a copy of the last error in the current execution context.
Corresponds to box.error.last().
Returns none if no error is currently set.
Return values
- option<
box-error>
clear: func
Clears the last error.
Corresponds to box.error.clear().
to-string: func
Formats a box-error value for diagnostics.
Equivalent to tostring(err) in Tarantool.
Parameters
err: The error to stringify.
Returns
- A human-readable string describing the error.
Params
err:box-error
Return values
Import interface tarantool:tarantool/session@0.2.0
Types
type session
type box-error
type msgpack-value
Functions
current: func
Returns the current session.
The record identifies the connection or execution context from which the current code runs. It does not own the session.
Returns
- A
sessionobject representing the current session.
Return values
broadcast: func
Broadcasts a message to all watchers subscribed to the given key.
value is a Lua expression whose evaluated value is passed to
box.broadcast. It is not JSON. Invalid expressions return an error;
callers must not interpolate untrusted text into the expression.
Parameters
key: A string event name to broadcast on.value: A Lua expression, for example"{a = 1}".
Returns
okon success, or abox-erroron failure.
Errors
- A
box-errorif the key or Lua expression is invalid or broadcast fails.
Params
Return values
- result<_,
box-error>
iproto-send: func
Sends a raw IPROTO packet to a specific session.
The header must be one complete MessagePack map. The optional body, when present, must also be one complete MessagePack map.
Parameters
session: Target session to send to.header: MessagePack map containing the request header.body:somewith a MessagePack map, ornoneto omit the body.
Returns
ok(())after the packet is accepted for sending.
Errors
- A
box-errordescribing the failure.
Params
session:sessionheader:msgpack-valuebody: option<msgpack-value>
Return values
- result<_,
box-error>
Import interface tarantool:tarantool/transaction@0.2.0
Types
type box-error
type transaction-isolation
Functions
id: func
Returns the current transaction ID.
A transaction ID is a non-persistent identifier of the current
transaction. Returns none if no transaction is active.
Returns
somewith the unsigned transaction ID, ornone.
Return values
isolation: func
Returns the isolation level of the current transaction.
Returns none if there is no active transaction.
Returns
somewith the current isolation level, ornone.
Return values
- option<
transaction-isolation>
begin: func
Begins a new transaction.
Fails if the current execution context already has an active transaction.
Errors
- A
box-errordescribing the failure.
Return values
- result<_,
box-error>
commit: func
Commits the current transaction.
Finalizes the transaction and applies its changes.
Errors
- A
box-errordescribing the failure.
Return values
- result<_,
box-error>
rollback: func
Rolls back the current transaction.
Discards all changes made within the current transaction.
Errors
- A
box-errordescribing the failure.
Return values
- result<_,
box-error>
set-isolation: func
Sets the isolation level for the current transaction.
Call this before the first DML operation in the transaction.
Parameters
isolation: Atransaction-isolationvalue.
Errors
- A
box-errordescribing the failure.
Params
Return values
- result<_,
box-error>
make-synchronous: func
Requires synchronous replication for the current transaction.
Commit waits for the configured synchronous replication acknowledgements. This function has no effect when no transaction is active.
Import interface tarantool:tarantool/index@0.2.0
Types
type index
type box-error
type box-tuple
type iterator-type
type msgpack-value
resource iterator
Index iterator resource for scanning tuples.
Functions
tuple-count: func
Returns the number of tuples stored in the index.
Parameters
index: The index to query.
Returns
- The number of tuples in the index, or a
box-erroron failure.
Errors
- A
box-errordescribing the failure.
Params
Return values
- result<
u64,box-error>
memory-size: func
Returns the memory size of the index in bytes.
Parameters
index: The index to inspect.
Returns
- Size in bytes, or a
box-error.
Errors
- A
box-errordescribing the failure.
Params
Return values
- result<
u64,box-error>
random: func
Returns a random tuple from the index.
Parameters
index: The index to read from.rnd: A random seed value.
Returns
somewith an owned tuple handle, ornoneif the index is empty. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Errors
- A
box-errordescribing the failure.
Params
Return values
get: func
Gets a tuple by key from the index.
The key must be one complete MessagePack array, for example [1].
Parameters
index: The index to search.key: MessagePack array containing exactly one item per index part.
Returns
somewith an owned tuple handle, ornoneif no tuple matches. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Errors
- A
box-errordescribing the failure.
Params
index:indexkey:msgpack-value
Return values
min: func
Finds the minimal tuple matching the given key.
Parameters
index: The index to search.key: MessagePack array containing zero or more key parts.
Returns
somewith an owned tuple handle, ornoneif no tuple matches. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Errors
- A
box-errordescribing the failure.
Params
index:indexkey:msgpack-value
Return values
max: func
Finds the maximal tuple matching the given key.
Parameters
index: The index to search.key: MessagePack array containing zero or more key parts.
Returns
somewith an owned tuple handle, ornoneif no tuple matches. The caller must release a returned handle with the publicreleasefunction from thetarantool:tarantool/box-tupleinterface.
Errors
- A
box-errordescribing the failure.
Params
index:indexkey:msgpack-value
Return values
count: func
Counts tuples matching a key and iterator mode.
Parameters
index: Index to query.mode: Iterator mode used to match tuples.key: MessagePack array containing zero or more key parts.
Returns
- Count of matching tuples, or an error.
Errors
- A
box-errordescribing the failure.
Params
index:indexmode:iterator-typekey:msgpack-value
Return values
- result<
u64,box-error>
[static]iterator.new: func
Allocates an iterator for the given index.
index: The index to scan.mode: Scan mode (seetarantool:tarantool/types::iterator-type).key: MessagePack array containing zero or more key parts.
Dropping the returned resource releases its host iterator state.
Params
index:indexmode:iterator-typekey:msgpack-value
Return values
[method]iterator.next: func
Advance the iterator and return the next tuple.
Returns some with an owned tuple handle, or none when the
iterator is exhausted. The caller must release a returned handle
with the public release function from the
tarantool:tarantool/box-tuple interface.
Params
self: borrow<iterator>
Return values
Import interface tarantool:tarantool/sequence@0.2.0
Types
type sequence
type box-error
Functions
next: func
Generates the next value of the specified sequence.
This updates the state of the sequence.
Parameters
seq: The target sequence object.
Returns
- The next value of the sequence as
s64.
Errors
- A
box-errordescribing the failure.
Params
seq:sequence
Return values
- result<
s64,box-error>
current: func
Returns the current value of the specified sequence.
Unlike next, this does not increment the sequence. It returns an error
if the sequence has not been advanced or set since creation or reset.
Parameters
seq: The target sequence object.
Returns
- The current value of the sequence as
s64.
Errors
- A
box-errordescribing the failure.
Params
seq:sequence
Return values
- result<
s64,box-error>
set: func
Sets the sequence to a specific value.
Parameters
seq: The target sequence object.value: The new value to assign.
Errors
- A
box-errordescribing the failure.
Params
seq:sequencevalue:s64
Return values
- result<_,
box-error>
reset: func
Resets the sequence to its initial state.
This clears the current value. After a reset, current returns an error
until next or set assigns another value.
Parameters
seq: The target sequence object.
Errors
- A
box-errordescribing the failure.
Params
seq:sequence
Return values
- result<_,
box-error>
Import interface tarantool:tarantool/key-def@0.2.0
Types
type box-error
type box-tuple
type key-def
type key-part
type msgpack-value
Functions
new: func
Creates a new key definition from a list of parts.
Each key part selects a tuple field and defines its type, optional collation, optional path, and flags.
Parameters
parts: List ofkey-partobjects.
Returns
- A new owned
key-defhandle on success. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
parts: list<key-part>
Return values
duplicate: func
Creates a deep copy of the given key definition.
The returned key-def is independent of the original and owns one
reference.
Parameters
key-def: The key definition to duplicate.
Returns
- A new owned
key-defhandle independent of the original. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
Return values
merge: func
Merges two key definitions into one.
Fields from the right-hand side are appended when they do not duplicate fields from the left-hand side.
Parameters
left: The base key definition.right: The key definition to append fields from.
Returns
- A new owned
key-defhandle. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
Return values
release: func
Releases a key definition and invalidates all aliases of its handle.
Call this once for every key definition returned by new,
duplicate, or merge. Releasing a stale handle traps.
Parameters
key-def: The key definition to release.
Params
dump-parts: func
Returns a list of key parts from a given key definition.
The returned list is copied into guest-owned memory.
Parameters
key-def: The key definition to inspect.
Returns
- List of
key-partobjects.
Errors
- A
box-errordescribing the failure.
Params
Return values
validate-key: func
Validates whether a given key conforms to the key definition.
Checks the number of fields and their types, allowing partial matches (e.g. prefix of the full key).
Parameters
key-def: Key definition to validate against.key: One complete MessagePack array of key parts.
Returns
okif the key conforms to the definition.
Errors
- A
box-errordescribing the failure.
Params
key-def:key-defkey:msgpack-value
Return values
- result<_,
box-error>
validate-full-key: func
Validates whether a key fully matches the key definition.
Differs from validate-key by requiring exact number of parts.
Parameters
key-def: Key definition to validate against.key: One complete MessagePack array with exactly one item per key part.
Returns
okif the key fully conforms to the definition.
Errors
- A
box-errordescribing the failure.
Params
key-def:key-defkey:msgpack-value
Return values
- result<_,
box-error>
part-count: func
Returns the number of parts in the key definition.
Each part corresponds to one field used in index comparison or validation.
Parameters
key-def: The key definition.
Returns
- Number of parts as
u32.
Errors
- A
box-errordescribing the failure.
Params
Return values
- result<
u32,box-error>
extract-key: func
Extracts a key from a given tuple based on the key definition.
The result is a MessagePack-encoded byte buffer representing the key, constructed by selecting fields from the input tuple as defined by the provided key definition.
This buffer can be decoded using a MessagePack decoder and will contain an array of fields corresponding to the key parts.
Parameters
Returns
- One complete MessagePack array containing the extracted key fields.
Errors
- Returns a
box-errorif the tuple is invalid or extraction fails.
Params
Return values
- result<
msgpack-value,box-error>
validate-tuple: func
Validates whether the tuple contains all required fields and types as specified by the key definition.
This is useful to check if a box-tuple is compatible with an index.
Parameters
Returns
okif the tuple satisfies the key definition.
A tuple that does not satisfy the definition is returned as a
box-error; it is not a normal boolean result.
Params
Return values
- result<_,
box-error>
Import interface tarantool:tarantool/tuple-format@0.2.0
Types
type key-def
type box-error
type tuple-format
Functions
default: func
Returns the default tuple format.
This format is used to create tuples not bound to any specific space.
Returns
- An owned
tuple-formathandle. The caller must eventually release it with the publicreleasefunction in this interface.
Return values
new: func
Creates a new tuple format based on a list of key definitions.
Key definitions supply field types, paths, collations, and nullability constraints.
Parameters
key-defs: Borrowed key-definition handles used only for this call. The returned format remains valid after the inputs are released.
Returns
- A new owned
tuple-formathandle. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
key-defs: list<key-def>
Return values
- result<
tuple-format,box-error>
retain: func
Increments the reference counter of the tuple format.
Call this to acquire one additional ownership reference for the same handle. Copying the handle alone does not acquire a reference.
Parameters
tf: Tuple format to retain.
Params
tf:tuple-format
release: func
Decrements the reference counter of the tuple format.
Must be called once for every owned reference. The final release
invalidates all aliases of the handle. Releasing a stale handle traps.
Parameters
tf: Tuple format to release.
Params
tf:tuple-format
Import interface tarantool:tarantool/box-tuple@0.2.0
Types
type box-error
type box-tuple
type tuple-field
type tuple-format
type key-def
type msgpack-value
resource iterator
Stateful traversal over the top-level fields of one tuple.
Functions
new: func
Creates a new tuple from MessagePack data using the default tuple format.
The data must be a MessagePack-encoded array (for example,
[1, "abc", {"x": 42}]).
Parameters
data: One complete MessagePack array containing the tuple fields.
Returns
- A new owned
box-tuplehandle, orbox-error. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
data:msgpack-value
Return values
retain: func
Increases the reference count of the tuple.
Call this to acquire one additional ownership reference for the same handle. Copying the handle alone does not acquire a reference.
Parameters
t: The tuple to retain.
Params
t:box-tuple
release: func
Decreases the reference count of the tuple.
If the count reaches zero, the handle and all of its aliases become stale. Releasing a stale handle traps.
Parameters
t: The tuple to release.
Params
t:box-tuple
field-count: func
Returns the number of fields in the tuple (i.e., array size).
Parameters
t: The tuple.
Returns
- Field count as
u32.
Params
t:box-tuple
Return values
byte-size: func
Returns the byte size of the internal MessagePack data.
Useful for buffer allocations.
Parameters
t: The tuple.
Returns
- Number of bytes used as
u64.
Params
t:box-tuple
Return values
to-bytes: func
Serializes the tuple to a MessagePack byte array.
This data can be passed to the public to-json function from the
tarantool:tarantool/msgpack interface or to another MessagePack
decoder.
Parameters
t: The tuple.
Returns
- One complete MessagePack array containing the tuple fields.
Errors
- A
box-errordescribing the failure.
Params
t:box-tuple
Return values
- result<
msgpack-value,box-error>
format: func
Returns the format object associated with the tuple.
Parameters
t: The tuple.
Returns
- An owned handle to the
tuple-formatused to construct the tuple. The caller must eventually release it with the publicreleasefunction from thetarantool:tarantool/tuple-formatinterface.
Params
t:box-tuple
Return values
field: func
Returns the field at the specified index (zero-based).
The returned value contains one complete copied MessagePack value.
Parameters
t: The tuple.idx: Field index (starting from 0).
Returns
somewith a copied field, ornoneifidxis out of range.
Errors
- A
box-errordescribing the failure.
Params
t:box-tupleidx:u32
Return values
- result<option<
tuple-field>,box-error>
field-by-path: func
Returns a copied field selected by a JSON path expression.
Parameters
t: The tuple.path: Path expression (e.g.,"[2].x"). Array indexes in the path are zero-based.
Returns
somewith a copied field, ornoneif the path selects no field.
Errors
- A
box-errordescribing the failure.
Params
t:box-tuplepath:string
Return values
- result<option<
tuple-field>,box-error>
update: func
Updates fields in a tuple using the given update expression.
The expression must be a MessagePack array of operation arrays, for
example [["=", 1, "new_value"]]. Operation field indexes are
zero-based. The original tuple is unchanged.
Parameters
t: The tuple to update.expr: One complete MessagePack array whose items are update-operation arrays.
Returns
- A new owned
box-tuplehandle with applied updates, or abox-error. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
t:box-tupleexpr:msgpack-value
Return values
upsert: func
Applies update operations while ignoring client-operation errors.
Valid operations are applied to a copy of the tuple. Invalid operations,
such as a type mismatch or missing field, are skipped and may be logged
by Tarantool. System failures still return box-error. Despite its
name, this function does not insert a tuple into a space. The original
tuple is unchanged.
Parameters
t: The tuple.expr: One complete MessagePack array whose items are update-operation arrays.
Returns
- A new owned
box-tuplehandle with the result, or abox-error. The caller must eventually release it with the publicreleasefunction in this interface.
Errors
- A
box-errordescribing the failure.
Params
t:box-tupleexpr:msgpack-value
Return values
validate: func
Validates a tuple against the given format.
Checks field types and nullability constraints.
Parameters
t: The tuple to validate.format: Tuple format to validate against.
Returns
okif the tuple conforms to the format.
A tuple that does not conform is returned as a box-error; it is not a
normal boolean result.
Errors
- A
box-errordescribing the failure.
Params
Return values
- result<_,
box-error>
compare: func
Compares two tuples using a given key definition.
The comparison is lexicographical by key fields.
Parameters
key-def: Definition of fields to compare.left: First tuple.right: Second tuple.
Returns
0if equal<0ifleft < right>0ifleft > right
Params
Return values
compare-with-key: func
Compares a tuple with a key using the given key definition.
Parameters
tuple: Tuple to compare.key: One complete MessagePack array of key parts.key-def: Key definition.
Returns
0if key matches tuple<0if tuple < key>0if tuple > key
Errors
- A
box-errorifkeyis malformed, does not match the key definition, or cannot be compared.
Params
tuple:box-tuplekey:msgpack-valuekey-def:key-def
Return values
- result<
s32,box-error>
[static]iterator.new: func
Creates a new iterator over the fields of a tuple.
This allows sequential or random access to MessagePack fields within the tuple.
Parameters
tuple: Borrowed for this call. The returned iterator retains the tuple independently, so the caller may release its tuple handle after this function returns.
Returns
- A new
iteratorresource, or abox-error. Dropping the iterator releases its retained tuple reference.
Errors
- A
box-errordescribing the failure.
Params
tuple:box-tuple
Return values
[method]iterator.position: func
Returns the current iterator position (index of the next field).
Returns
- The next field index (zero-based).
Params
self: borrow<iterator>
Return values
[method]iterator.rewind: func
Rewinds the iterator to the beginning of the tuple.
After this call, the next field will be the first.
Params
self: borrow<iterator>
[method]iterator.seek: func
Seeks to and returns a field at the given tuple index.
After a successful call, position points to the following field,
so the next call to next continues after the returned value.
Parameters
pos: Zero-based field index to seek to.
Returns
somewith a copied field, ornoneifposis outside the tuple.
Errors
- A
box-errordescribing the failure.
Params
self: borrow<iterator>pos:u32
Return values
- result<option<
tuple-field>,box-error>
[method]iterator.next: func
Returns the next field in the tuple.
Returns none if there are no more fields.
Returns
somecontaining a copiedtuple-field, ornonewhen the iterator is exhausted.
Errors
- A
box-errordescribing the failure.
Params
self: borrow<iterator>
Return values
- result<option<
tuple-field>,box-error>