matrix-sdk-python 0.18.0a1__cp314-cp314-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- matrix_sdk_python/__init__.py +23 -0
- matrix_sdk_python/_generated/__init__.py +1 -0
- matrix_sdk_python/_generated/matrix_sdk.py +2533 -0
- matrix_sdk_python/_generated/matrix_sdk_base.py +1061 -0
- matrix_sdk_python/_generated/matrix_sdk_common.py +1101 -0
- matrix_sdk_python/_generated/matrix_sdk_contentscanner.py +942 -0
- matrix_sdk_python/_generated/matrix_sdk_crypto.py +1876 -0
- matrix_sdk_python/_generated/matrix_sdk_ffi.dll +0 -0
- matrix_sdk_python/_generated/matrix_sdk_ffi.py +65464 -0
- matrix_sdk_python/_generated/matrix_sdk_ui.py +1542 -0
- matrix_sdk_python/_version.py +1 -0
- matrix_sdk_python/py.typed +1 -0
- matrix_sdk_python-0.18.0a1.dist-info/METADATA +87 -0
- matrix_sdk_python-0.18.0a1.dist-info/RECORD +16 -0
- matrix_sdk_python-0.18.0a1.dist-info/WHEEL +5 -0
- matrix_sdk_python-0.18.0a1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1542 @@
|
|
|
1
|
+
# This file was autogenerated by some hot garbage in the `uniffi` crate.
|
|
2
|
+
# Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
# Common helper code.
|
|
5
|
+
#
|
|
6
|
+
# Ideally this would live in a separate .py file where it can be unittested etc
|
|
7
|
+
# in isolation, and perhaps even published as a re-useable package.
|
|
8
|
+
#
|
|
9
|
+
# However, it's important that the details of how this helper code works (e.g. the
|
|
10
|
+
# way that different builtin types are passed across the FFI) exactly match what's
|
|
11
|
+
# expected by the rust code on the other side of the interface. In practice right
|
|
12
|
+
# now that means coming from the exact some version of `uniffi` that was used to
|
|
13
|
+
# compile the rust component. The easiest way to ensure this is to bundle the Python
|
|
14
|
+
# helpers directly inline like we're doing here.
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
import ctypes
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
import enum
|
|
22
|
+
import struct
|
|
23
|
+
import contextlib
|
|
24
|
+
import datetime
|
|
25
|
+
import threading
|
|
26
|
+
import itertools
|
|
27
|
+
import traceback
|
|
28
|
+
import typing
|
|
29
|
+
import platform
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Used for default argument values
|
|
33
|
+
_DEFAULT = object() # type: typing.Any
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _UniffiRustBuffer(ctypes.Structure):
|
|
37
|
+
_fields_ = [
|
|
38
|
+
("capacity", ctypes.c_uint64),
|
|
39
|
+
("len", ctypes.c_uint64),
|
|
40
|
+
("data", ctypes.POINTER(ctypes.c_char)),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def default():
|
|
45
|
+
return _UniffiRustBuffer(0, 0, None)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def alloc(size):
|
|
49
|
+
return _uniffi_rust_call(_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_alloc, size)
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def reserve(rbuf, additional):
|
|
53
|
+
return _uniffi_rust_call(_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_reserve, rbuf, additional)
|
|
54
|
+
|
|
55
|
+
def free(self):
|
|
56
|
+
return _uniffi_rust_call(_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_free, self)
|
|
57
|
+
|
|
58
|
+
def __str__(self):
|
|
59
|
+
return "_UniffiRustBuffer(capacity={}, len={}, data={})".format(
|
|
60
|
+
self.capacity,
|
|
61
|
+
self.len,
|
|
62
|
+
self.data[0:self.len]
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
@contextlib.contextmanager
|
|
66
|
+
def alloc_with_builder(*args):
|
|
67
|
+
"""Context-manger to allocate a buffer using a _UniffiRustBufferBuilder.
|
|
68
|
+
|
|
69
|
+
The allocated buffer will be automatically freed if an error occurs, ensuring that
|
|
70
|
+
we don't accidentally leak it.
|
|
71
|
+
"""
|
|
72
|
+
builder = _UniffiRustBufferBuilder()
|
|
73
|
+
try:
|
|
74
|
+
yield builder
|
|
75
|
+
except:
|
|
76
|
+
builder.discard()
|
|
77
|
+
raise
|
|
78
|
+
|
|
79
|
+
@contextlib.contextmanager
|
|
80
|
+
def consume_with_stream(self):
|
|
81
|
+
"""Context-manager to consume a buffer using a _UniffiRustBufferStream.
|
|
82
|
+
|
|
83
|
+
The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't
|
|
84
|
+
leak it even if an error occurs.
|
|
85
|
+
"""
|
|
86
|
+
try:
|
|
87
|
+
s = _UniffiRustBufferStream.from_rust_buffer(self)
|
|
88
|
+
yield s
|
|
89
|
+
if s.remaining() != 0:
|
|
90
|
+
raise RuntimeError(f"junk data left in buffer at end of consume_with_stream {s.remaining()}")
|
|
91
|
+
finally:
|
|
92
|
+
self.free()
|
|
93
|
+
|
|
94
|
+
@contextlib.contextmanager
|
|
95
|
+
def read_with_stream(self):
|
|
96
|
+
"""Context-manager to read a buffer using a _UniffiRustBufferStream.
|
|
97
|
+
|
|
98
|
+
This is like consume_with_stream, but doesn't free the buffer afterwards.
|
|
99
|
+
It should only be used with borrowed `_UniffiRustBuffer` data.
|
|
100
|
+
"""
|
|
101
|
+
s = _UniffiRustBufferStream.from_rust_buffer(self)
|
|
102
|
+
yield s
|
|
103
|
+
if s.remaining() != 0:
|
|
104
|
+
raise RuntimeError(f"junk data left in buffer at end of read_with_stream {s.remaining()}")
|
|
105
|
+
|
|
106
|
+
class _UniffiForeignBytes(ctypes.Structure):
|
|
107
|
+
_fields_ = [
|
|
108
|
+
("len", ctypes.c_int32),
|
|
109
|
+
("data", ctypes.POINTER(ctypes.c_char)),
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
def __str__(self):
|
|
113
|
+
return "_UniffiForeignBytes(len={}, data={})".format(self.len, self.data[0:self.len])
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class _UniffiRustBufferStream:
|
|
117
|
+
"""
|
|
118
|
+
Helper for structured reading of bytes from a _UniffiRustBuffer
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(self, data, len):
|
|
122
|
+
self.data = data
|
|
123
|
+
self.len = len
|
|
124
|
+
self.offset = 0
|
|
125
|
+
|
|
126
|
+
@classmethod
|
|
127
|
+
def from_rust_buffer(cls, buf):
|
|
128
|
+
return cls(buf.data, buf.len)
|
|
129
|
+
|
|
130
|
+
def remaining(self):
|
|
131
|
+
return self.len - self.offset
|
|
132
|
+
|
|
133
|
+
def _unpack_from(self, size, format):
|
|
134
|
+
if self.offset + size > self.len:
|
|
135
|
+
raise InternalError("read past end of rust buffer")
|
|
136
|
+
value = struct.unpack(format, self.data[self.offset:self.offset+size])[0]
|
|
137
|
+
self.offset += size
|
|
138
|
+
return value
|
|
139
|
+
|
|
140
|
+
def read(self, size):
|
|
141
|
+
if self.offset + size > self.len:
|
|
142
|
+
raise InternalError("read past end of rust buffer")
|
|
143
|
+
data = self.data[self.offset:self.offset+size]
|
|
144
|
+
self.offset += size
|
|
145
|
+
return data
|
|
146
|
+
|
|
147
|
+
def read_i8(self):
|
|
148
|
+
return self._unpack_from(1, ">b")
|
|
149
|
+
|
|
150
|
+
def read_u8(self):
|
|
151
|
+
return self._unpack_from(1, ">B")
|
|
152
|
+
|
|
153
|
+
def read_i16(self):
|
|
154
|
+
return self._unpack_from(2, ">h")
|
|
155
|
+
|
|
156
|
+
def read_u16(self):
|
|
157
|
+
return self._unpack_from(2, ">H")
|
|
158
|
+
|
|
159
|
+
def read_i32(self):
|
|
160
|
+
return self._unpack_from(4, ">i")
|
|
161
|
+
|
|
162
|
+
def read_u32(self):
|
|
163
|
+
return self._unpack_from(4, ">I")
|
|
164
|
+
|
|
165
|
+
def read_i64(self):
|
|
166
|
+
return self._unpack_from(8, ">q")
|
|
167
|
+
|
|
168
|
+
def read_u64(self):
|
|
169
|
+
return self._unpack_from(8, ">Q")
|
|
170
|
+
|
|
171
|
+
def read_float(self):
|
|
172
|
+
v = self._unpack_from(4, ">f")
|
|
173
|
+
return v
|
|
174
|
+
|
|
175
|
+
def read_double(self):
|
|
176
|
+
return self._unpack_from(8, ">d")
|
|
177
|
+
|
|
178
|
+
class _UniffiRustBufferBuilder:
|
|
179
|
+
"""
|
|
180
|
+
Helper for structured writing of bytes into a _UniffiRustBuffer.
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
def __init__(self):
|
|
184
|
+
self.rbuf = _UniffiRustBuffer.alloc(16)
|
|
185
|
+
self.rbuf.len = 0
|
|
186
|
+
|
|
187
|
+
def finalize(self):
|
|
188
|
+
rbuf = self.rbuf
|
|
189
|
+
self.rbuf = None
|
|
190
|
+
return rbuf
|
|
191
|
+
|
|
192
|
+
def discard(self):
|
|
193
|
+
if self.rbuf is not None:
|
|
194
|
+
rbuf = self.finalize()
|
|
195
|
+
rbuf.free()
|
|
196
|
+
|
|
197
|
+
@contextlib.contextmanager
|
|
198
|
+
def _reserve(self, num_bytes):
|
|
199
|
+
if self.rbuf.len + num_bytes > self.rbuf.capacity:
|
|
200
|
+
self.rbuf = _UniffiRustBuffer.reserve(self.rbuf, num_bytes)
|
|
201
|
+
yield None
|
|
202
|
+
self.rbuf.len += num_bytes
|
|
203
|
+
|
|
204
|
+
def _pack_into(self, size, format, value):
|
|
205
|
+
with self._reserve(size):
|
|
206
|
+
# XXX TODO: I feel like I should be able to use `struct.pack_into` here but can't figure it out.
|
|
207
|
+
for i, byte in enumerate(struct.pack(format, value)):
|
|
208
|
+
self.rbuf.data[self.rbuf.len + i] = byte
|
|
209
|
+
|
|
210
|
+
def write(self, value):
|
|
211
|
+
with self._reserve(len(value)):
|
|
212
|
+
for i, byte in enumerate(value):
|
|
213
|
+
self.rbuf.data[self.rbuf.len + i] = byte
|
|
214
|
+
|
|
215
|
+
def write_i8(self, v):
|
|
216
|
+
self._pack_into(1, ">b", v)
|
|
217
|
+
|
|
218
|
+
def write_u8(self, v):
|
|
219
|
+
self._pack_into(1, ">B", v)
|
|
220
|
+
|
|
221
|
+
def write_i16(self, v):
|
|
222
|
+
self._pack_into(2, ">h", v)
|
|
223
|
+
|
|
224
|
+
def write_u16(self, v):
|
|
225
|
+
self._pack_into(2, ">H", v)
|
|
226
|
+
|
|
227
|
+
def write_i32(self, v):
|
|
228
|
+
self._pack_into(4, ">i", v)
|
|
229
|
+
|
|
230
|
+
def write_u32(self, v):
|
|
231
|
+
self._pack_into(4, ">I", v)
|
|
232
|
+
|
|
233
|
+
def write_i64(self, v):
|
|
234
|
+
self._pack_into(8, ">q", v)
|
|
235
|
+
|
|
236
|
+
def write_u64(self, v):
|
|
237
|
+
self._pack_into(8, ">Q", v)
|
|
238
|
+
|
|
239
|
+
def write_float(self, v):
|
|
240
|
+
self._pack_into(4, ">f", v)
|
|
241
|
+
|
|
242
|
+
def write_double(self, v):
|
|
243
|
+
self._pack_into(8, ">d", v)
|
|
244
|
+
|
|
245
|
+
def write_c_size_t(self, v):
|
|
246
|
+
self._pack_into(ctypes.sizeof(ctypes.c_size_t) , "@N", v)
|
|
247
|
+
# A handful of classes and functions to support the generated data structures.
|
|
248
|
+
# This would be a good candidate for isolating in its own ffi-support lib.
|
|
249
|
+
|
|
250
|
+
class InternalError(Exception):
|
|
251
|
+
pass
|
|
252
|
+
|
|
253
|
+
class _UniffiRustCallStatus(ctypes.Structure):
|
|
254
|
+
"""
|
|
255
|
+
Error runtime.
|
|
256
|
+
"""
|
|
257
|
+
_fields_ = [
|
|
258
|
+
("code", ctypes.c_int8),
|
|
259
|
+
("error_buf", _UniffiRustBuffer),
|
|
260
|
+
]
|
|
261
|
+
|
|
262
|
+
# These match the values from the uniffi::rustcalls module
|
|
263
|
+
CALL_SUCCESS = 0
|
|
264
|
+
CALL_ERROR = 1
|
|
265
|
+
CALL_UNEXPECTED_ERROR = 2
|
|
266
|
+
|
|
267
|
+
@staticmethod
|
|
268
|
+
def default():
|
|
269
|
+
return _UniffiRustCallStatus(code=_UniffiRustCallStatus.CALL_SUCCESS, error_buf=_UniffiRustBuffer.default())
|
|
270
|
+
|
|
271
|
+
def __str__(self):
|
|
272
|
+
if self.code == _UniffiRustCallStatus.CALL_SUCCESS:
|
|
273
|
+
return "_UniffiRustCallStatus(CALL_SUCCESS)"
|
|
274
|
+
elif self.code == _UniffiRustCallStatus.CALL_ERROR:
|
|
275
|
+
return "_UniffiRustCallStatus(CALL_ERROR)"
|
|
276
|
+
elif self.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
|
|
277
|
+
return "_UniffiRustCallStatus(CALL_UNEXPECTED_ERROR)"
|
|
278
|
+
else:
|
|
279
|
+
return "_UniffiRustCallStatus(<invalid code>)"
|
|
280
|
+
|
|
281
|
+
def _uniffi_rust_call(fn, *args):
|
|
282
|
+
# Call a rust function
|
|
283
|
+
return _uniffi_rust_call_with_error(None, fn, *args)
|
|
284
|
+
|
|
285
|
+
def _uniffi_rust_call_with_error(error_ffi_converter, fn, *args):
|
|
286
|
+
# Call a rust function and handle any errors
|
|
287
|
+
#
|
|
288
|
+
# This function is used for rust calls that return Result<> and therefore can set the CALL_ERROR status code.
|
|
289
|
+
# error_ffi_converter must be set to the _UniffiConverter for the error class that corresponds to the result.
|
|
290
|
+
call_status = _UniffiRustCallStatus.default()
|
|
291
|
+
|
|
292
|
+
args_with_error = args + (ctypes.byref(call_status),)
|
|
293
|
+
result = fn(*args_with_error)
|
|
294
|
+
_uniffi_check_call_status(error_ffi_converter, call_status)
|
|
295
|
+
return result
|
|
296
|
+
|
|
297
|
+
def _uniffi_check_call_status(error_ffi_converter, call_status):
|
|
298
|
+
if call_status.code == _UniffiRustCallStatus.CALL_SUCCESS:
|
|
299
|
+
pass
|
|
300
|
+
elif call_status.code == _UniffiRustCallStatus.CALL_ERROR:
|
|
301
|
+
if error_ffi_converter is None:
|
|
302
|
+
call_status.error_buf.free()
|
|
303
|
+
raise InternalError("_uniffi_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None")
|
|
304
|
+
else:
|
|
305
|
+
raise error_ffi_converter.lift(call_status.error_buf)
|
|
306
|
+
elif call_status.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
|
|
307
|
+
# When the rust code sees a panic, it tries to construct a _UniffiRustBuffer
|
|
308
|
+
# with the message. But if that code panics, then it just sends back
|
|
309
|
+
# an empty buffer.
|
|
310
|
+
if call_status.error_buf.len > 0:
|
|
311
|
+
msg = _UniffiFfiConverterString.lift(call_status.error_buf)
|
|
312
|
+
else:
|
|
313
|
+
msg = "Unknown rust panic"
|
|
314
|
+
raise InternalError(msg)
|
|
315
|
+
else:
|
|
316
|
+
raise InternalError("Invalid _UniffiRustCallStatus code: {}".format(
|
|
317
|
+
call_status.code))
|
|
318
|
+
|
|
319
|
+
def _uniffi_trait_interface_call(call_status, make_call, write_return_value):
|
|
320
|
+
try:
|
|
321
|
+
return write_return_value(make_call())
|
|
322
|
+
except Exception as e:
|
|
323
|
+
call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
|
|
324
|
+
call_status.error_buf = _UniffiFfiConverterString.lower(repr(e))
|
|
325
|
+
|
|
326
|
+
def _uniffi_trait_interface_call_with_error(call_status, make_call, write_return_value, error_type, lower_error):
|
|
327
|
+
try:
|
|
328
|
+
try:
|
|
329
|
+
return write_return_value(make_call())
|
|
330
|
+
except error_type as e:
|
|
331
|
+
call_status.code = _UniffiRustCallStatus.CALL_ERROR
|
|
332
|
+
call_status.error_buf = lower_error(e)
|
|
333
|
+
except Exception as e:
|
|
334
|
+
call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
|
|
335
|
+
call_status.error_buf = _UniffiFfiConverterString.lower(repr(e))
|
|
336
|
+
# Initial value and increment amount for handles.
|
|
337
|
+
# These ensure that Python-generated handles always have the lowest bit set
|
|
338
|
+
_UNIFFI_HANDLEMAP_INITIAL = 1
|
|
339
|
+
_UNIFFI_HANDLEMAP_DELTA = 2
|
|
340
|
+
|
|
341
|
+
class _UniffiHandleMap:
|
|
342
|
+
"""
|
|
343
|
+
A map where inserting, getting and removing data is synchronized with a lock.
|
|
344
|
+
"""
|
|
345
|
+
|
|
346
|
+
def __init__(self):
|
|
347
|
+
# type Handle = int
|
|
348
|
+
self._map = {} # type: Dict[Handle, Any]
|
|
349
|
+
self._lock = threading.Lock()
|
|
350
|
+
self._counter = _UNIFFI_HANDLEMAP_INITIAL
|
|
351
|
+
|
|
352
|
+
def insert(self, obj):
|
|
353
|
+
with self._lock:
|
|
354
|
+
return self._insert(obj)
|
|
355
|
+
|
|
356
|
+
"""Low-level insert, this assumes `self._lock` is held."""
|
|
357
|
+
def _insert(self, obj):
|
|
358
|
+
handle = self._counter
|
|
359
|
+
self._counter += _UNIFFI_HANDLEMAP_DELTA
|
|
360
|
+
self._map[handle] = obj
|
|
361
|
+
return handle
|
|
362
|
+
|
|
363
|
+
def get(self, handle):
|
|
364
|
+
try:
|
|
365
|
+
with self._lock:
|
|
366
|
+
return self._map[handle]
|
|
367
|
+
except KeyError:
|
|
368
|
+
raise InternalError(f"_UniffiHandleMap.get: Invalid handle {handle}")
|
|
369
|
+
|
|
370
|
+
def clone(self, handle):
|
|
371
|
+
try:
|
|
372
|
+
with self._lock:
|
|
373
|
+
obj = self._map[handle]
|
|
374
|
+
return self._insert(obj)
|
|
375
|
+
except KeyError:
|
|
376
|
+
raise InternalError(f"_UniffiHandleMap.clone: Invalid handle {handle}")
|
|
377
|
+
|
|
378
|
+
def remove(self, handle):
|
|
379
|
+
try:
|
|
380
|
+
with self._lock:
|
|
381
|
+
return self._map.pop(handle)
|
|
382
|
+
except KeyError:
|
|
383
|
+
raise InternalError(f"_UniffiHandleMap.remove: Invalid handle: {handle}")
|
|
384
|
+
|
|
385
|
+
def __len__(self):
|
|
386
|
+
return len(self._map)
|
|
387
|
+
# Types conforming to `_UniffiConverterPrimitive` pass themselves directly over the FFI.
|
|
388
|
+
class _UniffiConverterPrimitive:
|
|
389
|
+
@classmethod
|
|
390
|
+
def lift(cls, value):
|
|
391
|
+
return value
|
|
392
|
+
|
|
393
|
+
@classmethod
|
|
394
|
+
def lower(cls, value):
|
|
395
|
+
return value
|
|
396
|
+
|
|
397
|
+
class _UniffiConverterPrimitiveInt(_UniffiConverterPrimitive):
|
|
398
|
+
@classmethod
|
|
399
|
+
def check_lower(cls, value):
|
|
400
|
+
try:
|
|
401
|
+
value = value.__index__()
|
|
402
|
+
except Exception:
|
|
403
|
+
raise TypeError("'{}' object cannot be interpreted as an integer".format(type(value).__name__))
|
|
404
|
+
if not isinstance(value, int):
|
|
405
|
+
raise TypeError("__index__ returned non-int (type {})".format(type(value).__name__))
|
|
406
|
+
if not cls.VALUE_MIN <= value < cls.VALUE_MAX:
|
|
407
|
+
raise ValueError("{} requires {} <= value < {}".format(cls.CLASS_NAME, cls.VALUE_MIN, cls.VALUE_MAX))
|
|
408
|
+
|
|
409
|
+
class _UniffiConverterPrimitiveFloat(_UniffiConverterPrimitive):
|
|
410
|
+
@classmethod
|
|
411
|
+
def check_lower(cls, value):
|
|
412
|
+
try:
|
|
413
|
+
value = value.__float__()
|
|
414
|
+
except Exception:
|
|
415
|
+
raise TypeError("must be real number, not {}".format(type(value).__name__))
|
|
416
|
+
if not isinstance(value, float):
|
|
417
|
+
raise TypeError("__float__ returned non-float (type {})".format(type(value).__name__))
|
|
418
|
+
|
|
419
|
+
# Helper class for wrapper types that will always go through a _UniffiRustBuffer.
|
|
420
|
+
# Classes should inherit from this and implement the `read` and `write` static methods.
|
|
421
|
+
class _UniffiConverterRustBuffer:
|
|
422
|
+
@classmethod
|
|
423
|
+
def lift(cls, rbuf):
|
|
424
|
+
with rbuf.consume_with_stream() as stream:
|
|
425
|
+
return cls.read(stream)
|
|
426
|
+
|
|
427
|
+
@classmethod
|
|
428
|
+
def lower(cls, value):
|
|
429
|
+
with _UniffiRustBuffer.alloc_with_builder() as builder:
|
|
430
|
+
cls.write(value, builder)
|
|
431
|
+
return builder.finalize()
|
|
432
|
+
|
|
433
|
+
# Contains loading, initialization code, and the FFI Function declarations.
|
|
434
|
+
# Define some ctypes FFI types that we use in the library
|
|
435
|
+
|
|
436
|
+
"""
|
|
437
|
+
Function pointer for a Rust task, which a callback function that takes a opaque pointer
|
|
438
|
+
"""
|
|
439
|
+
_UNIFFI_RUST_TASK = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int8)
|
|
440
|
+
|
|
441
|
+
def _uniffi_future_callback_t(return_type):
|
|
442
|
+
"""
|
|
443
|
+
Factory function to create callback function types for async functions
|
|
444
|
+
"""
|
|
445
|
+
return ctypes.CFUNCTYPE(None, ctypes.c_uint64, return_type, _UniffiRustCallStatus)
|
|
446
|
+
|
|
447
|
+
def _uniffi_load_indirect():
|
|
448
|
+
"""
|
|
449
|
+
This is how we find and load the dynamic library provided by the component.
|
|
450
|
+
For now we just look it up by name.
|
|
451
|
+
"""
|
|
452
|
+
if sys.platform == "darwin":
|
|
453
|
+
libname = "lib{}.dylib"
|
|
454
|
+
elif sys.platform.startswith("win"):
|
|
455
|
+
# As of python3.8, ctypes does not seem to search $PATH when loading DLLs.
|
|
456
|
+
# We could use `os.add_dll_directory` to configure the search path, but
|
|
457
|
+
# it doesn't feel right to mess with application-wide settings. Let's
|
|
458
|
+
# assume that the `.dll` is next to the `.py` file and load by full path.
|
|
459
|
+
libname = os.path.join(
|
|
460
|
+
os.path.dirname(__file__),
|
|
461
|
+
"{}.dll",
|
|
462
|
+
)
|
|
463
|
+
else:
|
|
464
|
+
# Anything else must be an ELF platform - Linux, *BSD, Solaris/illumos
|
|
465
|
+
libname = "lib{}.so"
|
|
466
|
+
|
|
467
|
+
libname = libname.format("matrix_sdk_ffi")
|
|
468
|
+
path = os.path.join(os.path.dirname(__file__), libname)
|
|
469
|
+
lib = ctypes.cdll.LoadLibrary(path)
|
|
470
|
+
return lib
|
|
471
|
+
|
|
472
|
+
def _uniffi_check_contract_api_version(lib):
|
|
473
|
+
# Get the bindings contract version from our ComponentInterface
|
|
474
|
+
bindings_contract_version = 30
|
|
475
|
+
# Get the scaffolding contract version by calling the into the dylib
|
|
476
|
+
scaffolding_contract_version = lib.ffi_matrix_sdk_ui_uniffi_contract_version()
|
|
477
|
+
if bindings_contract_version != scaffolding_contract_version:
|
|
478
|
+
raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
|
479
|
+
|
|
480
|
+
def _uniffi_check_api_checksums(lib):
|
|
481
|
+
pass
|
|
482
|
+
|
|
483
|
+
# A ctypes library to expose the extern-C FFI definitions.
|
|
484
|
+
# This is an implementation detail which will be called internally by the public API.
|
|
485
|
+
|
|
486
|
+
_UniffiLib = _uniffi_load_indirect()
|
|
487
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_alloc.argtypes = (
|
|
488
|
+
ctypes.c_uint64,
|
|
489
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
490
|
+
)
|
|
491
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_alloc.restype = _UniffiRustBuffer
|
|
492
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_from_bytes.argtypes = (
|
|
493
|
+
_UniffiForeignBytes,
|
|
494
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
495
|
+
)
|
|
496
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_from_bytes.restype = _UniffiRustBuffer
|
|
497
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_free.argtypes = (
|
|
498
|
+
_UniffiRustBuffer,
|
|
499
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
500
|
+
)
|
|
501
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_free.restype = None
|
|
502
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_reserve.argtypes = (
|
|
503
|
+
_UniffiRustBuffer,
|
|
504
|
+
ctypes.c_uint64,
|
|
505
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
506
|
+
)
|
|
507
|
+
_UniffiLib.ffi_matrix_sdk_ui_rustbuffer_reserve.restype = _UniffiRustBuffer
|
|
508
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8,
|
|
509
|
+
)
|
|
510
|
+
_UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,
|
|
511
|
+
)
|
|
512
|
+
class _UniffiForeignFutureDroppedCallbackStruct(ctypes.Structure):
|
|
513
|
+
_fields_ = [
|
|
514
|
+
("handle", ctypes.c_uint64),
|
|
515
|
+
("free", _UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK),
|
|
516
|
+
]
|
|
517
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u8.argtypes = (
|
|
518
|
+
ctypes.c_uint64,
|
|
519
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
520
|
+
ctypes.c_uint64,
|
|
521
|
+
)
|
|
522
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u8.restype = None
|
|
523
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u8.argtypes = (
|
|
524
|
+
ctypes.c_uint64,
|
|
525
|
+
)
|
|
526
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u8.restype = None
|
|
527
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u8.argtypes = (
|
|
528
|
+
ctypes.c_uint64,
|
|
529
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
530
|
+
)
|
|
531
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u8.restype = ctypes.c_uint8
|
|
532
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u8.argtypes = (
|
|
533
|
+
ctypes.c_uint64,
|
|
534
|
+
)
|
|
535
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u8.restype = None
|
|
536
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i8.argtypes = (
|
|
537
|
+
ctypes.c_uint64,
|
|
538
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
539
|
+
ctypes.c_uint64,
|
|
540
|
+
)
|
|
541
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i8.restype = None
|
|
542
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i8.argtypes = (
|
|
543
|
+
ctypes.c_uint64,
|
|
544
|
+
)
|
|
545
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i8.restype = None
|
|
546
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i8.argtypes = (
|
|
547
|
+
ctypes.c_uint64,
|
|
548
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
549
|
+
)
|
|
550
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i8.restype = ctypes.c_int8
|
|
551
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i8.argtypes = (
|
|
552
|
+
ctypes.c_uint64,
|
|
553
|
+
)
|
|
554
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i8.restype = None
|
|
555
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u16.argtypes = (
|
|
556
|
+
ctypes.c_uint64,
|
|
557
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
558
|
+
ctypes.c_uint64,
|
|
559
|
+
)
|
|
560
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u16.restype = None
|
|
561
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u16.argtypes = (
|
|
562
|
+
ctypes.c_uint64,
|
|
563
|
+
)
|
|
564
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u16.restype = None
|
|
565
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u16.argtypes = (
|
|
566
|
+
ctypes.c_uint64,
|
|
567
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
568
|
+
)
|
|
569
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u16.restype = ctypes.c_uint16
|
|
570
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u16.argtypes = (
|
|
571
|
+
ctypes.c_uint64,
|
|
572
|
+
)
|
|
573
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u16.restype = None
|
|
574
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i16.argtypes = (
|
|
575
|
+
ctypes.c_uint64,
|
|
576
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
577
|
+
ctypes.c_uint64,
|
|
578
|
+
)
|
|
579
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i16.restype = None
|
|
580
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i16.argtypes = (
|
|
581
|
+
ctypes.c_uint64,
|
|
582
|
+
)
|
|
583
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i16.restype = None
|
|
584
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i16.argtypes = (
|
|
585
|
+
ctypes.c_uint64,
|
|
586
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
587
|
+
)
|
|
588
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i16.restype = ctypes.c_int16
|
|
589
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i16.argtypes = (
|
|
590
|
+
ctypes.c_uint64,
|
|
591
|
+
)
|
|
592
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i16.restype = None
|
|
593
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u32.argtypes = (
|
|
594
|
+
ctypes.c_uint64,
|
|
595
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
596
|
+
ctypes.c_uint64,
|
|
597
|
+
)
|
|
598
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u32.restype = None
|
|
599
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u32.argtypes = (
|
|
600
|
+
ctypes.c_uint64,
|
|
601
|
+
)
|
|
602
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u32.restype = None
|
|
603
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u32.argtypes = (
|
|
604
|
+
ctypes.c_uint64,
|
|
605
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
606
|
+
)
|
|
607
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u32.restype = ctypes.c_uint32
|
|
608
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u32.argtypes = (
|
|
609
|
+
ctypes.c_uint64,
|
|
610
|
+
)
|
|
611
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u32.restype = None
|
|
612
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i32.argtypes = (
|
|
613
|
+
ctypes.c_uint64,
|
|
614
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
615
|
+
ctypes.c_uint64,
|
|
616
|
+
)
|
|
617
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i32.restype = None
|
|
618
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i32.argtypes = (
|
|
619
|
+
ctypes.c_uint64,
|
|
620
|
+
)
|
|
621
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i32.restype = None
|
|
622
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i32.argtypes = (
|
|
623
|
+
ctypes.c_uint64,
|
|
624
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
625
|
+
)
|
|
626
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i32.restype = ctypes.c_int32
|
|
627
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i32.argtypes = (
|
|
628
|
+
ctypes.c_uint64,
|
|
629
|
+
)
|
|
630
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i32.restype = None
|
|
631
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u64.argtypes = (
|
|
632
|
+
ctypes.c_uint64,
|
|
633
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
634
|
+
ctypes.c_uint64,
|
|
635
|
+
)
|
|
636
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_u64.restype = None
|
|
637
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u64.argtypes = (
|
|
638
|
+
ctypes.c_uint64,
|
|
639
|
+
)
|
|
640
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_u64.restype = None
|
|
641
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u64.argtypes = (
|
|
642
|
+
ctypes.c_uint64,
|
|
643
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
644
|
+
)
|
|
645
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_u64.restype = ctypes.c_uint64
|
|
646
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u64.argtypes = (
|
|
647
|
+
ctypes.c_uint64,
|
|
648
|
+
)
|
|
649
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_u64.restype = None
|
|
650
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i64.argtypes = (
|
|
651
|
+
ctypes.c_uint64,
|
|
652
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
653
|
+
ctypes.c_uint64,
|
|
654
|
+
)
|
|
655
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_i64.restype = None
|
|
656
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i64.argtypes = (
|
|
657
|
+
ctypes.c_uint64,
|
|
658
|
+
)
|
|
659
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_i64.restype = None
|
|
660
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i64.argtypes = (
|
|
661
|
+
ctypes.c_uint64,
|
|
662
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
663
|
+
)
|
|
664
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_i64.restype = ctypes.c_int64
|
|
665
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i64.argtypes = (
|
|
666
|
+
ctypes.c_uint64,
|
|
667
|
+
)
|
|
668
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_i64.restype = None
|
|
669
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_f32.argtypes = (
|
|
670
|
+
ctypes.c_uint64,
|
|
671
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
672
|
+
ctypes.c_uint64,
|
|
673
|
+
)
|
|
674
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_f32.restype = None
|
|
675
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_f32.argtypes = (
|
|
676
|
+
ctypes.c_uint64,
|
|
677
|
+
)
|
|
678
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_f32.restype = None
|
|
679
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_f32.argtypes = (
|
|
680
|
+
ctypes.c_uint64,
|
|
681
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
682
|
+
)
|
|
683
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_f32.restype = ctypes.c_float
|
|
684
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_f32.argtypes = (
|
|
685
|
+
ctypes.c_uint64,
|
|
686
|
+
)
|
|
687
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_f32.restype = None
|
|
688
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_f64.argtypes = (
|
|
689
|
+
ctypes.c_uint64,
|
|
690
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
691
|
+
ctypes.c_uint64,
|
|
692
|
+
)
|
|
693
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_f64.restype = None
|
|
694
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_f64.argtypes = (
|
|
695
|
+
ctypes.c_uint64,
|
|
696
|
+
)
|
|
697
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_f64.restype = None
|
|
698
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_f64.argtypes = (
|
|
699
|
+
ctypes.c_uint64,
|
|
700
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
701
|
+
)
|
|
702
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_f64.restype = ctypes.c_double
|
|
703
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_f64.argtypes = (
|
|
704
|
+
ctypes.c_uint64,
|
|
705
|
+
)
|
|
706
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_f64.restype = None
|
|
707
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_rust_buffer.argtypes = (
|
|
708
|
+
ctypes.c_uint64,
|
|
709
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
710
|
+
ctypes.c_uint64,
|
|
711
|
+
)
|
|
712
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_rust_buffer.restype = None
|
|
713
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_rust_buffer.argtypes = (
|
|
714
|
+
ctypes.c_uint64,
|
|
715
|
+
)
|
|
716
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_rust_buffer.restype = None
|
|
717
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_rust_buffer.argtypes = (
|
|
718
|
+
ctypes.c_uint64,
|
|
719
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
720
|
+
)
|
|
721
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer
|
|
722
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_rust_buffer.argtypes = (
|
|
723
|
+
ctypes.c_uint64,
|
|
724
|
+
)
|
|
725
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_rust_buffer.restype = None
|
|
726
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_void.argtypes = (
|
|
727
|
+
ctypes.c_uint64,
|
|
728
|
+
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
|
|
729
|
+
ctypes.c_uint64,
|
|
730
|
+
)
|
|
731
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_poll_void.restype = None
|
|
732
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_void.argtypes = (
|
|
733
|
+
ctypes.c_uint64,
|
|
734
|
+
)
|
|
735
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_cancel_void.restype = None
|
|
736
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_void.argtypes = (
|
|
737
|
+
ctypes.c_uint64,
|
|
738
|
+
ctypes.POINTER(_UniffiRustCallStatus),
|
|
739
|
+
)
|
|
740
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_complete_void.restype = None
|
|
741
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_void.argtypes = (
|
|
742
|
+
ctypes.c_uint64,
|
|
743
|
+
)
|
|
744
|
+
_UniffiLib.ffi_matrix_sdk_ui_rust_future_free_void.restype = None
|
|
745
|
+
_UniffiLib.ffi_matrix_sdk_ui_uniffi_contract_version.argtypes = (
|
|
746
|
+
)
|
|
747
|
+
_UniffiLib.ffi_matrix_sdk_ui_uniffi_contract_version.restype = ctypes.c_uint32
|
|
748
|
+
|
|
749
|
+
_uniffi_check_contract_api_version(_UniffiLib)
|
|
750
|
+
# _uniffi_check_api_checksums(_UniffiLib)
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
# Public interface members begin here.
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
class EventItemOrigin(enum.Enum):
|
|
763
|
+
"""
|
|
764
|
+
Where this event came.
|
|
765
|
+
"""
|
|
766
|
+
|
|
767
|
+
LOCAL = 0
|
|
768
|
+
"""
|
|
769
|
+
The event was created locally.
|
|
770
|
+
"""
|
|
771
|
+
|
|
772
|
+
SYNC = 1
|
|
773
|
+
"""
|
|
774
|
+
The event came from a sync response.
|
|
775
|
+
"""
|
|
776
|
+
|
|
777
|
+
PAGINATION = 2
|
|
778
|
+
"""
|
|
779
|
+
The event came from pagination.
|
|
780
|
+
"""
|
|
781
|
+
|
|
782
|
+
CACHE = 3
|
|
783
|
+
"""
|
|
784
|
+
The event came from a cache.
|
|
785
|
+
"""
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
class _UniffiFfiConverterTypeEventItemOrigin(_UniffiConverterRustBuffer):
|
|
790
|
+
@staticmethod
|
|
791
|
+
def read(buf):
|
|
792
|
+
variant = buf.read_i32()
|
|
793
|
+
if variant == 1:
|
|
794
|
+
return EventItemOrigin.LOCAL
|
|
795
|
+
if variant == 2:
|
|
796
|
+
return EventItemOrigin.SYNC
|
|
797
|
+
if variant == 3:
|
|
798
|
+
return EventItemOrigin.PAGINATION
|
|
799
|
+
if variant == 4:
|
|
800
|
+
return EventItemOrigin.CACHE
|
|
801
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
802
|
+
|
|
803
|
+
@staticmethod
|
|
804
|
+
def check_lower(value):
|
|
805
|
+
if value == EventItemOrigin.LOCAL:
|
|
806
|
+
return
|
|
807
|
+
if value == EventItemOrigin.SYNC:
|
|
808
|
+
return
|
|
809
|
+
if value == EventItemOrigin.PAGINATION:
|
|
810
|
+
return
|
|
811
|
+
if value == EventItemOrigin.CACHE:
|
|
812
|
+
return
|
|
813
|
+
raise ValueError(value)
|
|
814
|
+
|
|
815
|
+
@staticmethod
|
|
816
|
+
def write(value, buf):
|
|
817
|
+
if value == EventItemOrigin.LOCAL:
|
|
818
|
+
buf.write_i32(1)
|
|
819
|
+
if value == EventItemOrigin.SYNC:
|
|
820
|
+
buf.write_i32(2)
|
|
821
|
+
if value == EventItemOrigin.PAGINATION:
|
|
822
|
+
buf.write_i32(3)
|
|
823
|
+
if value == EventItemOrigin.CACHE:
|
|
824
|
+
buf.write_i32(4)
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
class LatestEventValueLocalState(enum.Enum):
|
|
834
|
+
|
|
835
|
+
IS_SENDING = 0
|
|
836
|
+
|
|
837
|
+
HAS_BEEN_SENT = 1
|
|
838
|
+
|
|
839
|
+
CANNOT_BE_SENT = 2
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
class _UniffiFfiConverterTypeLatestEventValueLocalState(_UniffiConverterRustBuffer):
|
|
844
|
+
@staticmethod
|
|
845
|
+
def read(buf):
|
|
846
|
+
variant = buf.read_i32()
|
|
847
|
+
if variant == 1:
|
|
848
|
+
return LatestEventValueLocalState.IS_SENDING
|
|
849
|
+
if variant == 2:
|
|
850
|
+
return LatestEventValueLocalState.HAS_BEEN_SENT
|
|
851
|
+
if variant == 3:
|
|
852
|
+
return LatestEventValueLocalState.CANNOT_BE_SENT
|
|
853
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
854
|
+
|
|
855
|
+
@staticmethod
|
|
856
|
+
def check_lower(value):
|
|
857
|
+
if value == LatestEventValueLocalState.IS_SENDING:
|
|
858
|
+
return
|
|
859
|
+
if value == LatestEventValueLocalState.HAS_BEEN_SENT:
|
|
860
|
+
return
|
|
861
|
+
if value == LatestEventValueLocalState.CANNOT_BE_SENT:
|
|
862
|
+
return
|
|
863
|
+
raise ValueError(value)
|
|
864
|
+
|
|
865
|
+
@staticmethod
|
|
866
|
+
def write(value, buf):
|
|
867
|
+
if value == LatestEventValueLocalState.IS_SENDING:
|
|
868
|
+
buf.write_i32(1)
|
|
869
|
+
if value == LatestEventValueLocalState.HAS_BEEN_SENT:
|
|
870
|
+
buf.write_i32(2)
|
|
871
|
+
if value == LatestEventValueLocalState.CANNOT_BE_SENT:
|
|
872
|
+
buf.write_i32(3)
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
class RoomPinnedEventsChange(enum.Enum):
|
|
882
|
+
"""
|
|
883
|
+
The type of change between the previous and current pinned events.
|
|
884
|
+
"""
|
|
885
|
+
|
|
886
|
+
ADDED = 0
|
|
887
|
+
"""
|
|
888
|
+
Only new event ids were added.
|
|
889
|
+
"""
|
|
890
|
+
|
|
891
|
+
REMOVED = 1
|
|
892
|
+
"""
|
|
893
|
+
Only event ids were removed.
|
|
894
|
+
"""
|
|
895
|
+
|
|
896
|
+
CHANGED = 2
|
|
897
|
+
"""
|
|
898
|
+
Some change other than only adding or only removing ids happened.
|
|
899
|
+
"""
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
class _UniffiFfiConverterTypeRoomPinnedEventsChange(_UniffiConverterRustBuffer):
|
|
904
|
+
@staticmethod
|
|
905
|
+
def read(buf):
|
|
906
|
+
variant = buf.read_i32()
|
|
907
|
+
if variant == 1:
|
|
908
|
+
return RoomPinnedEventsChange.ADDED
|
|
909
|
+
if variant == 2:
|
|
910
|
+
return RoomPinnedEventsChange.REMOVED
|
|
911
|
+
if variant == 3:
|
|
912
|
+
return RoomPinnedEventsChange.CHANGED
|
|
913
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
914
|
+
|
|
915
|
+
@staticmethod
|
|
916
|
+
def check_lower(value):
|
|
917
|
+
if value == RoomPinnedEventsChange.ADDED:
|
|
918
|
+
return
|
|
919
|
+
if value == RoomPinnedEventsChange.REMOVED:
|
|
920
|
+
return
|
|
921
|
+
if value == RoomPinnedEventsChange.CHANGED:
|
|
922
|
+
return
|
|
923
|
+
raise ValueError(value)
|
|
924
|
+
|
|
925
|
+
@staticmethod
|
|
926
|
+
def write(value, buf):
|
|
927
|
+
if value == RoomPinnedEventsChange.ADDED:
|
|
928
|
+
buf.write_i32(1)
|
|
929
|
+
if value == RoomPinnedEventsChange.REMOVED:
|
|
930
|
+
buf.write_i32(2)
|
|
931
|
+
if value == RoomPinnedEventsChange.CHANGED:
|
|
932
|
+
buf.write_i32(3)
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
class _UniffiFfiConverterBoolean:
|
|
937
|
+
@classmethod
|
|
938
|
+
def check_lower(cls, value):
|
|
939
|
+
return not not value
|
|
940
|
+
|
|
941
|
+
@classmethod
|
|
942
|
+
def lower(cls, value):
|
|
943
|
+
return 1 if value else 0
|
|
944
|
+
|
|
945
|
+
@staticmethod
|
|
946
|
+
def lift(value):
|
|
947
|
+
return value != 0
|
|
948
|
+
|
|
949
|
+
@classmethod
|
|
950
|
+
def read(cls, buf):
|
|
951
|
+
return cls.lift(buf.read_u8())
|
|
952
|
+
|
|
953
|
+
@classmethod
|
|
954
|
+
def write(cls, value, buf):
|
|
955
|
+
buf.write_u8(value)
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
class SpaceRoomListPaginationState:
|
|
963
|
+
def __init__(self):
|
|
964
|
+
raise RuntimeError("SpaceRoomListPaginationState cannot be instantiated directly")
|
|
965
|
+
|
|
966
|
+
# Each enum variant is a nested class of the enum itself.
|
|
967
|
+
@dataclass
|
|
968
|
+
class IDLE:
|
|
969
|
+
|
|
970
|
+
def __init__(self, end_reached:bool):
|
|
971
|
+
self.end_reached = end_reached
|
|
972
|
+
|
|
973
|
+
|
|
974
|
+
pass
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
def __str__(self):
|
|
981
|
+
return "SpaceRoomListPaginationState.IDLE(end_reached={})".format(self.end_reached)
|
|
982
|
+
def __eq__(self, other):
|
|
983
|
+
if not isinstance(other, SpaceRoomListPaginationState):
|
|
984
|
+
return NotImplemented
|
|
985
|
+
if not other.is_IDLE():
|
|
986
|
+
return False
|
|
987
|
+
if self.end_reached != other.end_reached:
|
|
988
|
+
return False
|
|
989
|
+
return True
|
|
990
|
+
|
|
991
|
+
@dataclass
|
|
992
|
+
class LOADING:
|
|
993
|
+
|
|
994
|
+
def __init__(self, ):
|
|
995
|
+
pass
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
def __str__(self):
|
|
1002
|
+
return "SpaceRoomListPaginationState.LOADING()".format()
|
|
1003
|
+
def __eq__(self, other):
|
|
1004
|
+
if not isinstance(other, SpaceRoomListPaginationState):
|
|
1005
|
+
return NotImplemented
|
|
1006
|
+
if not other.is_LOADING():
|
|
1007
|
+
return False
|
|
1008
|
+
return True
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
# For each variant, we have `is_NAME` and `is_name` methods for easily checking
|
|
1013
|
+
# whether an instance is that variant.
|
|
1014
|
+
def is_IDLE(self) -> bool:
|
|
1015
|
+
return isinstance(self, SpaceRoomListPaginationState.IDLE)
|
|
1016
|
+
def is_idle(self) -> bool:
|
|
1017
|
+
return isinstance(self, SpaceRoomListPaginationState.IDLE)
|
|
1018
|
+
def is_LOADING(self) -> bool:
|
|
1019
|
+
return isinstance(self, SpaceRoomListPaginationState.LOADING)
|
|
1020
|
+
def is_loading(self) -> bool:
|
|
1021
|
+
return isinstance(self, SpaceRoomListPaginationState.LOADING)
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
# Now, a little trick - we make each nested variant class be a subclass of the main
|
|
1025
|
+
# enum class, so that method calls and instance checks etc will work intuitively.
|
|
1026
|
+
# We might be able to do this a little more neatly with a metaclass, but this'll do.
|
|
1027
|
+
SpaceRoomListPaginationState.IDLE = type("SpaceRoomListPaginationState.IDLE", (SpaceRoomListPaginationState.IDLE, SpaceRoomListPaginationState,), {}) # type: ignore
|
|
1028
|
+
SpaceRoomListPaginationState.LOADING = type("SpaceRoomListPaginationState.LOADING", (SpaceRoomListPaginationState.LOADING, SpaceRoomListPaginationState,), {}) # type: ignore
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
class _UniffiFfiConverterTypeSpaceRoomListPaginationState(_UniffiConverterRustBuffer):
|
|
1034
|
+
@staticmethod
|
|
1035
|
+
def read(buf):
|
|
1036
|
+
variant = buf.read_i32()
|
|
1037
|
+
if variant == 1:
|
|
1038
|
+
return SpaceRoomListPaginationState.IDLE(
|
|
1039
|
+
_UniffiFfiConverterBoolean.read(buf),
|
|
1040
|
+
)
|
|
1041
|
+
if variant == 2:
|
|
1042
|
+
return SpaceRoomListPaginationState.LOADING(
|
|
1043
|
+
)
|
|
1044
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
1045
|
+
|
|
1046
|
+
@staticmethod
|
|
1047
|
+
def check_lower(value):
|
|
1048
|
+
if value.is_IDLE():
|
|
1049
|
+
_UniffiFfiConverterBoolean.check_lower(value.end_reached)
|
|
1050
|
+
return
|
|
1051
|
+
if value.is_LOADING():
|
|
1052
|
+
return
|
|
1053
|
+
raise ValueError(value)
|
|
1054
|
+
|
|
1055
|
+
@staticmethod
|
|
1056
|
+
def write(value, buf):
|
|
1057
|
+
if value.is_IDLE():
|
|
1058
|
+
buf.write_i32(1)
|
|
1059
|
+
_UniffiFfiConverterBoolean.write(value.end_reached, buf)
|
|
1060
|
+
if value.is_LOADING():
|
|
1061
|
+
buf.write_i32(2)
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
class ThreadListPaginationState:
|
|
1071
|
+
"""
|
|
1072
|
+
The pagination state of a [`ThreadListService`].
|
|
1073
|
+
"""
|
|
1074
|
+
def __init__(self):
|
|
1075
|
+
raise RuntimeError("ThreadListPaginationState cannot be instantiated directly")
|
|
1076
|
+
|
|
1077
|
+
# Each enum variant is a nested class of the enum itself.
|
|
1078
|
+
@dataclass
|
|
1079
|
+
class IDLE:
|
|
1080
|
+
"""
|
|
1081
|
+
The list is idle (not currently loading).
|
|
1082
|
+
"""
|
|
1083
|
+
|
|
1084
|
+
def __init__(self, end_reached:bool):
|
|
1085
|
+
self.end_reached = end_reached
|
|
1086
|
+
|
|
1087
|
+
"""
|
|
1088
|
+
Whether the end of the thread list has been reached (no more pages
|
|
1089
|
+
to load).
|
|
1090
|
+
"""
|
|
1091
|
+
|
|
1092
|
+
pass
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
def __str__(self):
|
|
1099
|
+
return "ThreadListPaginationState.IDLE(end_reached={})".format(self.end_reached)
|
|
1100
|
+
def __eq__(self, other):
|
|
1101
|
+
if not isinstance(other, ThreadListPaginationState):
|
|
1102
|
+
return NotImplemented
|
|
1103
|
+
if not other.is_IDLE():
|
|
1104
|
+
return False
|
|
1105
|
+
if self.end_reached != other.end_reached:
|
|
1106
|
+
return False
|
|
1107
|
+
return True
|
|
1108
|
+
|
|
1109
|
+
@dataclass
|
|
1110
|
+
class LOADING:
|
|
1111
|
+
"""
|
|
1112
|
+
The list is currently loading the next page.
|
|
1113
|
+
"""
|
|
1114
|
+
|
|
1115
|
+
def __init__(self, ):
|
|
1116
|
+
pass
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
def __str__(self):
|
|
1123
|
+
return "ThreadListPaginationState.LOADING()".format()
|
|
1124
|
+
def __eq__(self, other):
|
|
1125
|
+
if not isinstance(other, ThreadListPaginationState):
|
|
1126
|
+
return NotImplemented
|
|
1127
|
+
if not other.is_LOADING():
|
|
1128
|
+
return False
|
|
1129
|
+
return True
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
# For each variant, we have `is_NAME` and `is_name` methods for easily checking
|
|
1134
|
+
# whether an instance is that variant.
|
|
1135
|
+
def is_IDLE(self) -> bool:
|
|
1136
|
+
return isinstance(self, ThreadListPaginationState.IDLE)
|
|
1137
|
+
def is_idle(self) -> bool:
|
|
1138
|
+
return isinstance(self, ThreadListPaginationState.IDLE)
|
|
1139
|
+
def is_LOADING(self) -> bool:
|
|
1140
|
+
return isinstance(self, ThreadListPaginationState.LOADING)
|
|
1141
|
+
def is_loading(self) -> bool:
|
|
1142
|
+
return isinstance(self, ThreadListPaginationState.LOADING)
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
# Now, a little trick - we make each nested variant class be a subclass of the main
|
|
1146
|
+
# enum class, so that method calls and instance checks etc will work intuitively.
|
|
1147
|
+
# We might be able to do this a little more neatly with a metaclass, but this'll do.
|
|
1148
|
+
ThreadListPaginationState.IDLE = type("ThreadListPaginationState.IDLE", (ThreadListPaginationState.IDLE, ThreadListPaginationState,), {}) # type: ignore
|
|
1149
|
+
ThreadListPaginationState.LOADING = type("ThreadListPaginationState.LOADING", (ThreadListPaginationState.LOADING, ThreadListPaginationState,), {}) # type: ignore
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
class _UniffiFfiConverterTypeThreadListPaginationState(_UniffiConverterRustBuffer):
|
|
1155
|
+
@staticmethod
|
|
1156
|
+
def read(buf):
|
|
1157
|
+
variant = buf.read_i32()
|
|
1158
|
+
if variant == 1:
|
|
1159
|
+
return ThreadListPaginationState.IDLE(
|
|
1160
|
+
_UniffiFfiConverterBoolean.read(buf),
|
|
1161
|
+
)
|
|
1162
|
+
if variant == 2:
|
|
1163
|
+
return ThreadListPaginationState.LOADING(
|
|
1164
|
+
)
|
|
1165
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
1166
|
+
|
|
1167
|
+
@staticmethod
|
|
1168
|
+
def check_lower(value):
|
|
1169
|
+
if value.is_IDLE():
|
|
1170
|
+
_UniffiFfiConverterBoolean.check_lower(value.end_reached)
|
|
1171
|
+
return
|
|
1172
|
+
if value.is_LOADING():
|
|
1173
|
+
return
|
|
1174
|
+
raise ValueError(value)
|
|
1175
|
+
|
|
1176
|
+
@staticmethod
|
|
1177
|
+
def write(value, buf):
|
|
1178
|
+
if value.is_IDLE():
|
|
1179
|
+
buf.write_i32(1)
|
|
1180
|
+
_UniffiFfiConverterBoolean.write(value.end_reached, buf)
|
|
1181
|
+
if value.is_LOADING():
|
|
1182
|
+
buf.write_i32(2)
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
class TimelineEventFocusThreadMode:
|
|
1192
|
+
"""
|
|
1193
|
+
Options for controlling the behaviour of [`TimelineFocus::Event`]
|
|
1194
|
+
for threaded events.
|
|
1195
|
+
"""
|
|
1196
|
+
def __init__(self):
|
|
1197
|
+
raise RuntimeError("TimelineEventFocusThreadMode cannot be instantiated directly")
|
|
1198
|
+
|
|
1199
|
+
# Each enum variant is a nested class of the enum itself.
|
|
1200
|
+
@dataclass
|
|
1201
|
+
class FORCE_THREAD:
|
|
1202
|
+
"""
|
|
1203
|
+
Force the timeline into threaded mode.
|
|
1204
|
+
|
|
1205
|
+
When the focused event is part of a thread, the timeline will be focused
|
|
1206
|
+
on that thread's root. Otherwise, the timeline will treat the target
|
|
1207
|
+
event itself as the thread root. Threaded events will never be
|
|
1208
|
+
hidden.
|
|
1209
|
+
"""
|
|
1210
|
+
|
|
1211
|
+
def __init__(self, ):
|
|
1212
|
+
pass
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
def __str__(self):
|
|
1219
|
+
return "TimelineEventFocusThreadMode.FORCE_THREAD()".format()
|
|
1220
|
+
def __eq__(self, other):
|
|
1221
|
+
if not isinstance(other, TimelineEventFocusThreadMode):
|
|
1222
|
+
return NotImplemented
|
|
1223
|
+
if not other.is_FORCE_THREAD():
|
|
1224
|
+
return False
|
|
1225
|
+
return True
|
|
1226
|
+
|
|
1227
|
+
@dataclass
|
|
1228
|
+
class AUTOMATIC:
|
|
1229
|
+
"""
|
|
1230
|
+
Automatically determine if the target event is part of a thread or not.
|
|
1231
|
+
|
|
1232
|
+
If the event is part of a thread, the timeline
|
|
1233
|
+
will be filtered to on-thread events.
|
|
1234
|
+
"""
|
|
1235
|
+
|
|
1236
|
+
def __init__(self, hide_threaded_events:bool):
|
|
1237
|
+
self.hide_threaded_events = hide_threaded_events
|
|
1238
|
+
|
|
1239
|
+
"""
|
|
1240
|
+
When the target event is not part of a thread, whether to
|
|
1241
|
+
hide in-thread replies from the live timeline.
|
|
1242
|
+
|
|
1243
|
+
Has no effect when the target event is part of a thread.
|
|
1244
|
+
|
|
1245
|
+
This should be set to true when the client can create
|
|
1246
|
+
[`TimelineFocus::Thread`]-focused timelines from the thread roots
|
|
1247
|
+
themselves and doesn't use the [`Self::ForceThread`] mode.
|
|
1248
|
+
"""
|
|
1249
|
+
|
|
1250
|
+
pass
|
|
1251
|
+
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
def __str__(self):
|
|
1257
|
+
return "TimelineEventFocusThreadMode.AUTOMATIC(hide_threaded_events={})".format(self.hide_threaded_events)
|
|
1258
|
+
def __eq__(self, other):
|
|
1259
|
+
if not isinstance(other, TimelineEventFocusThreadMode):
|
|
1260
|
+
return NotImplemented
|
|
1261
|
+
if not other.is_AUTOMATIC():
|
|
1262
|
+
return False
|
|
1263
|
+
if self.hide_threaded_events != other.hide_threaded_events:
|
|
1264
|
+
return False
|
|
1265
|
+
return True
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
# For each variant, we have `is_NAME` and `is_name` methods for easily checking
|
|
1270
|
+
# whether an instance is that variant.
|
|
1271
|
+
def is_FORCE_THREAD(self) -> bool:
|
|
1272
|
+
return isinstance(self, TimelineEventFocusThreadMode.FORCE_THREAD)
|
|
1273
|
+
def is_force_thread(self) -> bool:
|
|
1274
|
+
return isinstance(self, TimelineEventFocusThreadMode.FORCE_THREAD)
|
|
1275
|
+
def is_AUTOMATIC(self) -> bool:
|
|
1276
|
+
return isinstance(self, TimelineEventFocusThreadMode.AUTOMATIC)
|
|
1277
|
+
def is_automatic(self) -> bool:
|
|
1278
|
+
return isinstance(self, TimelineEventFocusThreadMode.AUTOMATIC)
|
|
1279
|
+
|
|
1280
|
+
|
|
1281
|
+
# Now, a little trick - we make each nested variant class be a subclass of the main
|
|
1282
|
+
# enum class, so that method calls and instance checks etc will work intuitively.
|
|
1283
|
+
# We might be able to do this a little more neatly with a metaclass, but this'll do.
|
|
1284
|
+
TimelineEventFocusThreadMode.FORCE_THREAD = type("TimelineEventFocusThreadMode.FORCE_THREAD", (TimelineEventFocusThreadMode.FORCE_THREAD, TimelineEventFocusThreadMode,), {}) # type: ignore
|
|
1285
|
+
TimelineEventFocusThreadMode.AUTOMATIC = type("TimelineEventFocusThreadMode.AUTOMATIC", (TimelineEventFocusThreadMode.AUTOMATIC, TimelineEventFocusThreadMode,), {}) # type: ignore
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
class _UniffiFfiConverterTypeTimelineEventFocusThreadMode(_UniffiConverterRustBuffer):
|
|
1291
|
+
@staticmethod
|
|
1292
|
+
def read(buf):
|
|
1293
|
+
variant = buf.read_i32()
|
|
1294
|
+
if variant == 1:
|
|
1295
|
+
return TimelineEventFocusThreadMode.FORCE_THREAD(
|
|
1296
|
+
)
|
|
1297
|
+
if variant == 2:
|
|
1298
|
+
return TimelineEventFocusThreadMode.AUTOMATIC(
|
|
1299
|
+
_UniffiFfiConverterBoolean.read(buf),
|
|
1300
|
+
)
|
|
1301
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
1302
|
+
|
|
1303
|
+
@staticmethod
|
|
1304
|
+
def check_lower(value):
|
|
1305
|
+
if value.is_FORCE_THREAD():
|
|
1306
|
+
return
|
|
1307
|
+
if value.is_AUTOMATIC():
|
|
1308
|
+
_UniffiFfiConverterBoolean.check_lower(value.hide_threaded_events)
|
|
1309
|
+
return
|
|
1310
|
+
raise ValueError(value)
|
|
1311
|
+
|
|
1312
|
+
@staticmethod
|
|
1313
|
+
def write(value, buf):
|
|
1314
|
+
if value.is_FORCE_THREAD():
|
|
1315
|
+
buf.write_i32(1)
|
|
1316
|
+
if value.is_AUTOMATIC():
|
|
1317
|
+
buf.write_i32(2)
|
|
1318
|
+
_UniffiFfiConverterBoolean.write(value.hide_threaded_events, buf)
|
|
1319
|
+
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
class TimelineEventShieldStateCode(enum.Enum):
|
|
1328
|
+
"""
|
|
1329
|
+
Extends [`ShieldStateCode`] to allow for a `SentInClear` code.
|
|
1330
|
+
"""
|
|
1331
|
+
|
|
1332
|
+
AUTHENTICITY_NOT_GUARANTEED = 0
|
|
1333
|
+
"""
|
|
1334
|
+
Not enough information available to check the authenticity.
|
|
1335
|
+
"""
|
|
1336
|
+
|
|
1337
|
+
UNKNOWN_DEVICE = 1
|
|
1338
|
+
"""
|
|
1339
|
+
The sending device isn't yet known by the Client.
|
|
1340
|
+
"""
|
|
1341
|
+
|
|
1342
|
+
UNSIGNED_DEVICE = 2
|
|
1343
|
+
"""
|
|
1344
|
+
The sending device hasn't been verified by the sender.
|
|
1345
|
+
"""
|
|
1346
|
+
|
|
1347
|
+
UNVERIFIED_IDENTITY = 3
|
|
1348
|
+
"""
|
|
1349
|
+
The sender hasn't been verified by the Client's user.
|
|
1350
|
+
"""
|
|
1351
|
+
|
|
1352
|
+
VERIFICATION_VIOLATION = 4
|
|
1353
|
+
"""
|
|
1354
|
+
The sender was previously verified but changed their identity.
|
|
1355
|
+
"""
|
|
1356
|
+
|
|
1357
|
+
MISMATCHED_SENDER = 5
|
|
1358
|
+
"""
|
|
1359
|
+
The `sender` field on the event does not match the owner of the device
|
|
1360
|
+
that established the Megolm session.
|
|
1361
|
+
"""
|
|
1362
|
+
|
|
1363
|
+
SENT_IN_CLEAR = 6
|
|
1364
|
+
"""
|
|
1365
|
+
An unencrypted event in an encrypted room.
|
|
1366
|
+
"""
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
|
|
1370
|
+
class _UniffiFfiConverterTypeTimelineEventShieldStateCode(_UniffiConverterRustBuffer):
|
|
1371
|
+
@staticmethod
|
|
1372
|
+
def read(buf):
|
|
1373
|
+
variant = buf.read_i32()
|
|
1374
|
+
if variant == 1:
|
|
1375
|
+
return TimelineEventShieldStateCode.AUTHENTICITY_NOT_GUARANTEED
|
|
1376
|
+
if variant == 2:
|
|
1377
|
+
return TimelineEventShieldStateCode.UNKNOWN_DEVICE
|
|
1378
|
+
if variant == 3:
|
|
1379
|
+
return TimelineEventShieldStateCode.UNSIGNED_DEVICE
|
|
1380
|
+
if variant == 4:
|
|
1381
|
+
return TimelineEventShieldStateCode.UNVERIFIED_IDENTITY
|
|
1382
|
+
if variant == 5:
|
|
1383
|
+
return TimelineEventShieldStateCode.VERIFICATION_VIOLATION
|
|
1384
|
+
if variant == 6:
|
|
1385
|
+
return TimelineEventShieldStateCode.MISMATCHED_SENDER
|
|
1386
|
+
if variant == 7:
|
|
1387
|
+
return TimelineEventShieldStateCode.SENT_IN_CLEAR
|
|
1388
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
1389
|
+
|
|
1390
|
+
@staticmethod
|
|
1391
|
+
def check_lower(value):
|
|
1392
|
+
if value == TimelineEventShieldStateCode.AUTHENTICITY_NOT_GUARANTEED:
|
|
1393
|
+
return
|
|
1394
|
+
if value == TimelineEventShieldStateCode.UNKNOWN_DEVICE:
|
|
1395
|
+
return
|
|
1396
|
+
if value == TimelineEventShieldStateCode.UNSIGNED_DEVICE:
|
|
1397
|
+
return
|
|
1398
|
+
if value == TimelineEventShieldStateCode.UNVERIFIED_IDENTITY:
|
|
1399
|
+
return
|
|
1400
|
+
if value == TimelineEventShieldStateCode.VERIFICATION_VIOLATION:
|
|
1401
|
+
return
|
|
1402
|
+
if value == TimelineEventShieldStateCode.MISMATCHED_SENDER:
|
|
1403
|
+
return
|
|
1404
|
+
if value == TimelineEventShieldStateCode.SENT_IN_CLEAR:
|
|
1405
|
+
return
|
|
1406
|
+
raise ValueError(value)
|
|
1407
|
+
|
|
1408
|
+
@staticmethod
|
|
1409
|
+
def write(value, buf):
|
|
1410
|
+
if value == TimelineEventShieldStateCode.AUTHENTICITY_NOT_GUARANTEED:
|
|
1411
|
+
buf.write_i32(1)
|
|
1412
|
+
if value == TimelineEventShieldStateCode.UNKNOWN_DEVICE:
|
|
1413
|
+
buf.write_i32(2)
|
|
1414
|
+
if value == TimelineEventShieldStateCode.UNSIGNED_DEVICE:
|
|
1415
|
+
buf.write_i32(3)
|
|
1416
|
+
if value == TimelineEventShieldStateCode.UNVERIFIED_IDENTITY:
|
|
1417
|
+
buf.write_i32(4)
|
|
1418
|
+
if value == TimelineEventShieldStateCode.VERIFICATION_VIOLATION:
|
|
1419
|
+
buf.write_i32(5)
|
|
1420
|
+
if value == TimelineEventShieldStateCode.MISMATCHED_SENDER:
|
|
1421
|
+
buf.write_i32(6)
|
|
1422
|
+
if value == TimelineEventShieldStateCode.SENT_IN_CLEAR:
|
|
1423
|
+
buf.write_i32(7)
|
|
1424
|
+
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
class TimelineReadReceiptTracking(enum.Enum):
|
|
1433
|
+
"""
|
|
1434
|
+
The level of read receipt tracking for the timeline.
|
|
1435
|
+
"""
|
|
1436
|
+
|
|
1437
|
+
ALL_EVENTS = 0
|
|
1438
|
+
"""
|
|
1439
|
+
Track read receipts for all events.
|
|
1440
|
+
"""
|
|
1441
|
+
|
|
1442
|
+
MESSAGE_LIKE_EVENTS = 1
|
|
1443
|
+
"""
|
|
1444
|
+
Track read receipts only for message-like events.
|
|
1445
|
+
"""
|
|
1446
|
+
|
|
1447
|
+
DISABLED = 2
|
|
1448
|
+
"""
|
|
1449
|
+
Disable read receipt tracking.
|
|
1450
|
+
"""
|
|
1451
|
+
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
class _UniffiFfiConverterTypeTimelineReadReceiptTracking(_UniffiConverterRustBuffer):
|
|
1455
|
+
@staticmethod
|
|
1456
|
+
def read(buf):
|
|
1457
|
+
variant = buf.read_i32()
|
|
1458
|
+
if variant == 1:
|
|
1459
|
+
return TimelineReadReceiptTracking.ALL_EVENTS
|
|
1460
|
+
if variant == 2:
|
|
1461
|
+
return TimelineReadReceiptTracking.MESSAGE_LIKE_EVENTS
|
|
1462
|
+
if variant == 3:
|
|
1463
|
+
return TimelineReadReceiptTracking.DISABLED
|
|
1464
|
+
raise InternalError("Raw enum value doesn't match any cases")
|
|
1465
|
+
|
|
1466
|
+
@staticmethod
|
|
1467
|
+
def check_lower(value):
|
|
1468
|
+
if value == TimelineReadReceiptTracking.ALL_EVENTS:
|
|
1469
|
+
return
|
|
1470
|
+
if value == TimelineReadReceiptTracking.MESSAGE_LIKE_EVENTS:
|
|
1471
|
+
return
|
|
1472
|
+
if value == TimelineReadReceiptTracking.DISABLED:
|
|
1473
|
+
return
|
|
1474
|
+
raise ValueError(value)
|
|
1475
|
+
|
|
1476
|
+
@staticmethod
|
|
1477
|
+
def write(value, buf):
|
|
1478
|
+
if value == TimelineReadReceiptTracking.ALL_EVENTS:
|
|
1479
|
+
buf.write_i32(1)
|
|
1480
|
+
if value == TimelineReadReceiptTracking.MESSAGE_LIKE_EVENTS:
|
|
1481
|
+
buf.write_i32(2)
|
|
1482
|
+
if value == TimelineReadReceiptTracking.DISABLED:
|
|
1483
|
+
buf.write_i32(3)
|
|
1484
|
+
|
|
1485
|
+
|
|
1486
|
+
|
|
1487
|
+
class _UniffiFfiConverterUInt8(_UniffiConverterPrimitiveInt):
|
|
1488
|
+
CLASS_NAME = "u8"
|
|
1489
|
+
VALUE_MIN = 0
|
|
1490
|
+
VALUE_MAX = 2**8
|
|
1491
|
+
|
|
1492
|
+
@staticmethod
|
|
1493
|
+
def read(buf):
|
|
1494
|
+
return buf.read_u8()
|
|
1495
|
+
|
|
1496
|
+
@staticmethod
|
|
1497
|
+
def write(value, buf):
|
|
1498
|
+
buf.write_u8(value)
|
|
1499
|
+
|
|
1500
|
+
class _UniffiFfiConverterString:
|
|
1501
|
+
@staticmethod
|
|
1502
|
+
def check_lower(value):
|
|
1503
|
+
if not isinstance(value, str):
|
|
1504
|
+
raise TypeError("argument must be str, not {}".format(type(value).__name__))
|
|
1505
|
+
return value
|
|
1506
|
+
|
|
1507
|
+
@staticmethod
|
|
1508
|
+
def read(buf):
|
|
1509
|
+
size = buf.read_i32()
|
|
1510
|
+
if size < 0:
|
|
1511
|
+
raise InternalError("Unexpected negative string length")
|
|
1512
|
+
utf8_bytes = buf.read(size)
|
|
1513
|
+
return utf8_bytes.decode("utf-8")
|
|
1514
|
+
|
|
1515
|
+
@staticmethod
|
|
1516
|
+
def write(value, buf):
|
|
1517
|
+
utf8_bytes = value.encode("utf-8")
|
|
1518
|
+
buf.write_i32(len(utf8_bytes))
|
|
1519
|
+
buf.write(utf8_bytes)
|
|
1520
|
+
|
|
1521
|
+
@staticmethod
|
|
1522
|
+
def lift(buf):
|
|
1523
|
+
with buf.consume_with_stream() as stream:
|
|
1524
|
+
return stream.read(stream.remaining()).decode("utf-8")
|
|
1525
|
+
|
|
1526
|
+
@staticmethod
|
|
1527
|
+
def lower(value):
|
|
1528
|
+
with _UniffiRustBuffer.alloc_with_builder() as builder:
|
|
1529
|
+
builder.write(value.encode("utf-8"))
|
|
1530
|
+
return builder.finalize()
|
|
1531
|
+
|
|
1532
|
+
__all__ = [
|
|
1533
|
+
"InternalError",
|
|
1534
|
+
"EventItemOrigin",
|
|
1535
|
+
"LatestEventValueLocalState",
|
|
1536
|
+
"RoomPinnedEventsChange",
|
|
1537
|
+
"SpaceRoomListPaginationState",
|
|
1538
|
+
"ThreadListPaginationState",
|
|
1539
|
+
"TimelineEventFocusThreadMode",
|
|
1540
|
+
"TimelineEventShieldStateCode",
|
|
1541
|
+
"TimelineReadReceiptTracking",
|
|
1542
|
+
]
|