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.
@@ -0,0 +1,1101 @@
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_common_rustbuffer_alloc, size)
50
+
51
+ @staticmethod
52
+ def reserve(rbuf, additional):
53
+ return _uniffi_rust_call(_UniffiLib.ffi_matrix_sdk_common_rustbuffer_reserve, rbuf, additional)
54
+
55
+ def free(self):
56
+ return _uniffi_rust_call(_UniffiLib.ffi_matrix_sdk_common_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_common_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_common_rustbuffer_alloc.argtypes = (
488
+ ctypes.c_uint64,
489
+ ctypes.POINTER(_UniffiRustCallStatus),
490
+ )
491
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_alloc.restype = _UniffiRustBuffer
492
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_from_bytes.argtypes = (
493
+ _UniffiForeignBytes,
494
+ ctypes.POINTER(_UniffiRustCallStatus),
495
+ )
496
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_from_bytes.restype = _UniffiRustBuffer
497
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_free.argtypes = (
498
+ _UniffiRustBuffer,
499
+ ctypes.POINTER(_UniffiRustCallStatus),
500
+ )
501
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_free.restype = None
502
+ _UniffiLib.ffi_matrix_sdk_common_rustbuffer_reserve.argtypes = (
503
+ _UniffiRustBuffer,
504
+ ctypes.c_uint64,
505
+ ctypes.POINTER(_UniffiRustCallStatus),
506
+ )
507
+ _UniffiLib.ffi_matrix_sdk_common_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_common_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_common_rust_future_poll_u8.restype = None
523
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u8.argtypes = (
524
+ ctypes.c_uint64,
525
+ )
526
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u8.restype = None
527
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u8.argtypes = (
528
+ ctypes.c_uint64,
529
+ ctypes.POINTER(_UniffiRustCallStatus),
530
+ )
531
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u8.restype = ctypes.c_uint8
532
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u8.argtypes = (
533
+ ctypes.c_uint64,
534
+ )
535
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u8.restype = None
536
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_i8.restype = None
542
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i8.argtypes = (
543
+ ctypes.c_uint64,
544
+ )
545
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i8.restype = None
546
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i8.argtypes = (
547
+ ctypes.c_uint64,
548
+ ctypes.POINTER(_UniffiRustCallStatus),
549
+ )
550
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i8.restype = ctypes.c_int8
551
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i8.argtypes = (
552
+ ctypes.c_uint64,
553
+ )
554
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i8.restype = None
555
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_u16.restype = None
561
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u16.argtypes = (
562
+ ctypes.c_uint64,
563
+ )
564
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u16.restype = None
565
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u16.argtypes = (
566
+ ctypes.c_uint64,
567
+ ctypes.POINTER(_UniffiRustCallStatus),
568
+ )
569
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u16.restype = ctypes.c_uint16
570
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u16.argtypes = (
571
+ ctypes.c_uint64,
572
+ )
573
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u16.restype = None
574
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_i16.restype = None
580
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i16.argtypes = (
581
+ ctypes.c_uint64,
582
+ )
583
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i16.restype = None
584
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i16.argtypes = (
585
+ ctypes.c_uint64,
586
+ ctypes.POINTER(_UniffiRustCallStatus),
587
+ )
588
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i16.restype = ctypes.c_int16
589
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i16.argtypes = (
590
+ ctypes.c_uint64,
591
+ )
592
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i16.restype = None
593
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_u32.restype = None
599
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u32.argtypes = (
600
+ ctypes.c_uint64,
601
+ )
602
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u32.restype = None
603
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u32.argtypes = (
604
+ ctypes.c_uint64,
605
+ ctypes.POINTER(_UniffiRustCallStatus),
606
+ )
607
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u32.restype = ctypes.c_uint32
608
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u32.argtypes = (
609
+ ctypes.c_uint64,
610
+ )
611
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u32.restype = None
612
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_i32.restype = None
618
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i32.argtypes = (
619
+ ctypes.c_uint64,
620
+ )
621
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i32.restype = None
622
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i32.argtypes = (
623
+ ctypes.c_uint64,
624
+ ctypes.POINTER(_UniffiRustCallStatus),
625
+ )
626
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i32.restype = ctypes.c_int32
627
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i32.argtypes = (
628
+ ctypes.c_uint64,
629
+ )
630
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i32.restype = None
631
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_u64.restype = None
637
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u64.argtypes = (
638
+ ctypes.c_uint64,
639
+ )
640
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_u64.restype = None
641
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u64.argtypes = (
642
+ ctypes.c_uint64,
643
+ ctypes.POINTER(_UniffiRustCallStatus),
644
+ )
645
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_u64.restype = ctypes.c_uint64
646
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u64.argtypes = (
647
+ ctypes.c_uint64,
648
+ )
649
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_u64.restype = None
650
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_i64.restype = None
656
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i64.argtypes = (
657
+ ctypes.c_uint64,
658
+ )
659
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_i64.restype = None
660
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i64.argtypes = (
661
+ ctypes.c_uint64,
662
+ ctypes.POINTER(_UniffiRustCallStatus),
663
+ )
664
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_i64.restype = ctypes.c_int64
665
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i64.argtypes = (
666
+ ctypes.c_uint64,
667
+ )
668
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_i64.restype = None
669
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_f32.restype = None
675
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_f32.argtypes = (
676
+ ctypes.c_uint64,
677
+ )
678
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_f32.restype = None
679
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_f32.argtypes = (
680
+ ctypes.c_uint64,
681
+ ctypes.POINTER(_UniffiRustCallStatus),
682
+ )
683
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_f32.restype = ctypes.c_float
684
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_f32.argtypes = (
685
+ ctypes.c_uint64,
686
+ )
687
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_f32.restype = None
688
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_f64.restype = None
694
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_f64.argtypes = (
695
+ ctypes.c_uint64,
696
+ )
697
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_f64.restype = None
698
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_f64.argtypes = (
699
+ ctypes.c_uint64,
700
+ ctypes.POINTER(_UniffiRustCallStatus),
701
+ )
702
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_f64.restype = ctypes.c_double
703
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_f64.argtypes = (
704
+ ctypes.c_uint64,
705
+ )
706
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_f64.restype = None
707
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_rust_buffer.restype = None
713
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_rust_buffer.argtypes = (
714
+ ctypes.c_uint64,
715
+ )
716
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_rust_buffer.restype = None
717
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_rust_buffer.argtypes = (
718
+ ctypes.c_uint64,
719
+ ctypes.POINTER(_UniffiRustCallStatus),
720
+ )
721
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer
722
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_rust_buffer.argtypes = (
723
+ ctypes.c_uint64,
724
+ )
725
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_rust_buffer.restype = None
726
+ _UniffiLib.ffi_matrix_sdk_common_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_common_rust_future_poll_void.restype = None
732
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_void.argtypes = (
733
+ ctypes.c_uint64,
734
+ )
735
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_cancel_void.restype = None
736
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_void.argtypes = (
737
+ ctypes.c_uint64,
738
+ ctypes.POINTER(_UniffiRustCallStatus),
739
+ )
740
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_complete_void.restype = None
741
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_void.argtypes = (
742
+ ctypes.c_uint64,
743
+ )
744
+ _UniffiLib.ffi_matrix_sdk_common_rust_future_free_void.restype = None
745
+ _UniffiLib.ffi_matrix_sdk_common_uniffi_contract_version.argtypes = (
746
+ )
747
+ _UniffiLib.ffi_matrix_sdk_common_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
+ class _UniffiFfiConverterString:
758
+ @staticmethod
759
+ def check_lower(value):
760
+ if not isinstance(value, str):
761
+ raise TypeError("argument must be str, not {}".format(type(value).__name__))
762
+ return value
763
+
764
+ @staticmethod
765
+ def read(buf):
766
+ size = buf.read_i32()
767
+ if size < 0:
768
+ raise InternalError("Unexpected negative string length")
769
+ utf8_bytes = buf.read(size)
770
+ return utf8_bytes.decode("utf-8")
771
+
772
+ @staticmethod
773
+ def write(value, buf):
774
+ utf8_bytes = value.encode("utf-8")
775
+ buf.write_i32(len(utf8_bytes))
776
+ buf.write(utf8_bytes)
777
+
778
+ @staticmethod
779
+ def lift(buf):
780
+ with buf.consume_with_stream() as stream:
781
+ return stream.read(stream.remaining()).decode("utf-8")
782
+
783
+ @staticmethod
784
+ def lower(value):
785
+ with _UniffiRustBuffer.alloc_with_builder() as builder:
786
+ builder.write(value.encode("utf-8"))
787
+ return builder.finalize()
788
+
789
+ class _UniffiFfiConverterOptionalString(_UniffiConverterRustBuffer):
790
+ @classmethod
791
+ def check_lower(cls, value):
792
+ if value is not None:
793
+ _UniffiFfiConverterString.check_lower(value)
794
+
795
+ @classmethod
796
+ def write(cls, value, buf):
797
+ if value is None:
798
+ buf.write_u8(0)
799
+ return
800
+
801
+ buf.write_u8(1)
802
+ _UniffiFfiConverterString.write(value, buf)
803
+
804
+ @classmethod
805
+ def read(cls, buf):
806
+ flag = buf.read_u8()
807
+ if flag == 0:
808
+ return None
809
+ elif flag == 1:
810
+ return _UniffiFfiConverterString.read(buf)
811
+ else:
812
+ raise InternalError("Unexpected flag byte for optional type")
813
+
814
+
815
+
816
+
817
+
818
+
819
+ class BackgroundTaskFailureReason:
820
+ """
821
+ Reason why a background task failed.
822
+ """
823
+ def __init__(self):
824
+ raise RuntimeError("BackgroundTaskFailureReason cannot be instantiated directly")
825
+
826
+ # Each enum variant is a nested class of the enum itself.
827
+ @dataclass
828
+ class PANIC:
829
+ """
830
+ The task panicked.
831
+ """
832
+
833
+ def __init__(self, message:typing.Optional[str], panic_backtrace:typing.Optional[str]):
834
+ self.message = message
835
+
836
+ """
837
+ The panic message, if it could be extracted.
838
+ """
839
+
840
+ self.panic_backtrace = panic_backtrace
841
+
842
+ """
843
+ Backtrace captured after the panic (if available).
844
+ """
845
+
846
+ pass
847
+
848
+
849
+
850
+
851
+
852
+ def __str__(self):
853
+ return "BackgroundTaskFailureReason.PANIC(message={}, panic_backtrace={})".format(self.message, self.panic_backtrace)
854
+ def __eq__(self, other):
855
+ if not isinstance(other, BackgroundTaskFailureReason):
856
+ return NotImplemented
857
+ if not other.is_PANIC():
858
+ return False
859
+ if self.message != other.message:
860
+ return False
861
+ if self.panic_backtrace != other.panic_backtrace:
862
+ return False
863
+ return True
864
+
865
+ @dataclass
866
+ class ERROR:
867
+ """
868
+ The task returned an error.
869
+ """
870
+
871
+ def __init__(self, error:str):
872
+ self.error = error
873
+
874
+ """
875
+ String representation of the error.
876
+ """
877
+
878
+ pass
879
+
880
+
881
+
882
+
883
+
884
+ def __str__(self):
885
+ return "BackgroundTaskFailureReason.ERROR(error={})".format(self.error)
886
+ def __eq__(self, other):
887
+ if not isinstance(other, BackgroundTaskFailureReason):
888
+ return NotImplemented
889
+ if not other.is_ERROR():
890
+ return False
891
+ if self.error != other.error:
892
+ return False
893
+ return True
894
+
895
+ @dataclass
896
+ class EARLY_TERMINATION:
897
+ """
898
+ The task ended unexpectedly (for tasks expected to run forever).
899
+ """
900
+
901
+ def __init__(self, ):
902
+ pass
903
+
904
+
905
+
906
+
907
+
908
+ def __str__(self):
909
+ return "BackgroundTaskFailureReason.EARLY_TERMINATION()".format()
910
+ def __eq__(self, other):
911
+ if not isinstance(other, BackgroundTaskFailureReason):
912
+ return NotImplemented
913
+ if not other.is_EARLY_TERMINATION():
914
+ return False
915
+ return True
916
+
917
+
918
+
919
+ # For each variant, we have `is_NAME` and `is_name` methods for easily checking
920
+ # whether an instance is that variant.
921
+ def is_PANIC(self) -> bool:
922
+ return isinstance(self, BackgroundTaskFailureReason.PANIC)
923
+ def is_panic(self) -> bool:
924
+ return isinstance(self, BackgroundTaskFailureReason.PANIC)
925
+ def is_ERROR(self) -> bool:
926
+ return isinstance(self, BackgroundTaskFailureReason.ERROR)
927
+ def is_error(self) -> bool:
928
+ return isinstance(self, BackgroundTaskFailureReason.ERROR)
929
+ def is_EARLY_TERMINATION(self) -> bool:
930
+ return isinstance(self, BackgroundTaskFailureReason.EARLY_TERMINATION)
931
+ def is_early_termination(self) -> bool:
932
+ return isinstance(self, BackgroundTaskFailureReason.EARLY_TERMINATION)
933
+
934
+
935
+ # Now, a little trick - we make each nested variant class be a subclass of the main
936
+ # enum class, so that method calls and instance checks etc will work intuitively.
937
+ # We might be able to do this a little more neatly with a metaclass, but this'll do.
938
+ BackgroundTaskFailureReason.PANIC = type("BackgroundTaskFailureReason.PANIC", (BackgroundTaskFailureReason.PANIC, BackgroundTaskFailureReason,), {}) # type: ignore
939
+ BackgroundTaskFailureReason.ERROR = type("BackgroundTaskFailureReason.ERROR", (BackgroundTaskFailureReason.ERROR, BackgroundTaskFailureReason,), {}) # type: ignore
940
+ BackgroundTaskFailureReason.EARLY_TERMINATION = type("BackgroundTaskFailureReason.EARLY_TERMINATION", (BackgroundTaskFailureReason.EARLY_TERMINATION, BackgroundTaskFailureReason,), {}) # type: ignore
941
+
942
+
943
+
944
+
945
+ class _UniffiFfiConverterTypeBackgroundTaskFailureReason(_UniffiConverterRustBuffer):
946
+ @staticmethod
947
+ def read(buf):
948
+ variant = buf.read_i32()
949
+ if variant == 1:
950
+ return BackgroundTaskFailureReason.PANIC(
951
+ _UniffiFfiConverterOptionalString.read(buf),
952
+ _UniffiFfiConverterOptionalString.read(buf),
953
+ )
954
+ if variant == 2:
955
+ return BackgroundTaskFailureReason.ERROR(
956
+ _UniffiFfiConverterString.read(buf),
957
+ )
958
+ if variant == 3:
959
+ return BackgroundTaskFailureReason.EARLY_TERMINATION(
960
+ )
961
+ raise InternalError("Raw enum value doesn't match any cases")
962
+
963
+ @staticmethod
964
+ def check_lower(value):
965
+ if value.is_PANIC():
966
+ _UniffiFfiConverterOptionalString.check_lower(value.message)
967
+ _UniffiFfiConverterOptionalString.check_lower(value.panic_backtrace)
968
+ return
969
+ if value.is_ERROR():
970
+ _UniffiFfiConverterString.check_lower(value.error)
971
+ return
972
+ if value.is_EARLY_TERMINATION():
973
+ return
974
+ raise ValueError(value)
975
+
976
+ @staticmethod
977
+ def write(value, buf):
978
+ if value.is_PANIC():
979
+ buf.write_i32(1)
980
+ _UniffiFfiConverterOptionalString.write(value.message, buf)
981
+ _UniffiFfiConverterOptionalString.write(value.panic_backtrace, buf)
982
+ if value.is_ERROR():
983
+ buf.write_i32(2)
984
+ _UniffiFfiConverterString.write(value.error, buf)
985
+ if value.is_EARLY_TERMINATION():
986
+ buf.write_i32(3)
987
+
988
+
989
+
990
+
991
+
992
+
993
+
994
+
995
+ class ShieldStateCode(enum.Enum):
996
+ """
997
+ A machine-readable representation of the authenticity for a `ShieldState`.
998
+ """
999
+
1000
+ AUTHENTICITY_NOT_GUARANTEED = 0
1001
+ """
1002
+ Not enough information available to check the authenticity.
1003
+ """
1004
+
1005
+ UNKNOWN_DEVICE = 1
1006
+ """
1007
+ The sending device isn't yet known by the Client.
1008
+ """
1009
+
1010
+ UNSIGNED_DEVICE = 2
1011
+ """
1012
+ The sending device hasn't been verified by the sender.
1013
+ """
1014
+
1015
+ UNVERIFIED_IDENTITY = 3
1016
+ """
1017
+ The sender hasn't been verified by the Client's user.
1018
+ """
1019
+
1020
+ VERIFICATION_VIOLATION = 4
1021
+ """
1022
+ The sender was previously verified but changed their identity.
1023
+ """
1024
+
1025
+ MISMATCHED_SENDER = 5
1026
+ """
1027
+ The `sender` field on the event does not match the owner of the device
1028
+ that established the Megolm session.
1029
+ """
1030
+
1031
+
1032
+
1033
+ class _UniffiFfiConverterTypeShieldStateCode(_UniffiConverterRustBuffer):
1034
+ @staticmethod
1035
+ def read(buf):
1036
+ variant = buf.read_i32()
1037
+ if variant == 1:
1038
+ return ShieldStateCode.AUTHENTICITY_NOT_GUARANTEED
1039
+ if variant == 2:
1040
+ return ShieldStateCode.UNKNOWN_DEVICE
1041
+ if variant == 3:
1042
+ return ShieldStateCode.UNSIGNED_DEVICE
1043
+ if variant == 4:
1044
+ return ShieldStateCode.UNVERIFIED_IDENTITY
1045
+ if variant == 5:
1046
+ return ShieldStateCode.VERIFICATION_VIOLATION
1047
+ if variant == 6:
1048
+ return ShieldStateCode.MISMATCHED_SENDER
1049
+ raise InternalError("Raw enum value doesn't match any cases")
1050
+
1051
+ @staticmethod
1052
+ def check_lower(value):
1053
+ if value == ShieldStateCode.AUTHENTICITY_NOT_GUARANTEED:
1054
+ return
1055
+ if value == ShieldStateCode.UNKNOWN_DEVICE:
1056
+ return
1057
+ if value == ShieldStateCode.UNSIGNED_DEVICE:
1058
+ return
1059
+ if value == ShieldStateCode.UNVERIFIED_IDENTITY:
1060
+ return
1061
+ if value == ShieldStateCode.VERIFICATION_VIOLATION:
1062
+ return
1063
+ if value == ShieldStateCode.MISMATCHED_SENDER:
1064
+ return
1065
+ raise ValueError(value)
1066
+
1067
+ @staticmethod
1068
+ def write(value, buf):
1069
+ if value == ShieldStateCode.AUTHENTICITY_NOT_GUARANTEED:
1070
+ buf.write_i32(1)
1071
+ if value == ShieldStateCode.UNKNOWN_DEVICE:
1072
+ buf.write_i32(2)
1073
+ if value == ShieldStateCode.UNSIGNED_DEVICE:
1074
+ buf.write_i32(3)
1075
+ if value == ShieldStateCode.UNVERIFIED_IDENTITY:
1076
+ buf.write_i32(4)
1077
+ if value == ShieldStateCode.VERIFICATION_VIOLATION:
1078
+ buf.write_i32(5)
1079
+ if value == ShieldStateCode.MISMATCHED_SENDER:
1080
+ buf.write_i32(6)
1081
+
1082
+
1083
+
1084
+ class _UniffiFfiConverterUInt8(_UniffiConverterPrimitiveInt):
1085
+ CLASS_NAME = "u8"
1086
+ VALUE_MIN = 0
1087
+ VALUE_MAX = 2**8
1088
+
1089
+ @staticmethod
1090
+ def read(buf):
1091
+ return buf.read_u8()
1092
+
1093
+ @staticmethod
1094
+ def write(value, buf):
1095
+ buf.write_u8(value)
1096
+
1097
+ __all__ = [
1098
+ "InternalError",
1099
+ "BackgroundTaskFailureReason",
1100
+ "ShieldStateCode",
1101
+ ]