@dittolive/ditto 4.10.0-rc.1 → 4.10.0-rc.3

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.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +1 -1
  3. package/node/ditto.darwin-arm64.node +0 -0
  4. package/node/ditto.darwin-x64.node +0 -0
  5. package/node/ditto.linux-arm64.node +0 -0
  6. package/node/ditto.linux-x64.node +0 -0
  7. package/node/ditto.win32-x64.node +0 -0
  8. package/package.json +1 -1
  9. package/react-native/android/dittoffi/src/attachment_observer_interfaces.cpp +1 -0
  10. package/react-native/android/dittoffi/src/attachment_observer_interfaces.h +75 -0
  11. package/react-native/android/dittoffi/src/bus.cpp +1 -0
  12. package/react-native/android/dittoffi/src/bus.h +414 -0
  13. package/react-native/android/dittoffi/src/connection_request.cpp +1 -0
  14. package/react-native/android/dittoffi/src/connection_request.h +56 -0
  15. package/react-native/android/dittoffi/src/crash_reporter.cpp +1 -0
  16. package/react-native/android/dittoffi/src/crash_reporter.h +40 -0
  17. package/react-native/android/dittoffi/src/dittoffi.h +5006 -0
  18. package/react-native/android/dittoffi/src/dittoffi_java.cpp +34299 -0
  19. package/react-native/android/dittoffi/src/dittoffi_java.h +341 -0
  20. package/react-native/android/dittoffi/src/dittoffi_java.i +42 -0
  21. package/react-native/android/dittoffi/src/dittomesh_java.i +47 -0
  22. package/react-native/android/dittoffi/src/dittostore_java.i +476 -0
  23. package/react-native/android/dittoffi/src/ifaddrs.cpp +385 -0
  24. package/react-native/android/dittoffi/src/ifaddrs.h +206 -0
  25. package/react-native/android/dittoffi/src/live_query_java_interfaces.cpp +1 -0
  26. package/react-native/android/dittoffi/src/live_query_java_interfaces.h +64 -0
  27. package/react-native/android/dittoffi/src/logger_cb.cpp +3 -0
  28. package/react-native/android/dittoffi/src/logger_cb.h +47 -0
  29. package/react-native/android/dittoffi/src/logger_export.cpp +1 -0
  30. package/react-native/android/dittoffi/src/logger_export.h +37 -0
  31. package/react-native/android/dittoffi/src/mesh_java_interfaces.cpp +1 -0
  32. package/react-native/android/dittoffi/src/mesh_java_interfaces.h +690 -0
  33. package/react-native/android/dittoffi/src/presence.cpp +1 -0
  34. package/react-native/android/dittoffi/src/presence.h +82 -0
  35. package/react-native/android/dittoffi/src/retainable.cpp +1 -0
  36. package/react-native/android/dittoffi/src/retainable.h +47 -0
  37. package/react-native/android/dittoffi/src/store_observer.cpp +1 -0
  38. package/react-native/android/dittoffi/src/store_observer.h +57 -0
  39. package/react-native/ditto.es6.js +1 -1
  40. package/support/ditto-logo-96x96.png +0 -0
  41. package/web/ditto.es6.js +1 -1
  42. package/web/ditto.umd.js +1 -1
  43. package/web/ditto.wasm +0 -0
@@ -0,0 +1,5006 @@
1
+ /*! \file */
2
+ /*******************************************
3
+ * *
4
+ * File auto-generated by `::safer_ffi`. *
5
+ * *
6
+ * Do not manually edit this file. *
7
+ * *
8
+ *******************************************/
9
+
10
+ #ifndef __RUST_DITTOFFI__
11
+ #define __RUST_DITTOFFI__
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
15
+
16
+
17
+ #include <stddef.h>
18
+ #include <stdint.h>
19
+
20
+ /** <No documentation available> */
21
+ #define DITTOFFI_PRESENCE_PEER_METADATA_MAX_SIZE_IN_BYTES ((uint32_t) 4096)
22
+
23
+ /** \brief
24
+ * Ditto Bluetooth Company ID.
25
+ *
26
+ * According to the Android code, this is `0x0000`
27
+ * or `0` which according to the SIG Group, `0x0000` is "Ericsson Technology
28
+ * Licensing" which is not us but `0x0000` is used to match the other Ditto BLE
29
+ * implementations.
30
+ */
31
+ #define DITTOFFI_TRANSPORTS_BLE_COMPANY_ID 0
32
+
33
+ /** \brief
34
+ * The layout of `&str` is opaque/subject to changes.
35
+ */
36
+ typedef struct Opaque__str Opaque__str_t;
37
+
38
+ /** <No documentation available> */
39
+ #define DITTOFFI_TRANSPORTS_WIFI_AWARE_BACKGROUND_MODE_NAME "transports_wifi_aware_background_mode"
40
+
41
+ /** <No documentation available> */
42
+ #define DITTOFFI_TRANSPORTS_WIFI_AWARE_MAX_ERROR_COUNT_NAME "transports_wifi_aware_max_error_count"
43
+
44
+ /** <No documentation available> */
45
+ #define DITTOFFI_TRANSPORTS_WIFI_AWARE_RECENT_ERROR_DURATION_MS_NAME "transports_wifi_aware_max_recent_error_duration_ms"
46
+
47
+ /** \brief
48
+ * This enum contains all the Ditto types exposed publicly. The IDs **MUST**
49
+ * not be modified otherwise this would break the type conversions.
50
+ *
51
+ * CHECKME: When merging with Russell's work on explicit types, this enum may
52
+ * be duplicated.
53
+ */
54
+ typedef enum DittoCrdtType {
55
+ /** <No documentation available> */
56
+ DITTO_CRDT_TYPE_COUNTER = 0,
57
+ /** <No documentation available> */
58
+ DITTO_CRDT_TYPE_REGISTER = 1,
59
+ /** <No documentation available> */
60
+ DITTO_CRDT_TYPE_ATTACHMENT = 2,
61
+ /** <No documentation available> */
62
+ DITTO_CRDT_TYPE_RGA = 3,
63
+ /** <No documentation available> */
64
+ DITTO_CRDT_TYPE_R_W_MAP = 4,
65
+ /** <No documentation available> */
66
+ DITTO_CRDT_TYPE_ST_COUNTER = 5,
67
+ /** <No documentation available> */
68
+ DITTO_CRDT_TYPE_A_W_SET = 6,
69
+ } DittoCrdtType_t;
70
+
71
+ /** \brief
72
+ * State of WiFi Aware when the application goes to background
73
+ */
74
+ typedef enum dittoffi_transport_wifi_aware_background_mode {
75
+ /** \brief
76
+ * Try to keep WiFi Aware on
77
+ */
78
+ DITTOFFI_TRANSPORT_WIFI_AWARE_BACKGROUND_MODE_BEST_EFFORT_ON = 0,
79
+ /** \brief
80
+ * Terminate WiFi Aware on background, and only if the device is on battery
81
+ */
82
+ DITTOFFI_TRANSPORT_WIFI_AWARE_BACKGROUND_MODE_OFF_ON_BATTERY_ONLY,
83
+ /** \brief
84
+ * Terminate WiFi Aware on background
85
+ */
86
+ DITTOFFI_TRANSPORT_WIFI_AWARE_BACKGROUND_MODE_OFF,
87
+ } dittoffi_transport_wifi_aware_background_mode_t;
88
+
89
+ /** \brief
90
+ * A short-lived FFI object to let an SDK handle an authentication request
91
+ * in an async manner.
92
+ */
93
+ typedef struct CAuthServerAuthRequest CAuthServerAuthRequest_t;
94
+
95
+ /** <No documentation available> */
96
+ void
97
+ /* fn */ auth_server_auth_submit_with_error (
98
+ CAuthServerAuthRequest_t * req,
99
+ uint32_t _error_code);
100
+
101
+ /** \brief
102
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
103
+ *
104
+ * # C layout (for some given type T)
105
+ *
106
+ * ```c
107
+ * typedef struct {
108
+ * // Cannot be NULL
109
+ * T * ptr;
110
+ * size_t len;
111
+ * } slice_T;
112
+ * ```
113
+ *
114
+ * # Nullable pointer?
115
+ *
116
+ * If you want to support the above typedef, but where the `ptr` field is
117
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
118
+ * use the `Option< slice_ptr<_> >` type.
119
+ */
120
+ typedef struct slice_ref_uint8 {
121
+ /** \brief
122
+ * Pointer to the first element (if any).
123
+ */
124
+ uint8_t const * ptr;
125
+
126
+ /** \brief
127
+ * Element count
128
+ */
129
+ size_t len;
130
+ } slice_ref_uint8_t;
131
+
132
+ /** <No documentation available> */
133
+ void
134
+ /* fn */ auth_server_auth_submit_with_success (
135
+ CAuthServerAuthRequest_t * req,
136
+ slice_ref_uint8_t success_cbor);
137
+
138
+ /** <No documentation available> */
139
+ typedef struct CAuthServerRefreshRequest CAuthServerRefreshRequest_t;
140
+
141
+ /** <No documentation available> */
142
+ void
143
+ /* fn */ auth_server_refresh_submit_with_error (
144
+ CAuthServerRefreshRequest_t * req,
145
+ uint32_t _error_code);
146
+
147
+ /** <No documentation available> */
148
+ void
149
+ /* fn */ auth_server_refresh_submit_with_success (
150
+ CAuthServerRefreshRequest_t * req,
151
+ slice_ref_uint8_t success_cbor);
152
+
153
+ /** \brief
154
+ * An opaque handle for each installed transport, heap-allocated and owned by
155
+ * the SDK.
156
+ *
157
+ * A pointer to this handle is used to send platform events over FFI. In the
158
+ * future this handle will be the SDK's only point of control over the
159
+ * transport once created. In particular, a transport will be removed by
160
+ * freeing the handle. The concept of online and offline will be eliminated.
161
+ * (i.e., if you don't want a transport, remove it.)
162
+ *
163
+ * For now, the `Peer` object holds the transports and provides an API based on
164
+ * a numeric id assigned to each transport instance. Until that is removed, the
165
+ * id still exists and the SDK can request it from the opaque handle over FFI.
166
+ *
167
+ * For each transport type, define an `extern "C"` function to free that
168
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
169
+ * plus a function to retrieve the transport id, which will be removed later.
170
+ *
171
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
172
+ * that it does not use the pointer to the `TransportHandle` after freeing it
173
+ * with its respective function. In Rust we will assume it is okay to unsafely
174
+ * dereference a handle.
175
+ *
176
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
177
+ */
178
+ typedef struct TransportHandle_AwdlClientPlatformEvent TransportHandle_AwdlClientPlatformEvent_t;
179
+
180
+ /** \brief
181
+ * Generic enum used by crate and platforms to indicate a connection status
182
+ */
183
+ typedef enum ConnectState {
184
+ /** <No documentation available> */
185
+ CONNECT_STATE_DISCONNECTED,
186
+ /** <No documentation available> */
187
+ CONNECT_STATE_CONNECTED,
188
+ /** <No documentation available> */
189
+ CONNECT_STATE_CONNECTING,
190
+ /** <No documentation available> */
191
+ CONNECT_STATE_DISCONNECTING,
192
+ } ConnectState_t;
193
+
194
+ /** \brief
195
+ * The platform advises Rust that a peer has changed its current connection
196
+ * status
197
+ */
198
+ void
199
+ /* fn */ awdl_client_connect_state_changed (
200
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
201
+ char const * announce,
202
+ ConnectState_t state);
203
+
204
+ /** \brief
205
+ * The platform advises Rust that a complete message has been received from a
206
+ * remote peer
207
+ */
208
+ void
209
+ /* fn */ awdl_client_data_available (
210
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
211
+ char const * announce);
212
+
213
+ /** \brief
214
+ * The SDK requests to drop its handle to the AWDL Client Transport
215
+ *
216
+ * At some point dropping this events channel will effectively shut down and
217
+ * remove the Transport. At time of writing, the Transport is still owned
218
+ * within Peer.
219
+ */
220
+ void
221
+ /* fn */ awdl_client_free_handle (
222
+ TransportHandle_AwdlClientPlatformEvent_t * handle);
223
+
224
+ /** \brief
225
+ * The platform advises Rust that a peer has been identified. We know only its
226
+ * announce string.
227
+ */
228
+ void
229
+ /* fn */ awdl_client_platform_peer_appeared (
230
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
231
+ char const * announce);
232
+
233
+ /** \brief
234
+ * The platform advises Rust that a peer has disappeared.
235
+ */
236
+ void
237
+ /* fn */ awdl_client_platform_peer_disappeared (
238
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
239
+ char const * announce);
240
+
241
+ /** \brief
242
+ * The platform advises Rust that a given peer is now clear to queue up a new
243
+ * message whenever one is ready to go
244
+ */
245
+ void
246
+ /* fn */ awdl_client_ready_to_send (
247
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
248
+ char const * announce);
249
+
250
+ /** \brief
251
+ * Generic enum used by crate and platforms to indicate online-ness.
252
+ *
253
+ * In other words, is something active or not? Not everything will use the
254
+ * transitional states.
255
+ */
256
+ typedef enum OnlineState {
257
+ /** <No documentation available> */
258
+ ONLINE_STATE_OFFLINE,
259
+ /** <No documentation available> */
260
+ ONLINE_STATE_ONLINE,
261
+ /** <No documentation available> */
262
+ ONLINE_STATE_GOING_ONLINE,
263
+ /** <No documentation available> */
264
+ ONLINE_STATE_GOING_OFFLINE,
265
+ } OnlineState_t;
266
+
267
+ /** \brief
268
+ * A code reported by platforms/transports to indicate specific health
269
+ * conditions
270
+ */
271
+ typedef enum TransportCondition {
272
+ /** \brief
273
+ * A default state. Only use this for transient conditions, e.g., we are
274
+ * waiting for a platform to finish starting up. If everything is just
275
+ * quiet, use `Ok`.
276
+ */
277
+ TRANSPORT_CONDITION_UNKNOWN,
278
+ /** \brief
279
+ * No known problems.
280
+ */
281
+ TRANSPORT_CONDITION_OK,
282
+ /** \brief
283
+ * Catch-all failure, particularly for unexpected/internal faults. If
284
+ * possible, add a new case that the customer will be able to
285
+ * interpret.
286
+ */
287
+ TRANSPORT_CONDITION_GENERIC_FAILURE,
288
+ /** \brief
289
+ * App is in background.
290
+ */
291
+ TRANSPORT_CONDITION_APP_IN_BACKGROUND,
292
+ /** \brief
293
+ * We are not able to publish or discover with the mDNS daemon.
294
+ */
295
+ TRANSPORT_CONDITION_MDNS_FAILURE,
296
+ /** \brief
297
+ * We cannot bind to a port.
298
+ */
299
+ TRANSPORT_CONDITION_TCP_LISTEN_FAILURE,
300
+ /** \brief
301
+ * No app permission to act as a BLE Central.
302
+ */
303
+ TRANSPORT_CONDITION_NO_BLE_CENTRAL_PERMISSION,
304
+ /** \brief
305
+ * No app permission to act as a BLE Peripheral.
306
+ */
307
+ TRANSPORT_CONDITION_NO_BLE_PERIPHERAL_PERMISSION,
308
+ /** \brief
309
+ * This Transport targets a particular peer and we can't reach them right
310
+ * now.
311
+ */
312
+ TRANSPORT_CONDITION_CANNOT_ESTABLISH_CONNECTION,
313
+ /** \brief
314
+ * The device has Bluetooth disabled at the OS level.
315
+ */
316
+ TRANSPORT_CONDITION_BLE_DISABLED,
317
+ /** \brief
318
+ * The device has no Bluetooth hardware.
319
+ */
320
+ TRANSPORT_CONDITION_NO_BLE_HARDWARE,
321
+ /** \brief
322
+ * The device has Wifi disabled at the OS level.
323
+ */
324
+ TRANSPORT_CONDITION_WIFI_DISABLED,
325
+ /** \brief
326
+ * The platform has suspended briefly for internal reasons. Peers are
327
+ * reset.
328
+ */
329
+ TRANSPORT_CONDITION_TEMPORARILY_UNAVAILABLE,
330
+ } TransportCondition_t;
331
+
332
+ /** \brief
333
+ * The platform advises Rust that searching status changed
334
+ */
335
+ void
336
+ /* fn */ awdl_client_scanning_state_changed (
337
+ TransportHandle_AwdlClientPlatformEvent_t const * handle,
338
+ OnlineState_t state,
339
+ TransportCondition_t condition);
340
+
341
+ /** \brief
342
+ * An opaque handle for each installed transport, heap-allocated and owned by
343
+ * the SDK.
344
+ *
345
+ * A pointer to this handle is used to send platform events over FFI. In the
346
+ * future this handle will be the SDK's only point of control over the
347
+ * transport once created. In particular, a transport will be removed by
348
+ * freeing the handle. The concept of online and offline will be eliminated.
349
+ * (i.e., if you don't want a transport, remove it.)
350
+ *
351
+ * For now, the `Peer` object holds the transports and provides an API based on
352
+ * a numeric id assigned to each transport instance. Until that is removed, the
353
+ * id still exists and the SDK can request it from the opaque handle over FFI.
354
+ *
355
+ * For each transport type, define an `extern "C"` function to free that
356
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
357
+ * plus a function to retrieve the transport id, which will be removed later.
358
+ *
359
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
360
+ * that it does not use the pointer to the `TransportHandle` after freeing it
361
+ * with its respective function. In Rust we will assume it is okay to unsafely
362
+ * dereference a handle.
363
+ *
364
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
365
+ */
366
+ typedef struct TransportHandle_AwdlServerPlatformEvent TransportHandle_AwdlServerPlatformEvent_t;
367
+
368
+ /** \brief
369
+ * The platform advises Rust that advertising status changed
370
+ */
371
+ void
372
+ /* fn */ awdl_server_advertising_state_changed (
373
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
374
+ OnlineState_t state,
375
+ TransportCondition_t condition);
376
+
377
+ /** \brief
378
+ * The platform advises Rust that a peer has changed its current connection
379
+ * status
380
+ */
381
+ void
382
+ /* fn */ awdl_server_connect_state_changed (
383
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
384
+ int64_t platform_id,
385
+ ConnectState_t state);
386
+
387
+ /** \brief
388
+ * The platform advises Rust that a complete message has been received from a
389
+ * remote peer
390
+ */
391
+ void
392
+ /* fn */ awdl_server_data_available (
393
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
394
+ int64_t platform_id);
395
+
396
+ /** \brief
397
+ * The SDK requests to drop its handle to the AWDL Server Transport
398
+ *
399
+ * At some point dropping this events channel will effectively shut down and
400
+ * remove the Transport. At time of writing, the Transport is still owned
401
+ * within Peer.
402
+ */
403
+ void
404
+ /* fn */ awdl_server_free_handle (
405
+ TransportHandle_AwdlServerPlatformEvent_t * handle);
406
+
407
+ /** \brief
408
+ * The platform advises Rust that a peer has been identified. We know only its
409
+ * announce string.
410
+ */
411
+ void
412
+ /* fn */ awdl_server_platform_peer_appeared (
413
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
414
+ int64_t platform_id);
415
+
416
+ /** \brief
417
+ * The platform advises Rust that a peer has disappeared.
418
+ */
419
+ void
420
+ /* fn */ awdl_server_platform_peer_disappeared (
421
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
422
+ int64_t platform_id);
423
+
424
+ /** \brief
425
+ * The platform advises Rust that a given peer is now clear to queue up a new
426
+ * message whenever one is ready to go
427
+ */
428
+ void
429
+ /* fn */ awdl_server_ready_to_send (
430
+ TransportHandle_AwdlServerPlatformEvent_t const * handle,
431
+ int64_t platform_id);
432
+
433
+ /** \brief
434
+ * An opaque handle for each installed transport, heap-allocated and owned by
435
+ * the SDK.
436
+ *
437
+ * A pointer to this handle is used to send platform events over FFI. In the
438
+ * future this handle will be the SDK's only point of control over the
439
+ * transport once created. In particular, a transport will be removed by
440
+ * freeing the handle. The concept of online and offline will be eliminated.
441
+ * (i.e., if you don't want a transport, remove it.)
442
+ *
443
+ * For now, the `Peer` object holds the transports and provides an API based on
444
+ * a numeric id assigned to each transport instance. Until that is removed, the
445
+ * id still exists and the SDK can request it from the opaque handle over FFI.
446
+ *
447
+ * For each transport type, define an `extern "C"` function to free that
448
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
449
+ * plus a function to retrieve the transport id, which will be removed later.
450
+ *
451
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
452
+ * that it does not use the pointer to the `TransportHandle` after freeing it
453
+ * with its respective function. In Rust we will assume it is okay to unsafely
454
+ * dereference a handle.
455
+ *
456
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
457
+ */
458
+ typedef struct TransportHandle_BleServerPlatformEvent TransportHandle_BleServerPlatformEvent_t;
459
+
460
+ /** <No documentation available> */
461
+ void
462
+ /* fn */ ble_advertising_state_changed (
463
+ TransportHandle_BleServerPlatformEvent_t const * handle,
464
+ OnlineState_t state,
465
+ TransportCondition_t result);
466
+
467
+ typedef struct {
468
+ uint8_t idx[16];
469
+ } uint8_16_array_t;
470
+
471
+ /** <No documentation available> */
472
+ void
473
+ /* fn */ ble_central_finished_connecting (
474
+ TransportHandle_BleServerPlatformEvent_t const * handle,
475
+ uint8_16_array_t const * uuid,
476
+ slice_ref_uint8_t announce,
477
+ int32_t l2cap_available,
478
+ uint32_t mtu);
479
+
480
+ /** <No documentation available> */
481
+ void
482
+ /* fn */ ble_central_l2cap_data_available (
483
+ TransportHandle_BleServerPlatformEvent_t const * handle,
484
+ uint8_16_array_t const * uuid);
485
+
486
+ /** <No documentation available> */
487
+ void
488
+ /* fn */ ble_central_l2cap_ready_to_send (
489
+ TransportHandle_BleServerPlatformEvent_t const * handle,
490
+ uint8_16_array_t const * uuid);
491
+
492
+ /** <No documentation available> */
493
+ void
494
+ /* fn */ ble_central_mtu_updated (
495
+ TransportHandle_BleServerPlatformEvent_t const * handle,
496
+ uint8_16_array_t const * uuid,
497
+ uint32_t mtu);
498
+
499
+ /** <No documentation available> */
500
+ void
501
+ /* fn */ ble_central_ready_to_send (
502
+ TransportHandle_BleServerPlatformEvent_t const * handle,
503
+ uint8_16_array_t const * uuid);
504
+
505
+ /** <No documentation available> */
506
+ void
507
+ /* fn */ ble_central_unsubscribed (
508
+ TransportHandle_BleServerPlatformEvent_t const * handle,
509
+ uint8_16_array_t const * central_uuid);
510
+
511
+ /** \brief
512
+ * An opaque handle for each installed transport, heap-allocated and owned by
513
+ * the SDK.
514
+ *
515
+ * A pointer to this handle is used to send platform events over FFI. In the
516
+ * future this handle will be the SDK's only point of control over the
517
+ * transport once created. In particular, a transport will be removed by
518
+ * freeing the handle. The concept of online and offline will be eliminated.
519
+ * (i.e., if you don't want a transport, remove it.)
520
+ *
521
+ * For now, the `Peer` object holds the transports and provides an API based on
522
+ * a numeric id assigned to each transport instance. Until that is removed, the
523
+ * id still exists and the SDK can request it from the opaque handle over FFI.
524
+ *
525
+ * For each transport type, define an `extern "C"` function to free that
526
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
527
+ * plus a function to retrieve the transport id, which will be removed later.
528
+ *
529
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
530
+ * that it does not use the pointer to the `TransportHandle` after freeing it
531
+ * with its respective function. In Rust we will assume it is okay to unsafely
532
+ * dereference a handle.
533
+ *
534
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
535
+ */
536
+ typedef struct TransportHandle_BleClientPlatformEvent TransportHandle_BleClientPlatformEvent_t;
537
+
538
+ /** \brief
539
+ * The SDK requests to drop its handle to the BLE Client Transport
540
+ *
541
+ * At some point dropping this events channel will effectively shut down and
542
+ * remove the Transport. At time of writing, the Transport is still owned
543
+ * within Peer.
544
+ */
545
+ void
546
+ /* fn */ ble_client_free_handle (
547
+ TransportHandle_BleClientPlatformEvent_t * handle);
548
+
549
+ /** <No documentation available> */
550
+ void
551
+ /* fn */ ble_connection_state_changed (
552
+ TransportHandle_BleClientPlatformEvent_t const * handle,
553
+ uint8_16_array_t const * peripheral_uuid,
554
+ ConnectState_t state,
555
+ int32_t l2cap_available,
556
+ uint32_t mtu);
557
+
558
+ /** <No documentation available> */
559
+ void
560
+ /* fn */ ble_peripheral_l2cap_data_available (
561
+ TransportHandle_BleClientPlatformEvent_t const * handle,
562
+ uint8_16_array_t const * uuid);
563
+
564
+ /** <No documentation available> */
565
+ void
566
+ /* fn */ ble_peripheral_l2cap_ready_to_send (
567
+ TransportHandle_BleClientPlatformEvent_t const * handle,
568
+ uint8_16_array_t const * uuid);
569
+
570
+ /** <No documentation available> */
571
+ void
572
+ /* fn */ ble_peripheral_mtu_updated (
573
+ TransportHandle_BleClientPlatformEvent_t const * handle,
574
+ uint8_16_array_t const * uuid,
575
+ uint32_t mtu);
576
+
577
+ /** <No documentation available> */
578
+ void
579
+ /* fn */ ble_peripheral_ready_to_send (
580
+ TransportHandle_BleClientPlatformEvent_t const * handle,
581
+ uint8_16_array_t const * uuid);
582
+
583
+ /** \brief
584
+ * When receiving data from a Bluetooth LE peer, such as a characteristic
585
+ * write, indicates what sort of data it is.
586
+ */
587
+ typedef enum BleDataType {
588
+ /** \brief
589
+ * The data _should_ contain the remote peer's announce string.
590
+ * Used during handshake.
591
+ */
592
+ BLE_DATA_TYPE_ANNOUNCE = 0,
593
+ /** \brief
594
+ * Data message
595
+ */
596
+ BLE_DATA_TYPE_MESH_DATA = 1,
597
+ /** \brief
598
+ * Control message
599
+ */
600
+ BLE_DATA_TYPE_CONTROL = 2,
601
+ } BleDataType_t;
602
+
603
+ /** <No documentation available> */
604
+ void
605
+ /* fn */ ble_received_from_central (
606
+ TransportHandle_BleServerPlatformEvent_t const * handle,
607
+ uint8_16_array_t const * central_uuid,
608
+ BleDataType_t data_type,
609
+ slice_ref_uint8_t data);
610
+
611
+ /** <No documentation available> */
612
+ void
613
+ /* fn */ ble_received_from_peripheral (
614
+ TransportHandle_BleClientPlatformEvent_t const * handle,
615
+ uint8_16_array_t const * peripheral_uuid,
616
+ BleDataType_t data_type,
617
+ slice_ref_uint8_t data);
618
+
619
+ /** <No documentation available> */
620
+ void
621
+ /* fn */ ble_scanning_state_changed (
622
+ TransportHandle_BleClientPlatformEvent_t const * handle,
623
+ OnlineState_t state,
624
+ TransportCondition_t result);
625
+
626
+ /** \brief
627
+ * The SDK requests to drop its handle to the BLE Server Transport
628
+ *
629
+ * At some point dropping this events channel will effectively shut down and
630
+ * remove the Transport. At time of writing, the Transport is still owned
631
+ * within Peer.
632
+ */
633
+ void
634
+ /* fn */ ble_server_free_handle (
635
+ TransportHandle_BleServerPlatformEvent_t * handle);
636
+
637
+ /** <No documentation available> */
638
+ typedef struct CDitto CDitto_t;
639
+
640
+ /** \brief
641
+ * `&'lt mut [T]` but with a guaranteed `#[repr(C)]` layout.
642
+ *
643
+ * # C layout (for some given type T)
644
+ *
645
+ * ```c
646
+ * typedef struct {
647
+ * // Cannot be NULL
648
+ * T * ptr;
649
+ * size_t len;
650
+ * } slice_T;
651
+ * ```
652
+ *
653
+ * # Nullable pointer?
654
+ *
655
+ * If you want to support the above typedef, but where the `ptr` field is
656
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
657
+ * use the `Option< slice_ptr<_> >` type.
658
+ */
659
+ typedef struct slice_mut_uint8 {
660
+ /** \brief
661
+ * Pointer to the first element (if any).
662
+ */
663
+ uint8_t * ptr;
664
+
665
+ /** \brief
666
+ * Element count
667
+ */
668
+ size_t len;
669
+ } slice_mut_uint8_t;
670
+
671
+ /** <No documentation available> */
672
+ typedef struct AwdlClientCallbacks {
673
+ /** <No documentation available> */
674
+ void (*start_searching)(void *, char const *, char const *);
675
+
676
+ /** <No documentation available> */
677
+ void (*stop_searching)(void *);
678
+
679
+ /** <No documentation available> */
680
+ void (*request_connect)(void *, char const *);
681
+
682
+ /** <No documentation available> */
683
+ void (*request_disconnect)(void *, char const *);
684
+
685
+ /** <No documentation available> */
686
+ int32_t (*send_data)(void *, char const *, slice_ref_uint8_t);
687
+
688
+ /** <No documentation available> */
689
+ int32_t (*read_data)(void *, char const *, slice_mut_uint8_t);
690
+ } AwdlClientCallbacks_t;
691
+
692
+ /** <No documentation available> */
693
+ TransportHandle_AwdlClientPlatformEvent_t *
694
+ /* fn */ ditto_add_awdl_client_transport (
695
+ CDitto_t const * ditto,
696
+ AwdlClientCallbacks_t callbacks,
697
+ void * ctx,
698
+ void (*retain)(void *),
699
+ void (*release)(void *));
700
+
701
+ /** <No documentation available> */
702
+ typedef struct AwdlServerCallbacks {
703
+ /** <No documentation available> */
704
+ void (*start_advertising)(void *, char const *, char const *);
705
+
706
+ /** <No documentation available> */
707
+ void (*stop_advertising)(void *);
708
+
709
+ /** <No documentation available> */
710
+ void (*request_disconnect)(void *, int64_t);
711
+
712
+ /** <No documentation available> */
713
+ int32_t (*send_data)(void *, int64_t, slice_ref_uint8_t);
714
+
715
+ /** <No documentation available> */
716
+ int32_t (*read_data)(void *, int64_t, slice_mut_uint8_t);
717
+ } AwdlServerCallbacks_t;
718
+
719
+ /** <No documentation available> */
720
+ TransportHandle_AwdlServerPlatformEvent_t *
721
+ /* fn */ ditto_add_awdl_server_transport (
722
+ CDitto_t const * ditto,
723
+ AwdlServerCallbacks_t callbacks,
724
+ void * ctx,
725
+ void (*retain)(void *),
726
+ void (*release)(void *));
727
+
728
+
729
+ #include <stdbool.h>
730
+
731
+ /** \brief
732
+ * Rust-level representation of the result of a send operation, converted from
733
+ * a bitfield
734
+ */
735
+ typedef struct SendResult {
736
+ /** <No documentation available> */
737
+ bool accepted;
738
+
739
+ /** <No documentation available> */
740
+ bool wait_for_ready;
741
+ } SendResult_t;
742
+
743
+ /** <No documentation available> */
744
+ typedef struct BleClientCallbacks {
745
+ /** <No documentation available> */
746
+ void (*start_scanning)(void *, uint8_16_array_t const *, slice_ref_uint8_t);
747
+
748
+ /** <No documentation available> */
749
+ void (*stop_scanning)(void *);
750
+
751
+ /** <No documentation available> */
752
+ OnlineState_t (*scanning_state)(void *);
753
+
754
+ /** <No documentation available> */
755
+ void (*connect_peripheral)(void *, uint8_16_array_t const *);
756
+
757
+ /** <No documentation available> */
758
+ void (*disconnect_peripheral)(void *, uint8_16_array_t const *);
759
+
760
+ /** <No documentation available> */
761
+ SendResult_t (*write_to_peripheral)(void *, BleDataType_t, uint8_16_array_t const *, slice_ref_uint8_t);
762
+
763
+ /** <No documentation available> */
764
+ int32_t (*read_l2cap_from_peripheral)(void *, uint8_16_array_t const *, slice_mut_uint8_t);
765
+
766
+ /** <No documentation available> */
767
+ int32_t (*send_l2cap_to_peripheral)(void *, uint8_16_array_t const *, slice_ref_uint8_t);
768
+ } BleClientCallbacks_t;
769
+
770
+ /** <No documentation available> */
771
+ TransportHandle_BleClientPlatformEvent_t *
772
+ /* fn */ ditto_add_ble_client_transport (
773
+ CDitto_t const * ditto,
774
+ BleClientCallbacks_t callbacks,
775
+ void * ctx,
776
+ void (*retain)(void *),
777
+ void (*release)(void *));
778
+
779
+ /** <No documentation available> */
780
+ typedef struct BleServerCallbacks {
781
+ /** <No documentation available> */
782
+ void (*start_advertising)(void *, uint8_16_array_t const *, slice_ref_uint8_t);
783
+
784
+ /** <No documentation available> */
785
+ void (*stop_advertising)(void *);
786
+
787
+ /** <No documentation available> */
788
+ OnlineState_t (*advertising_state)(void *);
789
+
790
+ /** <No documentation available> */
791
+ SendResult_t (*notify_to_central)(void *, BleDataType_t, uint8_16_array_t const *, slice_ref_uint8_t);
792
+
793
+ /** <No documentation available> */
794
+ int32_t (*read_l2cap_from_central)(void *, uint8_16_array_t const *, slice_mut_uint8_t);
795
+
796
+ /** <No documentation available> */
797
+ int32_t (*send_l2cap_to_central)(void *, uint8_16_array_t const *, slice_ref_uint8_t);
798
+ } BleServerCallbacks_t;
799
+
800
+ /** <No documentation available> */
801
+ TransportHandle_BleServerPlatformEvent_t *
802
+ /* fn */ ditto_add_ble_server_transport (
803
+ CDitto_t const * ditto,
804
+ BleServerCallbacks_t callbacks,
805
+ void * ctx,
806
+ void (*retain)(void *),
807
+ void (*release)(void *));
808
+
809
+ /** <No documentation available> */
810
+ typedef struct MdnsClientCallbacks {
811
+ /** <No documentation available> */
812
+ void (*start_searching)(void *, char const *);
813
+
814
+ /** <No documentation available> */
815
+ void (*stop_searching)(void *);
816
+
817
+ /** <No documentation available> */
818
+ void (*resolve_service)(void *, slice_ref_uint8_t);
819
+ } MdnsClientCallbacks_t;
820
+
821
+ /** \brief
822
+ * An opaque handle for each installed transport, heap-allocated and owned by
823
+ * the SDK.
824
+ *
825
+ * A pointer to this handle is used to send platform events over FFI. In the
826
+ * future this handle will be the SDK's only point of control over the
827
+ * transport once created. In particular, a transport will be removed by
828
+ * freeing the handle. The concept of online and offline will be eliminated.
829
+ * (i.e., if you don't want a transport, remove it.)
830
+ *
831
+ * For now, the `Peer` object holds the transports and provides an API based on
832
+ * a numeric id assigned to each transport instance. Until that is removed, the
833
+ * id still exists and the SDK can request it from the opaque handle over FFI.
834
+ *
835
+ * For each transport type, define an `extern "C"` function to free that
836
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
837
+ * plus a function to retrieve the transport id, which will be removed later.
838
+ *
839
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
840
+ * that it does not use the pointer to the `TransportHandle` after freeing it
841
+ * with its respective function. In Rust we will assume it is okay to unsafely
842
+ * dereference a handle.
843
+ *
844
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
845
+ */
846
+ typedef struct TransportHandle_MdnsClientPlatformEvent TransportHandle_MdnsClientPlatformEvent_t;
847
+
848
+ /** <No documentation available> */
849
+ TransportHandle_MdnsClientPlatformEvent_t *
850
+ /* fn */ ditto_add_mdns_client_transport (
851
+ CDitto_t const * ditto,
852
+ MdnsClientCallbacks_t callbacks,
853
+ void * ctx,
854
+ void (*retain)(void *),
855
+ void (*release)(void *));
856
+
857
+ /** <No documentation available> */
858
+ typedef struct MdnsServerCallbacks {
859
+ /** <No documentation available> */
860
+ void (*start_advertising)(void *, char const *, char const *, uint16_t);
861
+
862
+ /** <No documentation available> */
863
+ void (*stop_advertising)(void *);
864
+ } MdnsServerCallbacks_t;
865
+
866
+ /** \brief
867
+ * An opaque handle for each installed transport, heap-allocated and owned by
868
+ * the SDK.
869
+ *
870
+ * A pointer to this handle is used to send platform events over FFI. In the
871
+ * future this handle will be the SDK's only point of control over the
872
+ * transport once created. In particular, a transport will be removed by
873
+ * freeing the handle. The concept of online and offline will be eliminated.
874
+ * (i.e., if you don't want a transport, remove it.)
875
+ *
876
+ * For now, the `Peer` object holds the transports and provides an API based on
877
+ * a numeric id assigned to each transport instance. Until that is removed, the
878
+ * id still exists and the SDK can request it from the opaque handle over FFI.
879
+ *
880
+ * For each transport type, define an `extern "C"` function to free that
881
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
882
+ * plus a function to retrieve the transport id, which will be removed later.
883
+ *
884
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
885
+ * that it does not use the pointer to the `TransportHandle` after freeing it
886
+ * with its respective function. In Rust we will assume it is okay to unsafely
887
+ * dereference a handle.
888
+ *
889
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
890
+ */
891
+ typedef struct TransportHandle_MdnsServerPlatformEvent TransportHandle_MdnsServerPlatformEvent_t;
892
+
893
+ /** <No documentation available> */
894
+ TransportHandle_MdnsServerPlatformEvent_t *
895
+ /* fn */ ditto_add_mdns_server_transport (
896
+ CDitto_t const * ditto,
897
+ MdnsServerCallbacks_t callbacks,
898
+ void * ctx,
899
+ void (*retain)(void *),
900
+ void (*release)(void *));
901
+
902
+ /** \brief
903
+ * The direction to sort the results of a query.
904
+ */
905
+ typedef enum QuerySortDirection {
906
+ /** <No documentation available> */
907
+ QUERY_SORT_DIRECTION_ASCENDING = 1,
908
+ /** <No documentation available> */
909
+ QUERY_SORT_DIRECTION_DESCENDING,
910
+ } QuerySortDirection_t;
911
+
912
+ /** \brief
913
+ * OrderBy Parameter
914
+ */
915
+ typedef struct COrderByParam {
916
+ /** <No documentation available> */
917
+ char const * query_c_str;
918
+
919
+ /** <No documentation available> */
920
+ QuerySortDirection_t direction;
921
+ } COrderByParam_t;
922
+
923
+ /** \brief
924
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
925
+ *
926
+ * # C layout (for some given type T)
927
+ *
928
+ * ```c
929
+ * typedef struct {
930
+ * // Cannot be NULL
931
+ * T * ptr;
932
+ * size_t len;
933
+ * } slice_T;
934
+ * ```
935
+ *
936
+ * # Nullable pointer?
937
+ *
938
+ * If you want to support the above typedef, but where the `ptr` field is
939
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
940
+ * use the `Option< slice_ptr<_> >` type.
941
+ */
942
+ typedef struct slice_ref_COrderByParam {
943
+ /** \brief
944
+ * Pointer to the first element (if any).
945
+ */
946
+ COrderByParam_t const * ptr;
947
+
948
+ /** \brief
949
+ * Element count
950
+ */
951
+ size_t len;
952
+ } slice_ref_COrderByParam_t;
953
+
954
+ /** <No documentation available> */
955
+ int32_t
956
+ /* fn */ ditto_add_subscription (
957
+ CDitto_t const * ditto,
958
+ char const * collection,
959
+ char const * query,
960
+ slice_ref_uint8_t query_args_cbor,
961
+ slice_ref_COrderByParam_t order_by,
962
+ int32_t limit,
963
+ uint32_t offset);
964
+
965
+ /** <No documentation available> */
966
+ typedef struct LegacySubscriptionHandle LegacySubscriptionHandle_t;
967
+
968
+ /** <No documentation available> */
969
+ typedef struct LegacySubscriptionHandleResult {
970
+ /** <No documentation available> */
971
+ int32_t status_code;
972
+
973
+ /** <No documentation available> */
974
+ LegacySubscriptionHandle_t * handle;
975
+ } LegacySubscriptionHandleResult_t;
976
+
977
+ /** \brief
978
+ * Helper function for GC-sensitive SDKs to ensure proper unregistering of the subscription in the
979
+ * future.
980
+ *
981
+ * Indeed, the state contained in the `LegacySubscriptionHandle` is otherwise difficult for the
982
+ * SDK to keep alive once "finalizing the world" has started: some of this state (such as some of
983
+ * the individual items of `order_by`) may have been disposed of already, which makes it impossible
984
+ * to then properly call `ditto_remove_subscription()`.
985
+ */
986
+ LegacySubscriptionHandleResult_t
987
+ /* fn */ ditto_add_subscription_with_easier_unregistering (
988
+ CDitto_t const * ditto,
989
+ char const * collection,
990
+ char const * query,
991
+ slice_ref_uint8_t query_args_cbor,
992
+ slice_ref_COrderByParam_t order_bys,
993
+ int32_t limit,
994
+ uint32_t offset);
995
+
996
+ /** <No documentation available> */
997
+ typedef struct WifiAwareClientCallbacks {
998
+ /** <No documentation available> */
999
+ void (*start_searching)(void *, char const *, char const *);
1000
+
1001
+ /** <No documentation available> */
1002
+ void (*stop_searching)(void *);
1003
+
1004
+ /** <No documentation available> */
1005
+ void (*create_network)(void *, char const *);
1006
+
1007
+ /** <No documentation available> */
1008
+ void (*update_peer)(void *, char const *, ConnectState_t);
1009
+ } WifiAwareClientCallbacks_t;
1010
+
1011
+ /** \brief
1012
+ * An opaque handle for each installed transport, heap-allocated and owned by
1013
+ * the SDK.
1014
+ *
1015
+ * A pointer to this handle is used to send platform events over FFI. In the
1016
+ * future this handle will be the SDK's only point of control over the
1017
+ * transport once created. In particular, a transport will be removed by
1018
+ * freeing the handle. The concept of online and offline will be eliminated.
1019
+ * (i.e., if you don't want a transport, remove it.)
1020
+ *
1021
+ * For now, the `Peer` object holds the transports and provides an API based on
1022
+ * a numeric id assigned to each transport instance. Until that is removed, the
1023
+ * id still exists and the SDK can request it from the opaque handle over FFI.
1024
+ *
1025
+ * For each transport type, define an `extern "C"` function to free that
1026
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
1027
+ * plus a function to retrieve the transport id, which will be removed later.
1028
+ *
1029
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
1030
+ * that it does not use the pointer to the `TransportHandle` after freeing it
1031
+ * with its respective function. In Rust we will assume it is okay to unsafely
1032
+ * dereference a handle.
1033
+ *
1034
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
1035
+ */
1036
+ typedef struct TransportHandle_WifiAwareClientPlatformEvent TransportHandle_WifiAwareClientPlatformEvent_t;
1037
+
1038
+ /** <No documentation available> */
1039
+ TransportHandle_WifiAwareClientPlatformEvent_t *
1040
+ /* fn */ ditto_add_wifi_aware_client_transport (
1041
+ CDitto_t const * ditto,
1042
+ WifiAwareClientCallbacks_t callbacks,
1043
+ void * ctx,
1044
+ void (*retain)(void *),
1045
+ void (*release)(void *));
1046
+
1047
+ /** <No documentation available> */
1048
+ typedef enum dittoffi_wifi_aware_system_parameter_u64 {
1049
+ /** <No documentation available> */
1050
+ DITTOFFI_WIFI_AWARE_SYSTEM_PARAMETER_U64_MAX_ERROR_COUNT,
1051
+ /** <No documentation available> */
1052
+ DITTOFFI_WIFI_AWARE_SYSTEM_PARAMETER_U64_RECENT_ERROR_DURATION_MS,
1053
+ /** <No documentation available> */
1054
+ DITTOFFI_WIFI_AWARE_SYSTEM_PARAMETER_U64_BACKGROUND_MODE,
1055
+ } dittoffi_wifi_aware_system_parameter_u64_t;
1056
+
1057
+ /** <No documentation available> */
1058
+ typedef struct WifiAwareServerCallbacks {
1059
+ /** <No documentation available> */
1060
+ void (*start_advertising)(void *, char const *, char const *, uint16_t);
1061
+
1062
+ /** <No documentation available> */
1063
+ void (*stop_advertising)(void *);
1064
+
1065
+ /** <No documentation available> */
1066
+ void (*update_peer)(void *, char const *, ConnectState_t);
1067
+
1068
+ /** <No documentation available> */
1069
+ void (*update_parameter_u64)(void *, dittoffi_wifi_aware_system_parameter_u64_t, uint64_t);
1070
+ } WifiAwareServerCallbacks_t;
1071
+
1072
+ /** \brief
1073
+ * An opaque handle for each installed transport, heap-allocated and owned by
1074
+ * the SDK.
1075
+ *
1076
+ * A pointer to this handle is used to send platform events over FFI. In the
1077
+ * future this handle will be the SDK's only point of control over the
1078
+ * transport once created. In particular, a transport will be removed by
1079
+ * freeing the handle. The concept of online and offline will be eliminated.
1080
+ * (i.e., if you don't want a transport, remove it.)
1081
+ *
1082
+ * For now, the `Peer` object holds the transports and provides an API based on
1083
+ * a numeric id assigned to each transport instance. Until that is removed, the
1084
+ * id still exists and the SDK can request it from the opaque handle over FFI.
1085
+ *
1086
+ * For each transport type, define an `extern "C"` function to free that
1087
+ * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
1088
+ * plus a function to retrieve the transport id, which will be removed later.
1089
+ *
1090
+ * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
1091
+ * that it does not use the pointer to the `TransportHandle` after freeing it
1092
+ * with its respective function. In Rust we will assume it is okay to unsafely
1093
+ * dereference a handle.
1094
+ *
1095
+ * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
1096
+ */
1097
+ typedef struct TransportHandle_WifiAwareServerPlatformEvent TransportHandle_WifiAwareServerPlatformEvent_t;
1098
+
1099
+ /** <No documentation available> */
1100
+ TransportHandle_WifiAwareServerPlatformEvent_t *
1101
+ /* fn */ ditto_add_wifi_aware_server_advertiser (
1102
+ CDitto_t const * ditto,
1103
+ WifiAwareServerCallbacks_t callbacks,
1104
+ void * ctx,
1105
+ void (*retain)(void *),
1106
+ void (*release)(void *));
1107
+
1108
+ /** <No documentation available> */
1109
+ char *
1110
+ /* fn */ ditto_auth_client_get_app_id (
1111
+ CDitto_t const * ditto);
1112
+
1113
+ /** <No documentation available> */
1114
+ uint64_t
1115
+ /* fn */ ditto_auth_client_get_site_id (
1116
+ CDitto_t const * ditto);
1117
+
1118
+ /** <No documentation available> */
1119
+ int32_t
1120
+ /* fn */ ditto_auth_client_is_web_valid (
1121
+ CDitto_t const * ditto);
1122
+
1123
+ /** <No documentation available> */
1124
+ int32_t
1125
+ /* fn */ ditto_auth_client_login_with_credentials (
1126
+ CDitto_t * ditto,
1127
+ char const * username,
1128
+ char const * password,
1129
+ char const * provider);
1130
+
1131
+ /** <No documentation available> */
1132
+ int32_t
1133
+ /* fn */ ditto_auth_client_login_with_token (
1134
+ CDitto_t * ditto,
1135
+ char const * token,
1136
+ char const * provider);
1137
+
1138
+ /** <No documentation available> */
1139
+ typedef struct BoxedCharPtrResult {
1140
+ /** <No documentation available> */
1141
+ int32_t status_code;
1142
+
1143
+ /** <No documentation available> */
1144
+ char * c_string;
1145
+ } BoxedCharPtrResult_t;
1146
+
1147
+ /** <No documentation available> */
1148
+ BoxedCharPtrResult_t
1149
+ /* fn */ ditto_auth_client_login_with_token_and_feedback (
1150
+ CDitto_t const * ditto,
1151
+ char const * token,
1152
+ char const * provider);
1153
+
1154
+ /** \brief
1155
+ * Trigger an explicit logout and purge of any cached credentials
1156
+ */
1157
+ int32_t
1158
+ /* fn */ ditto_auth_client_logout (
1159
+ CDitto_t const * ditto);
1160
+
1161
+ /** \brief
1162
+ * An `SdkLoginProvider` that sends the notifications over FFI
1163
+ */
1164
+ typedef struct CLoginProvider CLoginProvider_t;
1165
+
1166
+ /** \brief
1167
+ * Create a LoginProvider. Ownership passes to the SDK.
1168
+ *
1169
+ * This cannot be freed directly - it should be passed in when creating an
1170
+ * AuthClient.
1171
+ */
1172
+ CLoginProvider_t *
1173
+ /* fn */ ditto_auth_client_make_login_provider (
1174
+ void * ctx,
1175
+ void (*retain)(void *),
1176
+ void (*release)(void *),
1177
+ void (*expiring_cb)(void *, uint32_t));
1178
+
1179
+ /** <No documentation available> */
1180
+ char *
1181
+ /* fn */ ditto_auth_client_user_id (
1182
+ CDitto_t const * ditto);
1183
+
1184
+ /** <No documentation available> */
1185
+ void
1186
+ /* fn */ ditto_auth_login_provider_free (
1187
+ CLoginProvider_t * login_provider);
1188
+
1189
+ /** <No documentation available> */
1190
+ void
1191
+ /* fn */ ditto_auth_set_login_provider (
1192
+ CDitto_t const * ditto,
1193
+ CLoginProvider_t * login_provider);
1194
+
1195
+ /** \brief
1196
+ * [`Box`][`rust::Box`]`<[T]>` (fat pointer to a slice),
1197
+ * but with a guaranteed `#[repr(C)]` layout.
1198
+ *
1199
+ * # C layout (for some given type T)
1200
+ *
1201
+ * ```c
1202
+ * typedef struct {
1203
+ * // Cannot be NULL
1204
+ * T * ptr;
1205
+ * size_t len;
1206
+ * } slice_T;
1207
+ * ```
1208
+ *
1209
+ * # Nullable pointer?
1210
+ *
1211
+ * If you want to support the above typedef, but where the `ptr` field is
1212
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
1213
+ * use the `Option< slice_ptr<_> >` type.
1214
+ */
1215
+ typedef struct slice_boxed_uint8 {
1216
+ /** \brief
1217
+ * Pointer to the first element (if any).
1218
+ */
1219
+ uint8_t * ptr;
1220
+
1221
+ /** \brief
1222
+ * Element count
1223
+ */
1224
+ size_t len;
1225
+ } slice_boxed_uint8_t;
1226
+
1227
+ /** \brief
1228
+ * Releases a byte array value returned by DittoStore.
1229
+ *
1230
+ * DittoStore manages its own memory allocations and it is not safe to release
1231
+ * such values with C's `free()`. That's why the structures it returns provide
1232
+ * their own associated `free` function.
1233
+ *
1234
+ * It should be used for values returned by functions like
1235
+ * `ditto_document_cbor`.
1236
+ */
1237
+ void
1238
+ /* fn */ ditto_c_bytes_free (
1239
+ slice_boxed_uint8_t bytes);
1240
+
1241
+ /** \brief
1242
+ * Releases `char *` value returned by DittoStore.
1243
+ *
1244
+ * DittoStore manages its own memory allocations and it is not safe to release
1245
+ * such values with C's `free()`. That's why the structures it returns provide
1246
+ * their own associated `free` function and this is one we need for `char *`.
1247
+ *
1248
+ * It should be used for values returned by functions like
1249
+ * `ditto_document_id_query_compatible`.
1250
+ */
1251
+ void
1252
+ /* fn */ ditto_c_string_free (
1253
+ char * s);
1254
+
1255
+ /** <No documentation available> */
1256
+ typedef struct DittoCancellable DittoCancellable_t;
1257
+
1258
+ /** <No documentation available> */
1259
+ void
1260
+ /* fn */ ditto_cancel (
1261
+ DittoCancellable_t * _cancelable);
1262
+
1263
+ /** \brief
1264
+ * Cancels a resolve callback registered by ditto_resolve_attachment.
1265
+ *
1266
+ * Returns following error codes:
1267
+ *
1268
+ * * `0` -- no error
1269
+ * * `1` -- an error
1270
+ * * `2` -- invalid id
1271
+ * * `3` -- token never issued
1272
+ *
1273
+ * In case of a non-zero return value, error message can be retrieved using
1274
+ * `ditto_error_message` function.
1275
+ */
1276
+ uint32_t
1277
+ /* fn */ ditto_cancel_resolve_attachment (
1278
+ CDitto_t const * ditto,
1279
+ slice_ref_uint8_t id,
1280
+ uint64_t cancel_token);
1281
+
1282
+ /** \brief
1283
+ * The `PathAccessorType` enum allows you to specify (usually from the SDK side
1284
+ * of the FFI) what sort of type you’re trying to access. So for some of the
1285
+ * cases in the enum, e.g. `String`, `Bool`, etc, it’s quite straightforward
1286
+ * what you’re asking for. For something like `Int` it’s a little more complex
1287
+ * in that if the value at the path you’ve provided is an integer _or_ a float
1288
+ * (with no fractional part to it) then it’ll return an integer to you. For
1289
+ * `Array` or `Object` it’ll give you back an array or an object (respectively)
1290
+ * if either the value at the path provided is a `Register` containing an
1291
+ * array/object or if the value at the path provided is an `RGA`/`RWMap`,
1292
+ * respectively.
1293
+ *
1294
+ * There are then the explicit type accessor type cases in that enum, e.g.
1295
+ * `Counter`, `Register`, etc which will only return a value if the “active”
1296
+ * value (most recently updated) at the provided path is a CRDT of the
1297
+ * specified type, otherwise `None` will be returned.
1298
+ */
1299
+ typedef enum PathAccessorType {
1300
+ /** <No documentation available> */
1301
+ PATH_ACCESSOR_TYPE_STRING,
1302
+ /** <No documentation available> */
1303
+ PATH_ACCESSOR_TYPE_NUMBER,
1304
+ /** <No documentation available> */
1305
+ PATH_ACCESSOR_TYPE_INT,
1306
+ /** <No documentation available> */
1307
+ PATH_ACCESSOR_TYPE_U_INT,
1308
+ /** <No documentation available> */
1309
+ PATH_ACCESSOR_TYPE_FLOAT,
1310
+ /** <No documentation available> */
1311
+ PATH_ACCESSOR_TYPE_DOUBLE,
1312
+ /** <No documentation available> */
1313
+ PATH_ACCESSOR_TYPE_BOOL,
1314
+ /** <No documentation available> */
1315
+ PATH_ACCESSOR_TYPE_NULL,
1316
+ /** <No documentation available> */
1317
+ PATH_ACCESSOR_TYPE_OBJECT,
1318
+ /** <No documentation available> */
1319
+ PATH_ACCESSOR_TYPE_ARRAY,
1320
+ /** <No documentation available> */
1321
+ PATH_ACCESSOR_TYPE_ANY,
1322
+ /** <No documentation available> */
1323
+ PATH_ACCESSOR_TYPE_COUNTER,
1324
+ /** <No documentation available> */
1325
+ PATH_ACCESSOR_TYPE_REGISTER,
1326
+ /** <No documentation available> */
1327
+ PATH_ACCESSOR_TYPE_ATTACHMENT,
1328
+ /** <No documentation available> */
1329
+ PATH_ACCESSOR_TYPE_R_W_MAP,
1330
+ } PathAccessorType_t;
1331
+
1332
+ /** <No documentation available> */
1333
+ typedef struct CBORPathResult {
1334
+ /** <No documentation available> */
1335
+ int32_t status_code;
1336
+
1337
+ /** <No documentation available> */
1338
+ slice_boxed_uint8_t cbor;
1339
+ } CBORPathResult_t;
1340
+
1341
+ /** \brief
1342
+ * Gets the CBOR value at the path in the provided CBOR and returns it if the
1343
+ * value found matches the type requested, otherwise `None` will be returned in
1344
+ * the result.
1345
+ *
1346
+ * If CBOR is returned in the result then the bytes have to be released with
1347
+ * `::ditto_c_bytes_free`.
1348
+ */
1349
+ CBORPathResult_t
1350
+ /* fn */ ditto_cbor_get_cbor_with_path_type (
1351
+ slice_ref_uint8_t cbor,
1352
+ char const * path,
1353
+ PathAccessorType_t path_type);
1354
+
1355
+ /** \brief
1356
+ * Represents the error code as returned by various FFI functions. It's a
1357
+ * simple integer for now, the codes are specified by each FFI function
1358
+ * individually (for now, we plan to introduce a proper error type in the near
1359
+ * future).
1360
+ * Beware that all errors are not captured here. It is encouraged to use this enum
1361
+ * instead of explicit `status_code` -mostly 0 and 1-.
1362
+ */
1363
+ typedef enum DittoErrorCode {
1364
+ /** <No documentation available> */
1365
+ DITTO_ERROR_CODE_OK = 0,
1366
+ /** <No documentation available> */
1367
+ DITTO_ERROR_CODE_UNKNOWN = 1,
1368
+ /** <No documentation available> */
1369
+ DITTO_ERROR_CODE_NOT_IMPLEMENTED = 2,
1370
+ /** \brief
1371
+ * Fatal case that ought to never happen.
1372
+ */
1373
+ DITTO_ERROR_CODE_UNREACHABLE = 2989,
1374
+ /** <No documentation available> */
1375
+ DITTO_ERROR_CODE_FAILED_TO_ACQUIRE_LOCK_FILE = 16777217,
1376
+ /** <No documentation available> */
1377
+ DITTO_ERROR_CODE_INVALID_PASSPHRASE = 33554433,
1378
+ /** <No documentation available> */
1379
+ DITTO_ERROR_CODE_EXTRANEOUS_PASSPHRASE_GIVEN = 33554434,
1380
+ /** <No documentation available> */
1381
+ DITTO_ERROR_CODE_PASSPHRASE_NOT_GIVEN = 33554435,
1382
+ /** <No documentation available> */
1383
+ DITTO_ERROR_CODE_ALREADY_ENCRYPTED = 33554436,
1384
+ /** <No documentation available> */
1385
+ DITTO_ERROR_CODE_ENCRYPTION_FAILED = 33554437,
1386
+ /** <No documentation available> */
1387
+ DITTO_ERROR_CODE_CANNOT_BE_ENCRYPTED = 33554438,
1388
+ /** <No documentation available> */
1389
+ DITTO_ERROR_CODE_NOT_INITIALIZED = 33554439,
1390
+ /** <No documentation available> */
1391
+ DITTO_ERROR_CODE_SORT_FAILED = 50331649,
1392
+ /** <No documentation available> */
1393
+ DITTO_ERROR_CODE_DQL_FAILED_TO_COMPILE_QUERY = 50331650,
1394
+ /** <No documentation available> */
1395
+ DITTO_ERROR_CODE_DQL_UNSUPPORTED = 50331651,
1396
+ /** <No documentation available> */
1397
+ DITTO_ERROR_CODE_DQL_EXECUTION_FAILED = 50331652,
1398
+ /** <No documentation available> */
1399
+ DITTO_ERROR_CODE_PARAMETER_QUERY_FAILED = 50331653,
1400
+ } DittoErrorCode_t;
1401
+
1402
+ /** \brief
1403
+ * Changes the passphrase and re-encrypts all data. This can take a while,
1404
+ * progress is reported via the progress callback. Returns a progress token
1405
+ * or 0 if a _synchronous_ error occured, in which case the `error_code` out
1406
+ * parameter is set (see error code table below).
1407
+ *
1408
+ * Note that errors can also occur while the operation is in progress. Those
1409
+ * are typically IO errors and are reported via the progress callback.
1410
+ * The combination of `passphrase` and `newPassphrase` have the following
1411
+ * effects:
1412
+ *
1413
+ * - `passphrase = NULL` & `newPassphrase = NULL` -> No-op if not encrypted, otherwise error code
1414
+ * 3.
1415
+ *
1416
+ * - `passphrase = "123"` & `newPassphrase = "123"` -> No-op if encrypted and password is correct,
1417
+ * error code 2 if not encrypted, and error code 1 if encrypted but `passphrase` invalid.
1418
+ *
1419
+ * - `passphrase = NULL` & `newPassphrase = "123"` -> Add encryption. No-op if already encrypted
1420
+ * and passphrase matches, error code 4 if already encrypted but passphrase does not match.
1421
+ *
1422
+ * - `passphrase = "123"` & `newPassphrase = NULL` -> Remove encryption. No op
1423
+ * - if not encrypted.
1424
+ *
1425
+ * - `passphrase = "123"` & `newPassphrase = "456"` -> Re-encrypt. Error code 1 if passphrase
1426
+ * invalid.
1427
+ */
1428
+ DittoCancellable_t *
1429
+ /* fn */ ditto_change_passphrase (
1430
+ char const * _working_dir,
1431
+ char const * _old_passphrase,
1432
+ char const * _new_passphrase,
1433
+ void * _ctx,
1434
+ void (*_c_cb)(void *),
1435
+ DittoErrorCode_t * _error_code);
1436
+
1437
+ /** \brief
1438
+ * Deregister any presence callback, releasing the receiver on the SDK side.
1439
+ */
1440
+ void
1441
+ /* fn */ ditto_clear_presence_callback (
1442
+ CDitto_t const * ditto);
1443
+
1444
+ /** \brief
1445
+ * Deregister v1 presence callback, releasing the receiver on the SDK side.
1446
+ */
1447
+ void
1448
+ /* fn */ ditto_clear_presence_v1_callback (
1449
+ CDitto_t const * ditto);
1450
+
1451
+ /** \brief
1452
+ * Deregister v2 presence callback, releasing the receiver on the SDK side.
1453
+ */
1454
+ void
1455
+ /* fn */ ditto_clear_presence_v2_callback (
1456
+ CDitto_t const * ditto);
1457
+
1458
+ /** \brief
1459
+ * Deregister v3 presence callback, releasing the receiver on the SDK side.
1460
+ */
1461
+ void
1462
+ /* fn */ ditto_clear_presence_v3_callback (
1463
+ CDitto_t const * ditto);
1464
+
1465
+ /** <No documentation available> */
1466
+ int32_t
1467
+ /* fn */ ditto_collection (
1468
+ CDitto_t const * ditto,
1469
+ char const * name);
1470
+
1471
+ /** \brief
1472
+ * Write transaction synchronous API.
1473
+ */
1474
+ typedef struct CWriteTransaction CWriteTransaction_t;
1475
+
1476
+ /** <No documentation available> */
1477
+ typedef struct BoolResult {
1478
+ /** <No documentation available> */
1479
+ int32_t status_code;
1480
+
1481
+ /** <No documentation available> */
1482
+ bool bool_value;
1483
+ } BoolResult_t;
1484
+
1485
+ /** \brief
1486
+ * Evict a document from the collection, using the provided write transaction.
1487
+ *
1488
+ * `was_evicted` is set to indicate whether the document was removed
1489
+ * successfully.
1490
+ *
1491
+ * * [js only] Returns -1 in case of outstanding non-`await`ed transaction operation.
1492
+ */
1493
+ BoolResult_t
1494
+ /* fn */ ditto_collection_evict (
1495
+ CDitto_t const * ditto,
1496
+ char const * coll_name,
1497
+ CWriteTransaction_t * transaction,
1498
+ slice_ref_uint8_t id);
1499
+
1500
+ /** \brief
1501
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
1502
+ *
1503
+ * # C layout (for some given type T)
1504
+ *
1505
+ * ```c
1506
+ * typedef struct {
1507
+ * // Cannot be NULL
1508
+ * T * ptr;
1509
+ * size_t len;
1510
+ * } slice_T;
1511
+ * ```
1512
+ *
1513
+ * # Nullable pointer?
1514
+ *
1515
+ * If you want to support the above typedef, but where the `ptr` field is
1516
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
1517
+ * use the `Option< slice_ptr<_> >` type.
1518
+ */
1519
+ typedef struct slice_ref_slice_boxed_uint8 {
1520
+ /** \brief
1521
+ * Pointer to the first element (if any).
1522
+ */
1523
+ slice_boxed_uint8_t const * ptr;
1524
+
1525
+ /** \brief
1526
+ * Element count
1527
+ */
1528
+ size_t len;
1529
+ } slice_ref_slice_boxed_uint8_t;
1530
+
1531
+ /** \brief
1532
+ * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
1533
+ */
1534
+ typedef struct Vec_slice_boxed_uint8 {
1535
+ /** <No documentation available> */
1536
+ slice_boxed_uint8_t * ptr;
1537
+
1538
+ /** <No documentation available> */
1539
+ size_t len;
1540
+
1541
+ /** <No documentation available> */
1542
+ size_t cap;
1543
+ } Vec_slice_boxed_uint8_t;
1544
+
1545
+ /** <No documentation available> */
1546
+ typedef struct DocIdsResult {
1547
+ /** <No documentation available> */
1548
+ int32_t status_code;
1549
+
1550
+ /** <No documentation available> */
1551
+ Vec_slice_boxed_uint8_t ids;
1552
+ } DocIdsResult_t;
1553
+
1554
+ /** \brief
1555
+ * Evict several documents from the collection, using the provided write transaction.
1556
+ *
1557
+ * Returns the list of successfully evicted document ids.
1558
+ *
1559
+ * * [js only] Returns -1 in case of outstanding non-`await`ed transaction operation.
1560
+ */
1561
+ DocIdsResult_t
1562
+ /* fn */ ditto_collection_evict_by_ids (
1563
+ CDitto_t const * ditto,
1564
+ char const * coll_name,
1565
+ CWriteTransaction_t * transaction,
1566
+ slice_ref_slice_boxed_uint8_t ids);
1567
+
1568
+ /** \brief
1569
+ * Evict all documents returned by the specified query from a collection.
1570
+ *
1571
+ * `out_ids` is set to the list of IDs of all documents successfully evicted.
1572
+ *
1573
+ * [js only] Returns -2 in case of outstanding non-awaited transaction operation.
1574
+ */
1575
+ DocIdsResult_t
1576
+ /* fn */ ditto_collection_evict_query_str (
1577
+ CDitto_t const * ditto,
1578
+ char const * coll_name,
1579
+ CWriteTransaction_t * transaction,
1580
+ char const * query,
1581
+ slice_ref_uint8_t query_args_cbor,
1582
+ slice_ref_COrderByParam_t order_by_params,
1583
+ int32_t limit,
1584
+ uint32_t offset);
1585
+
1586
+ /** \brief
1587
+ * Store document consisting of a `DocumentId` and `ditto_crdt::Document` pair.
1588
+ *
1589
+ * Within the `ditto_store` crate the association of these two elements is maintained together
1590
+ * within this single structure, while these elements may be stored separately in upstream or
1591
+ * downstream crates. This type corresponds to the `Record` type in the `replication` crate, rather
1592
+ * than a literal document.
1593
+ */
1594
+ typedef struct CDocument CDocument_t;
1595
+
1596
+ /** \brief
1597
+ * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
1598
+ */
1599
+ typedef struct Vec_CDocument_ptr {
1600
+ /** <No documentation available> */
1601
+ CDocument_t * * ptr;
1602
+
1603
+ /** <No documentation available> */
1604
+ size_t len;
1605
+
1606
+ /** <No documentation available> */
1607
+ size_t cap;
1608
+ } Vec_CDocument_ptr_t;
1609
+
1610
+ /** <No documentation available> */
1611
+ typedef struct DocumentsResult {
1612
+ /** <No documentation available> */
1613
+ int32_t status_code;
1614
+
1615
+ /** <No documentation available> */
1616
+ Vec_CDocument_ptr_t documents;
1617
+ } DocumentsResult_t;
1618
+
1619
+ /** \brief
1620
+ * Execute the specified query.
1621
+ *
1622
+ * `out_documents` is set to the list of all documents successfully retrieved
1623
+ * from the collection.
1624
+ *
1625
+ * [js only] Returns -2 in case of outstanding non-awaited transaction operation.
1626
+ */
1627
+ DocumentsResult_t
1628
+ /* fn */ ditto_collection_exec_query_str (
1629
+ CDitto_t const * ditto,
1630
+ char const * coll_name,
1631
+ CWriteTransaction_t * txn,
1632
+ char const * query,
1633
+ slice_ref_uint8_t query_args_cbor,
1634
+ slice_ref_COrderByParam_t order_by_params,
1635
+ int32_t limit,
1636
+ uint32_t offset);
1637
+
1638
+ /** \brief
1639
+ * Read transaction synchronous API.
1640
+ */
1641
+ typedef struct CReadTransaction CReadTransaction_t;
1642
+
1643
+ /** <No documentation available> */
1644
+ typedef struct DocumentsIdsResult {
1645
+ /** <No documentation available> */
1646
+ int32_t status_code;
1647
+
1648
+ /** <No documentation available> */
1649
+ Vec_CDocument_ptr_t documents;
1650
+
1651
+ /** <No documentation available> */
1652
+ Vec_slice_boxed_uint8_t ids;
1653
+ } DocumentsIdsResult_t;
1654
+
1655
+ /** \brief
1656
+ * [js only] Returns `-1` in case of outstanding non-`awaited` transaction operation.
1657
+ */
1658
+ DocumentsIdsResult_t
1659
+ /* fn */ ditto_collection_find_by_ids (
1660
+ CDitto_t const * ditto,
1661
+ char const * coll_name,
1662
+ slice_ref_slice_boxed_uint8_t ids,
1663
+ CReadTransaction_t * transaction);
1664
+
1665
+ /** <No documentation available> */
1666
+ typedef struct DocumentResult {
1667
+ /** <No documentation available> */
1668
+ int32_t status_code;
1669
+
1670
+ /** <No documentation available> */
1671
+ CDocument_t * document;
1672
+ } DocumentResult_t;
1673
+
1674
+ /** \brief
1675
+ * [js only] Returns `-1` in case of outstanding non-`awaited` transaction operation.
1676
+ */
1677
+ DocumentResult_t
1678
+ /* fn */ ditto_collection_get (
1679
+ CDitto_t const * _ditto,
1680
+ char const * coll_name,
1681
+ slice_ref_uint8_t id,
1682
+ CReadTransaction_t * transaction);
1683
+
1684
+ /** \brief
1685
+ * [js only] Returns `-1` in case of outstanding non-`awaited` transaction operation.
1686
+ */
1687
+ DocumentResult_t
1688
+ /* fn */ ditto_collection_get_with_write_transaction (
1689
+ CDitto_t const * _ditto,
1690
+ char const * coll_name,
1691
+ slice_ref_uint8_t id,
1692
+ CWriteTransaction_t * transaction);
1693
+
1694
+ /** \brief
1695
+ * The write strategies available when writing data to the store.
1696
+ */
1697
+ typedef enum WriteStrategyRs {
1698
+ /** \brief
1699
+ * Create or merge with existing data
1700
+ */
1701
+ WRITE_STRATEGY_RS_MERGE,
1702
+ /** \brief
1703
+ * Only insert if no document already exists with the same document ID
1704
+ */
1705
+ WRITE_STRATEGY_RS_INSERT_IF_ABSENT,
1706
+ /** \brief
1707
+ * Insert as default data, only if no document already exists with the same document ID
1708
+ */
1709
+ WRITE_STRATEGY_RS_INSERT_DEFAULT_IF_ABSENT,
1710
+ /** \brief
1711
+ * This works as follows:
1712
+ * - If the document does not exist, it is created with the given value
1713
+ * - If the document exists, the value is compared to the document's current value, any
1714
+ * differing leaf's values in the Document are updated to match the given value. Nothing is
1715
+ * removed.
1716
+ */
1717
+ WRITE_STRATEGY_RS_UPDATE_DIFFERENT_VALUES,
1718
+ } WriteStrategyRs_t;
1719
+
1720
+ /** <No documentation available> */
1721
+ typedef struct DocIdResult {
1722
+ /** <No documentation available> */
1723
+ int32_t status_code;
1724
+
1725
+ /** <No documentation available> */
1726
+ slice_boxed_uint8_t id;
1727
+ } DocIdResult_t;
1728
+
1729
+ /** \brief
1730
+ * Inserts a document into the store.
1731
+ *
1732
+ * If an ID is provided explicitly via the `doc_id` parameter then that will be
1733
+ * used as the document's ID. If an ID is provided implicitly via the
1734
+ * document's value (`doc_cbor`) then that will be used as the document's ID,
1735
+ * assuming no explicit ID was provided. If neither an explicit nor an implicit
1736
+ * document ID was provided then a new document ID will be generated and used
1737
+ * as the new document's ID.
1738
+ *
1739
+ * Return codes:
1740
+ *
1741
+ * * `0` -- success
1742
+ * * `1` -- improper CBOR provided for the document value
1743
+ * * `2` -- invalid CBOR for the document value (i.e. the CBOR could be parsed but it represented a
1744
+ * non-`Object` value)
1745
+ * * `3` -- unable to create document ID from value at `_id` key in document's value (`doc_cbor`
1746
+ * argument)
1747
+ * * `4` -- (js only) concurrent database operation (missing `await`?)
1748
+ */
1749
+ DocIdResult_t
1750
+ /* fn */ ditto_collection_insert_value (
1751
+ CDitto_t const * ditto,
1752
+ char const * coll_name,
1753
+ slice_ref_uint8_t doc_cbor,
1754
+ WriteStrategyRs_t write_strategy,
1755
+ char const * log_hint,
1756
+ CWriteTransaction_t * txn);
1757
+
1758
+ /** \brief
1759
+ * Remove a document from the collection, using the provided write transaction.
1760
+ *
1761
+ * `was_removed` is set to indicate whether the document was removed
1762
+ * successfully.
1763
+ *
1764
+ * * [js only] Returns -1 in case of outstanding non-`await`ed transaction operation.
1765
+ */
1766
+ BoolResult_t
1767
+ /* fn */ ditto_collection_remove (
1768
+ CDitto_t const * _ditto,
1769
+ char const * coll_name,
1770
+ CWriteTransaction_t * transaction,
1771
+ slice_ref_uint8_t id);
1772
+
1773
+ /** \brief
1774
+ * Remove documents from the collection, using the provided write transaction.
1775
+ *
1776
+ * Return the list of successfully removed DocumentId
1777
+ *
1778
+ * Will return an error if the number of keys is greater than 1024.
1779
+ * * [js only] Returns -1 in case of outstanding non-`await`ed transaction operation.
1780
+ */
1781
+ DocIdsResult_t
1782
+ /* fn */ ditto_collection_remove_by_ids (
1783
+ CDitto_t const * ditto,
1784
+ char const * coll_name,
1785
+ CWriteTransaction_t * transaction,
1786
+ slice_ref_slice_boxed_uint8_t ids);
1787
+
1788
+ /** \brief
1789
+ * Remove all documents returned by the specified query from a collection.
1790
+ *
1791
+ * `out_ids` is set to the list of IDs of all documents successfully removed.
1792
+ *
1793
+ * [js only] Returns -2 in case of outstanding non-awaited transaction operation.
1794
+ */
1795
+ DocIdsResult_t
1796
+ /* fn */ ditto_collection_remove_query_str (
1797
+ CDitto_t const * ditto,
1798
+ char const * coll_name,
1799
+ CWriteTransaction_t * transaction,
1800
+ char const * query,
1801
+ slice_ref_uint8_t query_args_cbor,
1802
+ slice_ref_COrderByParam_t order_by_params,
1803
+ int32_t limit,
1804
+ uint32_t offset);
1805
+
1806
+ /** \brief
1807
+ * [js only] Returns -1 in case of outstanding non-awaited transaction operation.
1808
+ */
1809
+ int32_t
1810
+ /* fn */ ditto_collection_update (
1811
+ CDitto_t const * _ditto,
1812
+ char const * coll_name,
1813
+ CWriteTransaction_t * transaction,
1814
+ CDocument_t * document);
1815
+
1816
+ /** \brief
1817
+ * Update multiple documents in a collection, using the provided write
1818
+ * transaction.
1819
+ *
1820
+ * # Return Values
1821
+ *
1822
+ * - Returns `0` if all links were successfully updated in all documents.
1823
+ * - Returns `-1` if one or more documents' links fail to all update
1824
+ * successfully, but all documents themselves are successfully updated. Note
1825
+ * that in the event of an attachment failing to update, updates are still
1826
+ * attempted on the rest of the attachments and the rest of the documents.
1827
+ * - If a document fails to update, the appropriate error code is returned for
1828
+ * the cause of the failure. Note that if a document fails to update, no more
1829
+ * document updates are attempted.
1830
+ */
1831
+ int32_t
1832
+ /* fn */ ditto_collection_update_multiple (
1833
+ CDitto_t const * _ditto,
1834
+ char const * coll_name,
1835
+ CWriteTransaction_t * transaction,
1836
+ Vec_CDocument_ptr_t documents);
1837
+
1838
+ /** <No documentation available> */
1839
+ int32_t
1840
+ /* fn */ ditto_disable_sync_with_v3 (
1841
+ CDitto_t const * ditto);
1842
+
1843
+ /** \brief
1844
+ * Supported components whose disk usage can be monitored separately.
1845
+ */
1846
+ /** \remark Has the same ABI as `uint8_t` **/
1847
+ #ifdef DOXYGEN
1848
+ typedef
1849
+ #endif
1850
+ enum FsComponent {
1851
+ /** \brief
1852
+ * The whole ditto working directory
1853
+ */
1854
+ FS_COMPONENT_ROOT = 0,
1855
+ /** \brief
1856
+ * The store component
1857
+ */
1858
+ FS_COMPONENT_STORE,
1859
+ /** \brief
1860
+ * The auth component
1861
+ */
1862
+ FS_COMPONENT_AUTH,
1863
+ /** \brief
1864
+ * The replication component
1865
+ */
1866
+ FS_COMPONENT_REPLICATION,
1867
+ /** \brief
1868
+ * The attachment component
1869
+ */
1870
+ FS_COMPONENT_ATTACHMENT,
1871
+ }
1872
+ #ifndef DOXYGEN
1873
+ ; typedef uint8_t
1874
+ #endif
1875
+ FsComponent_t;
1876
+
1877
+ /** \brief
1878
+ * Get a cbor repr of the disk usage
1879
+ */
1880
+ slice_boxed_uint8_t
1881
+ /* fn */ ditto_disk_usage (
1882
+ CDitto_t const * ditto,
1883
+ FsComponent_t path);
1884
+
1885
+ /** \brief
1886
+ * Document's CBOR
1887
+ */
1888
+ slice_boxed_uint8_t
1889
+ /* fn */ ditto_document_cbor (
1890
+ CDocument_t const * document);
1891
+
1892
+ /** \brief
1893
+ * Releases the document
1894
+ */
1895
+ void
1896
+ /* fn */ ditto_document_free (
1897
+ CDocument_t * document);
1898
+
1899
+ /** \brief
1900
+ * Gets the CBOR value at the path in the provided document and returns it if
1901
+ * the value found matches the type requested, otherwise `None` will be
1902
+ * returned in the result.
1903
+ *
1904
+ * To understand how this is intended to be used it might be instructive to see
1905
+ * how things work in the DittoDocumentPath of the Swift SDK, for example:
1906
+ * <https://github.com/getditto/ditto/blob/v2/cocoa/DittoSwift/Store/DittoDocumentPath.swift#L63-L277>
1907
+ *
1908
+ * where the valueAtPathInDocumentWithType implementation looks like this:
1909
+ * <https://github.com/getditto/ditto/blob/259cfa64dd2c6b36ffee2e97514695ccbfff6755/cocoa/DittoSwift/Store/Internal/ValueAtPath.swift#L42-L49>
1910
+ *
1911
+ * Note: all the of the values returned by
1912
+ * `ditto_document_get_cbor_with_path_type` are untyped (i.e. there’s never an
1913
+ * object with `_value` and `_ditto_internal_type_jkb12973t4b` keys being
1914
+ * returned). For example, if you request a value at a path with a
1915
+ * `PathAccessorType` of `Counter` and there is indeed a counter at that path
1916
+ * then the value (as CBOR) that will be returned will be the `f64`/`double`
1917
+ * representation of the counter’s value, on its own.
1918
+ *
1919
+ * If CBOR is returned in the result then the bytes have to be released with
1920
+ * `::ditto_c_bytes_free`.
1921
+ */
1922
+ CBORPathResult_t
1923
+ /* fn */ ditto_document_get_cbor_with_path_type (
1924
+ CDocument_t const * document,
1925
+ char const * pointer,
1926
+ PathAccessorType_t path_type);
1927
+
1928
+ /** \brief
1929
+ * Document's ID
1930
+ *
1931
+ * The resulting bytes have to be freed with `::ditto_c_bytes_free`
1932
+ */
1933
+ slice_boxed_uint8_t
1934
+ /* fn */ ditto_document_id (
1935
+ CDocument_t const * document);
1936
+
1937
+ /** \brief
1938
+ * Defines how string primitives should be encoded. This is relevant if a
1939
+ * document ID was created from a string. There are occasions when we want the
1940
+ * stringified representation of the document ID do include quotes around the
1941
+ * string, for example when creating a query like `_id == "abc"`. However,
1942
+ * there are also times when we want to return the string as just a string, for
1943
+ * example when we're injecting a document ID into a document's value before
1944
+ * then serializing the document and sending those bytes across the FFI
1945
+ * boundary.
1946
+ */
1947
+ typedef enum StringPrimitiveFormat {
1948
+ /** <No documentation available> */
1949
+ STRING_PRIMITIVE_FORMAT_WITH_QUOTES,
1950
+ /** <No documentation available> */
1951
+ STRING_PRIMITIVE_FORMAT_WITHOUT_QUOTES,
1952
+ } StringPrimitiveFormat_t;
1953
+
1954
+ /** \brief
1955
+ * Convert a document ID from CBOR bytes into a Ditto query language compatible
1956
+ * string.
1957
+ *
1958
+ * The resulting string has to be freed with `::ditto_c_string_free`
1959
+ */
1960
+ char *
1961
+ /* fn */ ditto_document_id_query_compatible (
1962
+ slice_ref_uint8_t id,
1963
+ StringPrimitiveFormat_t string_primitive_format);
1964
+
1965
+ /** <No documentation available> */
1966
+ int32_t
1967
+ /* fn */ ditto_document_increment_counter (
1968
+ CDocument_t * document,
1969
+ char const * pointer,
1970
+ double amount);
1971
+
1972
+ /** \brief
1973
+ * Removes a value from a document. Only object properties can be removed. If the
1974
+ * `pointer` points to an array index, the removal will fail. To update an array
1975
+ * within a register, see `ditto_document_update`.
1976
+ *
1977
+ * # Arguments
1978
+ *
1979
+ * * `document` - A pointer to the document which was previously returned from a query.
1980
+ * * `pointer` - A JMESPath _pointer_ to a property within `document` which is to be removed.
1981
+ *
1982
+ * # Returns
1983
+ *
1984
+ * `0` if the remove was successful or non-zero to indicate failure. To
1985
+ * retrieve an error message in the case of failure, call
1986
+ * `ditto_error_message()`.
1987
+ */
1988
+ int32_t
1989
+ /* fn */ ditto_document_remove (
1990
+ CDocument_t * document,
1991
+ char const * pointer);
1992
+
1993
+ /** <No documentation available> */
1994
+ int32_t
1995
+ /* fn */ ditto_document_set_cbor (
1996
+ CDocument_t * document,
1997
+ char const * pointer,
1998
+ slice_ref_uint8_t cbor);
1999
+
2000
+ /** <No documentation available> */
2001
+ int32_t
2002
+ /* fn */ ditto_document_set_cbor_with_timestamp (
2003
+ CDocument_t * document,
2004
+ char const * pointer,
2005
+ slice_ref_uint8_t cbor,
2006
+ uint32_t _timestamp);
2007
+
2008
+ /** \brief
2009
+ * Updates the document with values taken from provided CBOR data.
2010
+ *
2011
+ * Returns following error codes:
2012
+ *
2013
+ * * `0` -- no error
2014
+ * * `1` -- invalid CBOR data
2015
+ * * `2` -- CBOR data was not a map
2016
+ * * `3` -- update error
2017
+ * * `4` -- `_id` key provided
2018
+ * * `5` -- invalid value
2019
+ *
2020
+ * In case of a non-zero return value, error message can be retrieved using
2021
+ * `::ditto_error_message` function.
2022
+ */
2023
+ int32_t
2024
+ /* fn */ ditto_document_update (
2025
+ CDocument_t * document,
2026
+ slice_ref_uint8_t cbor);
2027
+
2028
+ /** \brief
2029
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
2030
+ *
2031
+ * # C layout (for some given type T)
2032
+ *
2033
+ * ```c
2034
+ * typedef struct {
2035
+ * // Cannot be NULL
2036
+ * T * ptr;
2037
+ * size_t len;
2038
+ * } slice_T;
2039
+ * ```
2040
+ *
2041
+ * # Nullable pointer?
2042
+ *
2043
+ * If you want to support the above typedef, but where the `ptr` field is
2044
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
2045
+ * use the `Option< slice_ptr<_> >` type.
2046
+ */
2047
+ typedef struct slice_ref_CDocument_ptr {
2048
+ /** \brief
2049
+ * Pointer to the first element (if any).
2050
+ */
2051
+ CDocument_t * const * ptr;
2052
+
2053
+ /** \brief
2054
+ * Element count
2055
+ */
2056
+ size_t len;
2057
+ } slice_ref_CDocument_ptr_t;
2058
+
2059
+ /** <No documentation available> */
2060
+ typedef struct U64Result {
2061
+ /** <No documentation available> */
2062
+ int32_t status_code;
2063
+
2064
+ /** <No documentation available> */
2065
+ uint64_t u64;
2066
+ } U64Result_t;
2067
+
2068
+ /** <No documentation available> */
2069
+ U64Result_t
2070
+ /* fn */ ditto_documents_hash (
2071
+ slice_ref_CDocument_ptr_t documents);
2072
+
2073
+ /** <No documentation available> */
2074
+ BoxedCharPtrResult_t
2075
+ /* fn */ ditto_documents_hash_mnemonic (
2076
+ slice_ref_CDocument_ptr_t documents);
2077
+
2078
+ /** \brief
2079
+ * Retrieves last thread-local error message (used by some synchronous APIs)
2080
+ * and removes it. Subsequent call to this function (if nothing else has
2081
+ * happened) will always return `NULL`.
2082
+ *
2083
+ * Returns `NULL` if there was no error. A non-null result MUST be freed using
2084
+ * `ditto_c_string_free`.
2085
+ */
2086
+ char *
2087
+ /* fn */ ditto_error_message (void);
2088
+
2089
+ /** \brief
2090
+ * Retrieves last thread-local error message (used by some synchronous APIs)
2091
+ * and retains ownership of it.
2092
+ *
2093
+ * Returns `NULL` if there was no error. A non-null result MUST be freed using
2094
+ * `ditto_c_string_free`.
2095
+ */
2096
+ char *
2097
+ /* fn */ ditto_error_message_peek (void);
2098
+
2099
+ /** <No documentation available> */
2100
+ typedef struct CIdentityConfig CIdentityConfig_t;
2101
+
2102
+ /** \brief
2103
+ * Whether or not history tracking is enabled.
2104
+ */
2105
+ typedef enum HistoryTracking {
2106
+ /** \brief
2107
+ * History tracking is enabled.
2108
+ */
2109
+ HISTORY_TRACKING_ENABLED,
2110
+ /** \brief
2111
+ * History tracking is disabled.
2112
+ */
2113
+ HISTORY_TRACKING_DISABLED,
2114
+ } HistoryTracking_t;
2115
+
2116
+ /** \brief
2117
+ * Same as `ditto_make()`, only takes an additional `passphrase` and an out
2118
+ * `error_code` parameter.
2119
+ *
2120
+ * Returns the Ditto pointer on success. On failure, returns `NULL` and sets the
2121
+ * out `error_code` parameter (1 or 2 possible here, plus IO errors).
2122
+ */
2123
+ CDitto_t *
2124
+ /* fn */ ditto_experimental_make_with_passphrase (
2125
+ char const * working_dir,
2126
+ CIdentityConfig_t * identity_config,
2127
+ HistoryTracking_t history_tracking,
2128
+ char const * passphrase,
2129
+ DittoErrorCode_t * error_code);
2130
+
2131
+ /** \brief
2132
+ * Frees the `Ditto` object.
2133
+ *
2134
+ * It is expected that `ditto_shutdown` will have been called before this is called.
2135
+ */
2136
+ void
2137
+ /* fn */ ditto_free (
2138
+ CDitto_t * ditto);
2139
+
2140
+ /** \brief
2141
+ * A shared read-only reference to an existing Attachment.
2142
+ */
2143
+ typedef struct AttachmentHandle AttachmentHandle_t;
2144
+
2145
+ /** <No documentation available> */
2146
+ void
2147
+ /* fn */ ditto_free_attachment_handle (
2148
+ AttachmentHandle_t * handle);
2149
+
2150
+ /** \brief
2151
+ * [`Box`][`rust::Box`]`<[T]>` (fat pointer to a slice),
2152
+ * but with a guaranteed `#[repr(C)]` layout.
2153
+ *
2154
+ * # C layout (for some given type T)
2155
+ *
2156
+ * ```c
2157
+ * typedef struct {
2158
+ * // Cannot be NULL
2159
+ * T * ptr;
2160
+ * size_t len;
2161
+ * } slice_T;
2162
+ * ```
2163
+ *
2164
+ * # Nullable pointer?
2165
+ *
2166
+ * If you want to support the above typedef, but where the `ptr` field is
2167
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
2168
+ * use the `Option< slice_ptr<_> >` type.
2169
+ */
2170
+ typedef struct slice_boxed_size {
2171
+ /** \brief
2172
+ * Pointer to the first element (if any).
2173
+ */
2174
+ size_t * ptr;
2175
+
2176
+ /** \brief
2177
+ * Element count
2178
+ */
2179
+ size_t len;
2180
+ } slice_boxed_size_t;
2181
+
2182
+ /** \brief
2183
+ * Frees a `slice_box_size_t`, used in `c_cb_params`.
2184
+ */
2185
+ void
2186
+ /* fn */ ditto_free_indices (
2187
+ slice_boxed_size_t indices);
2188
+
2189
+ /** <No documentation available> */
2190
+ typedef struct AttachmentHandleResult {
2191
+ /** <No documentation available> */
2192
+ int32_t status_code;
2193
+
2194
+ /** <No documentation available> */
2195
+ AttachmentHandle_t * handle;
2196
+ } AttachmentHandleResult_t;
2197
+
2198
+ /** <No documentation available> */
2199
+ AttachmentHandleResult_t
2200
+ /* fn */ ditto_get_attachment_status (
2201
+ CDitto_t * ditto,
2202
+ slice_ref_uint8_t id);
2203
+
2204
+ /** \brief
2205
+ * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
2206
+ */
2207
+ typedef struct Vec_char_ptr {
2208
+ /** <No documentation available> */
2209
+ char * * ptr;
2210
+
2211
+ /** <No documentation available> */
2212
+ size_t len;
2213
+
2214
+ /** <No documentation available> */
2215
+ size_t cap;
2216
+ } Vec_char_ptr_t;
2217
+
2218
+ /** <No documentation available> */
2219
+ typedef struct CollectionNamesResult {
2220
+ /** <No documentation available> */
2221
+ int32_t status_code;
2222
+
2223
+ /** <No documentation available> */
2224
+ Vec_char_ptr_t names;
2225
+ } CollectionNamesResult_t;
2226
+
2227
+ /** <No documentation available> */
2228
+ CollectionNamesResult_t
2229
+ /* fn */ ditto_get_collection_names (
2230
+ CDitto_t const * ditto);
2231
+
2232
+ /** <No documentation available> */
2233
+ typedef struct AttachmentDataResult {
2234
+ /** <No documentation available> */
2235
+ int8_t status;
2236
+
2237
+ /** <No documentation available> */
2238
+ slice_boxed_uint8_t data;
2239
+ } AttachmentDataResult_t;
2240
+
2241
+ /** <No documentation available> */
2242
+ AttachmentDataResult_t
2243
+ /* fn */ ditto_get_complete_attachment_data (
2244
+ CDitto_t const * ditto,
2245
+ AttachmentHandle_t const * handle);
2246
+
2247
+ /** <No documentation available> */
2248
+ char *
2249
+ /* fn */ ditto_get_complete_attachment_path (
2250
+ CDitto_t const * ditto,
2251
+ AttachmentHandle_t const * handle);
2252
+
2253
+ /** \brief
2254
+ * Returns a human-readable SDK version string, including platform information.
2255
+ * While useful when logging, its exact format or contents ought not to be
2256
+ * relied on.
2257
+ *
2258
+ * The returned string must be freed.
2259
+ */
2260
+ char *
2261
+ /* fn */ ditto_get_sdk_version (void);
2262
+
2263
+ /** <No documentation available> */
2264
+ typedef struct IdentityConfigResult {
2265
+ /** <No documentation available> */
2266
+ int32_t status_code;
2267
+
2268
+ /** <No documentation available> */
2269
+ CIdentityConfig_t * identity_config;
2270
+ } IdentityConfigResult_t;
2271
+
2272
+ /** <No documentation available> */
2273
+ IdentityConfigResult_t
2274
+ /* fn */ ditto_identity_config_make_manual (
2275
+ char const * manual_identity_str);
2276
+
2277
+ /** <No documentation available> */
2278
+ IdentityConfigResult_t
2279
+ /* fn */ ditto_identity_config_make_manual_v0 (
2280
+ char const * config_cbor_b64);
2281
+
2282
+ /** <No documentation available> */
2283
+ IdentityConfigResult_t
2284
+ /* fn */ ditto_identity_config_make_offline_playground (
2285
+ char const * app_id,
2286
+ uint64_t site_id);
2287
+
2288
+ /** <No documentation available> */
2289
+ IdentityConfigResult_t
2290
+ /* fn */ ditto_identity_config_make_online_playground (
2291
+ char const * app_id,
2292
+ char const * shared_token,
2293
+ char const * base_url);
2294
+
2295
+ /** <No documentation available> */
2296
+ IdentityConfigResult_t
2297
+ /* fn */ ditto_identity_config_make_online_with_authentication (
2298
+ char const * app_id,
2299
+ char const * base_url);
2300
+
2301
+ /** <No documentation available> */
2302
+ IdentityConfigResult_t
2303
+ /* fn */ ditto_identity_config_make_shared_key (
2304
+ char const * app_id,
2305
+ char const * key_der_b64,
2306
+ uint64_t site_id);
2307
+
2308
+ /** <No documentation available> */
2309
+ typedef enum Platform {
2310
+ /** <No documentation available> */
2311
+ PLATFORM_WINDOWS,
2312
+ /** <No documentation available> */
2313
+ PLATFORM_MAC,
2314
+ /** <No documentation available> */
2315
+ PLATFORM_IOS,
2316
+ /** <No documentation available> */
2317
+ PLATFORM_TVOS,
2318
+ /** <No documentation available> */
2319
+ PLATFORM_ANDROID,
2320
+ /** <No documentation available> */
2321
+ PLATFORM_LINUX,
2322
+ /** <No documentation available> */
2323
+ PLATFORM_WEB,
2324
+ /** <No documentation available> */
2325
+ PLATFORM_UNKNOWN,
2326
+ } Platform_t;
2327
+
2328
+ /** <No documentation available> */
2329
+ typedef enum Language {
2330
+ /** <No documentation available> */
2331
+ LANGUAGE_SWIFT,
2332
+ /** <No documentation available> */
2333
+ LANGUAGE_OBJECTIVE_C,
2334
+ /** <No documentation available> */
2335
+ LANGUAGE_C_PLUS_PLUS,
2336
+ /** <No documentation available> */
2337
+ LANGUAGE_C_SHARP,
2338
+ /** <No documentation available> */
2339
+ LANGUAGE_JAVA_SCRIPT,
2340
+ /** <No documentation available> */
2341
+ LANGUAGE_UNKNOWN,
2342
+ /** <No documentation available> */
2343
+ LANGUAGE_RUST,
2344
+ /** <No documentation available> */
2345
+ LANGUAGE_J_V_M_BASED,
2346
+ /** <No documentation available> */
2347
+ LANGUAGE_FLUTTER,
2348
+ } Language_t;
2349
+
2350
+ /** <No documentation available> */
2351
+ void
2352
+ /* fn */ ditto_init_sdk_version (
2353
+ Platform_t platform,
2354
+ Language_t language,
2355
+ char const * sdk_semver);
2356
+
2357
+ typedef struct {
2358
+ uint8_t idx[8];
2359
+ } uint8_8_array_t;
2360
+
2361
+ /** \brief
2362
+ * Construct a new Timeseries Event from the following parts:
2363
+ * * `timestamp` - u64 Unix epoch seconds as 8 big endian bytes
2364
+ * * `nanos` - Number of nanoseconds offset into the current second
2365
+ * * `ts_name` - The name of the timeseries
2366
+ * * `cbor` - The cbor content for the event
2367
+ * * `txn` - An optional write transaction. If one is provided then it will not be committed. If
2368
+ * one is not provided then one will be obtained and it will be committed.
2369
+ *
2370
+ * Return codes:
2371
+ * * `0` -- success
2372
+ * * `1` -- invalid CBOR
2373
+ * * `2` -- `cbor` is not an object
2374
+ * * `3` -- (js only) concurrent database operation (missing `await`?)
2375
+ */
2376
+ int32_t
2377
+ /* fn */ ditto_insert_timeseries_event (
2378
+ CDitto_t const * ditto,
2379
+ uint8_8_array_t timestamp,
2380
+ uint32_t nanos,
2381
+ char const * ts_name,
2382
+ slice_ref_uint8_t cbor,
2383
+ CWriteTransaction_t * txn);
2384
+
2385
+ /** <No documentation available> */
2386
+ void
2387
+ /* fn */ ditto_invalidate_tcp_listeners (
2388
+ CDitto_t const * ditto);
2389
+
2390
+ /** \brief
2391
+ * Returns `true` if Ditto data at that path is encrypted, otherwise
2392
+ * returns `false`
2393
+ */
2394
+ bool
2395
+ /* fn */ ditto_is_encrypted (
2396
+ CDitto_t const * ditto);
2397
+
2398
+ /** \brief
2399
+ * Describes how a live query callback's availability should be treated.
2400
+ */
2401
+ typedef enum LiveQueryAvailability {
2402
+ /** \brief
2403
+ * As soon as a transaction is committed that impacts the live query the consumer-provided
2404
+ * callback will be called with the relevant update information. This can be temporarily
2405
+ * delayed if there's a lot of activity leading to the event receivers lagging or if groups of
2406
+ * transactions are coalesced into a single live query update.
2407
+ */
2408
+ LIVE_QUERY_AVAILABILITY_ALWAYS,
2409
+ /** \brief
2410
+ * If `WhenSignalled` is specified then the consumer-provided live query callback will only be
2411
+ * called when there is a transaction committed that impacts the live query *and* the consumer
2412
+ * has signalled that they are ready to receive a new live query event (via the callback).
2413
+ */
2414
+ LIVE_QUERY_AVAILABILITY_WHEN_SIGNALLED,
2415
+ } LiveQueryAvailability_t;
2416
+
2417
+ /** <No documentation available> */
2418
+ typedef struct c_cb_params {
2419
+ /** \brief
2420
+ * The vec must be freed with `ditto_sparse_vec_documents_free`. The `Document`s contained by
2421
+ * the vec are owned by the recipient of the diff and should be freed independently of the
2422
+ * vec.
2423
+ */
2424
+ Vec_CDocument_ptr_t documents;
2425
+
2426
+ /** <No documentation available> */
2427
+ bool is_initial;
2428
+
2429
+ /** \brief
2430
+ * The vec, if present, must be freed with `ditto_sparse_vec_documents_free`. The `Document`s
2431
+ * contained by the vec are owned by the recipient of the diff and should be freed
2432
+ * independently of the vec.
2433
+ */
2434
+ Vec_CDocument_ptr_t old_documents;
2435
+
2436
+ /** \brief
2437
+ * Must be freed using `ditto_free_indices`.
2438
+ */
2439
+ slice_boxed_size_t insertions;
2440
+
2441
+ /** \brief
2442
+ * Must be freed using `ditto_free_indices`.
2443
+ */
2444
+ slice_boxed_size_t deletions;
2445
+
2446
+ /** \brief
2447
+ * Must be freed using `ditto_free_indices`.
2448
+ */
2449
+ slice_boxed_size_t updates;
2450
+
2451
+ /** \brief
2452
+ * Must be freed using `ditto_free_indices`.
2453
+ */
2454
+ slice_boxed_size_t moves;
2455
+ } c_cb_params_t;
2456
+
2457
+ /** <No documentation available> */
2458
+ typedef struct I64Result {
2459
+ /** <No documentation available> */
2460
+ int32_t status_code;
2461
+
2462
+ /** <No documentation available> */
2463
+ int64_t i64;
2464
+ } I64Result_t;
2465
+
2466
+ /** \brief
2467
+ * Convenience function for `ditto_live_query_register`, so as not to require
2468
+ * pre-compiling the query.
2469
+ */
2470
+ I64Result_t
2471
+ /* fn */ ditto_live_query_register_str (
2472
+ CDitto_t const * ditto,
2473
+ char const * coll_name,
2474
+ char const * query,
2475
+ slice_ref_uint8_t query_args_cbor,
2476
+ slice_ref_COrderByParam_t order_by,
2477
+ int32_t limit,
2478
+ uint32_t offset,
2479
+ LiveQueryAvailability_t lq_availability,
2480
+ void * ctx,
2481
+ void (*retain)(void *),
2482
+ void (*release)(void *),
2483
+ void (*c_cb)(void *, c_cb_params_t));
2484
+
2485
+ /** <No documentation available> */
2486
+ void
2487
+ /* fn */ ditto_live_query_signal_available_next (
2488
+ CDitto_t const * ditto,
2489
+ int64_t id);
2490
+
2491
+ /** <No documentation available> */
2492
+ int32_t
2493
+ /* fn */ ditto_live_query_start (
2494
+ CDitto_t const * ditto,
2495
+ int64_t id);
2496
+
2497
+ /** <No documentation available> */
2498
+ void
2499
+ /* fn */ ditto_live_query_stop (
2500
+ CDitto_t const * ditto,
2501
+ int64_t id);
2502
+
2503
+ /** <No documentation available> */
2504
+ DocIdResult_t
2505
+ /* fn */ ditto_live_query_webhook_register_str (
2506
+ CDitto_t const * ditto,
2507
+ char const * coll_name,
2508
+ char const * query,
2509
+ slice_ref_COrderByParam_t order_by,
2510
+ int32_t limit,
2511
+ uint32_t offset,
2512
+ char const * url);
2513
+
2514
+ /** <No documentation available> */
2515
+ typedef enum CLogLevel {
2516
+ /** <No documentation available> */
2517
+ C_LOG_LEVEL_ERROR = 1,
2518
+ /** <No documentation available> */
2519
+ C_LOG_LEVEL_WARNING,
2520
+ /** <No documentation available> */
2521
+ C_LOG_LEVEL_INFO,
2522
+ /** <No documentation available> */
2523
+ C_LOG_LEVEL_DEBUG,
2524
+ /** <No documentation available> */
2525
+ C_LOG_LEVEL_VERBOSE,
2526
+ } CLogLevel_t;
2527
+
2528
+ /** \brief
2529
+ * Log function called over FFI such that logging can be grouped into a single
2530
+ * logging mechanism.
2531
+ */
2532
+ void
2533
+ /* fn */ ditto_log (
2534
+ CLogLevel_t level,
2535
+ char const * msg);
2536
+
2537
+ /** <No documentation available> */
2538
+ void
2539
+ /* fn */ ditto_logger_emoji_headings_enabled (
2540
+ bool enabled);
2541
+
2542
+ /** <No documentation available> */
2543
+ bool
2544
+ /* fn */ ditto_logger_emoji_headings_enabled_get (void);
2545
+
2546
+ /** <No documentation available> */
2547
+ void
2548
+ /* fn */ ditto_logger_enabled (
2549
+ bool enabled);
2550
+
2551
+ /** <No documentation available> */
2552
+ bool
2553
+ /* fn */ ditto_logger_enabled_get (void);
2554
+
2555
+ /** \brief
2556
+ * Initializes and registers the global Ditto logger.
2557
+ *
2558
+ * This function shouldn't *need* to be called because all of the logging-related FFI calls
2559
+ * *should* start with a call that ensures that the logger is initialized. However, it also
2560
+ * shouldn't hurt to call this.
2561
+ */
2562
+ void
2563
+ /* fn */ ditto_logger_init (void);
2564
+
2565
+ /** <No documentation available> */
2566
+ void
2567
+ /* fn */ ditto_logger_minimum_log_level (
2568
+ CLogLevel_t log_level);
2569
+
2570
+ /** <No documentation available> */
2571
+ CLogLevel_t
2572
+ /* fn */ ditto_logger_minimum_log_level_get (void);
2573
+
2574
+ /** \brief
2575
+ * Registers a custom logging callback to be called whenever Ditto wants to
2576
+ * issue a log (on _top_ of emitting the log to the console).
2577
+ *
2578
+ * Care should be taken not to perform any Ditto operations within this
2579
+ * callback, since those could emit new ditto logs, leading to a recursive
2580
+ * situation. More specifically, this should not be fed `ditto_log`.
2581
+ *
2582
+ * A `NULL` may be fed to provide no callback (thus unregistering any
2583
+ * previously registered one).
2584
+ */
2585
+ void
2586
+ /* fn */ ditto_logger_set_custom_log_cb (
2587
+ void (*custom_log_cb)(CLogLevel_t, char *));
2588
+
2589
+ /** \brief
2590
+ * Registers a file path where logs will be written to, whenever Ditto wants
2591
+ * to issue a log (on _top_ of emitting the log to the console).
2592
+ *
2593
+ * The path, if any, must be within an already existing directory.
2594
+ *
2595
+ * A `NULL` may be fed to provide no file (thus unregistering any previously
2596
+ * registered one).
2597
+ *
2598
+ * Returns `0` on success, and `-1` otherwise (and the thread local error
2599
+ * message is set accordingly).
2600
+ */
2601
+ int8_t
2602
+ /* fn */ ditto_logger_set_log_file (
2603
+ char const * log_file);
2604
+
2605
+ /** \brief
2606
+ * Make a Ditto object as an opaque pointer. The Ditto object creates the Tokio
2607
+ * runtime and starts internal threads. The return value is a raw pointer whose
2608
+ * only use is to supply as an argument to other ditto_* functions. The Ditto
2609
+ * object must be stopped and freed with ditto_free().
2610
+ */
2611
+ CDitto_t *
2612
+ /* fn */ ditto_make (
2613
+ char const * working_dir,
2614
+ CIdentityConfig_t * identity_config,
2615
+ HistoryTracking_t history_tracking);
2616
+
2617
+ /** <No documentation available> */
2618
+ typedef struct CAttachment {
2619
+ /** <No documentation available> */
2620
+ slice_boxed_uint8_t id;
2621
+
2622
+ /** <No documentation available> */
2623
+ uint64_t len;
2624
+
2625
+ /** <No documentation available> */
2626
+ AttachmentHandle_t * handle;
2627
+ } CAttachment_t;
2628
+
2629
+ /** \brief
2630
+ * Creates new Attachment from a blob of bytes link it to the given Document.
2631
+ *
2632
+ * Returns following error codes:
2633
+ *
2634
+ * * `0` -- no error
2635
+ * * `1` -- an error
2636
+ *
2637
+ * In case of a non-zero return value, error message can be retrieved using
2638
+ * `ditto_error_message` function.
2639
+ */
2640
+ uint32_t
2641
+ /* fn */ ditto_new_attachment_from_bytes (
2642
+ CDitto_t const * ditto,
2643
+ slice_ref_uint8_t bytes,
2644
+ CAttachment_t * out_attachment);
2645
+
2646
+ /** \brief
2647
+ * Describes how an attachment file should be handled by our Rust code.
2648
+ *
2649
+ * In most cases copying the file will be desirable but with the Android SDK,
2650
+ * for example, we sometimes want to create a tempfile from an InputStream
2651
+ * associated with the attachment file and then move that tempfile rather than
2652
+ * copy it, so as to not make unnecessary copies.
2653
+ */
2654
+ typedef enum AttachmentFileOperation {
2655
+ /** <No documentation available> */
2656
+ ATTACHMENT_FILE_OPERATION_COPY = 1,
2657
+ /** <No documentation available> */
2658
+ ATTACHMENT_FILE_OPERATION_MOVE,
2659
+ } AttachmentFileOperation_t;
2660
+
2661
+ /** \brief
2662
+ * Creates new Attachment from a file and link it to the given Document.
2663
+ *
2664
+ * Returns following error codes:
2665
+ *
2666
+ * * `0` -- no error
2667
+ * * `1` -- an error
2668
+ * * `2` -- file not found
2669
+ * * `3` -- permission denied
2670
+ *
2671
+ * In case of a non-zero return value, error message can be retrieved using
2672
+ * `ditto_error_message` function.
2673
+ */
2674
+ uint32_t
2675
+ /* fn */ ditto_new_attachment_from_file (
2676
+ CDitto_t const * ditto,
2677
+ char const * source_path,
2678
+ AttachmentFileOperation_t file_operation,
2679
+ CAttachment_t * out_attachment);
2680
+
2681
+ /** \brief
2682
+ * Request data showing who we are connected to in a user-friendly way.
2683
+ */
2684
+ char *
2685
+ /* fn */ ditto_presence_v1 (
2686
+ CDitto_t const * ditto);
2687
+
2688
+ /** \brief
2689
+ * Request data showing who we are connected to in a user-friendly way.
2690
+ */
2691
+ char *
2692
+ /* fn */ ditto_presence_v2 (
2693
+ CDitto_t const * ditto);
2694
+
2695
+ /** \brief
2696
+ * Request data showing who we are connected to in a user-friendly way.
2697
+ */
2698
+ char *
2699
+ /* fn */ ditto_presence_v3 (
2700
+ CDitto_t const * ditto);
2701
+
2702
+ /** \brief
2703
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
2704
+ *
2705
+ * # C layout (for some given type T)
2706
+ *
2707
+ * ```c
2708
+ * typedef struct {
2709
+ * // Cannot be NULL
2710
+ * T * ptr;
2711
+ * size_t len;
2712
+ * } slice_T;
2713
+ * ```
2714
+ *
2715
+ * # Nullable pointer?
2716
+ *
2717
+ * If you want to support the above typedef, but where the `ptr` field is
2718
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
2719
+ * use the `Option< slice_ptr<_> >` type.
2720
+ */
2721
+ typedef struct slice_ref_char_const_ptr {
2722
+ /** \brief
2723
+ * Pointer to the first element (if any).
2724
+ */
2725
+ char const * const * ptr;
2726
+
2727
+ /** \brief
2728
+ * Element count
2729
+ */
2730
+ size_t len;
2731
+ } slice_ref_char_const_ptr_t;
2732
+
2733
+ /** <No documentation available> */
2734
+ U64Result_t
2735
+ /* fn */ ditto_queries_hash (
2736
+ CDitto_t const * ditto,
2737
+ slice_ref_char_const_ptr_t coll_names,
2738
+ slice_ref_char_const_ptr_t queries);
2739
+
2740
+ /** <No documentation available> */
2741
+ BoxedCharPtrResult_t
2742
+ /* fn */ ditto_queries_hash_mnemonic (
2743
+ CDitto_t const * ditto,
2744
+ slice_ref_char_const_ptr_t coll_names,
2745
+ slice_ref_char_const_ptr_t queries);
2746
+
2747
+ /** <No documentation available> */
2748
+ typedef struct CReadTransactionResult {
2749
+ /** <No documentation available> */
2750
+ int32_t status_code;
2751
+
2752
+ /** <No documentation available> */
2753
+ CReadTransaction_t * txn;
2754
+ } CReadTransactionResult_t;
2755
+
2756
+ /** <No documentation available> */
2757
+ CReadTransactionResult_t
2758
+ /* fn */ ditto_read_transaction (
2759
+ CDitto_t const * ditto);
2760
+
2761
+ /** <No documentation available> */
2762
+ void
2763
+ /* fn */ ditto_read_transaction_free (
2764
+ CReadTransaction_t * transaction);
2765
+
2766
+ /** \brief
2767
+ * Guard for a specific disk usage callback; drop to "unregister" the callback.
2768
+ */
2769
+ typedef struct DiskUsageObserver DiskUsageObserver_t;
2770
+
2771
+ /** \brief
2772
+ * Register a function that will be called every time
2773
+ * the given path directory or file is updated.
2774
+ * Return a handle that should be given to ditto_release_disk_usage_callback
2775
+ * to drop the callback
2776
+ */
2777
+ DiskUsageObserver_t *
2778
+ /* fn */ ditto_register_disk_usage_callback (
2779
+ CDitto_t const * ditto,
2780
+ FsComponent_t component,
2781
+ void * ctx,
2782
+ void (*retain)(void *),
2783
+ void (*release)(void *),
2784
+ void (*c_cb)(void *, slice_ref_uint8_t));
2785
+
2786
+ /** \brief
2787
+ * Register a function that will be called every time the connection state
2788
+ * of remote peers changes.
2789
+ */
2790
+ void
2791
+ /* fn */ ditto_register_presence_callback_v3 (
2792
+ CDitto_t const * ditto,
2793
+ void * ctx,
2794
+ void (*retain)(void *),
2795
+ void (*release)(void *),
2796
+ void (*c_cb)(void *, char const *));
2797
+
2798
+ /** \brief
2799
+ * Register a function that will be called every time the connection state
2800
+ * of remote peers changes.
2801
+ */
2802
+ void
2803
+ /* fn */ ditto_register_presence_callback_v3_owned (
2804
+ CDitto_t const * ditto,
2805
+ void * ctx,
2806
+ void (*retain)(void *),
2807
+ void (*release)(void *),
2808
+ void (*c_cb)(void *, char *));
2809
+
2810
+ /** \brief
2811
+ * Register a function that will be called every time the connection state
2812
+ * of remote peers changes.
2813
+ * REMOVE THIS IN V4
2814
+ */
2815
+ void
2816
+ /* fn */ ditto_register_presence_v1_callback (
2817
+ CDitto_t const * ditto,
2818
+ void * ctx,
2819
+ void (*retain)(void *),
2820
+ void (*release)(void *),
2821
+ void (*c_cb)(void *, char const *));
2822
+
2823
+ /** \brief
2824
+ * Register a function that will be called every time the connection state
2825
+ * of remote peers changes.
2826
+ * REMOVE THIS IN V4
2827
+ */
2828
+ void
2829
+ /* fn */ ditto_register_presence_v2_callback (
2830
+ CDitto_t const * ditto,
2831
+ void * ctx,
2832
+ void (*retain)(void *),
2833
+ void (*release)(void *),
2834
+ void (*c_cb)(void *, char const *));
2835
+
2836
+ /** \brief
2837
+ * User-friendly categories describing where condition events arose
2838
+ */
2839
+ typedef enum ConditionSource {
2840
+ /** <No documentation available> */
2841
+ CONDITION_SOURCE_BLUETOOTH,
2842
+ /** <No documentation available> */
2843
+ CONDITION_SOURCE_TCP,
2844
+ /** <No documentation available> */
2845
+ CONDITION_SOURCE_AWDL,
2846
+ /** <No documentation available> */
2847
+ CONDITION_SOURCE_MDNS,
2848
+ /** <No documentation available> */
2849
+ CONDITION_SOURCE_WIFI_AWARE,
2850
+ } ConditionSource_t;
2851
+
2852
+ /** \brief
2853
+ * Register a function that will be called every time a transport changes
2854
+ * condition.
2855
+ *
2856
+ * This should drive UI indicators to indicate overall connectivity via methods
2857
+ * such as BLE, WiFi, or an internet-based server on a dedicated
2858
+ * WsConnectTransport.
2859
+ */
2860
+ void
2861
+ /* fn */ ditto_register_transport_condition_changed_callback (
2862
+ CDitto_t const * ditto,
2863
+ void * ctx,
2864
+ void (*retain)(void *),
2865
+ void (*release)(void *),
2866
+ void (*c_cb)(void *, ConditionSource_t, TransportCondition_t));
2867
+
2868
+ /** \brief
2869
+ * Release the disk usage observer obtained from `ditto_register_disk_usage_callback`
2870
+ */
2871
+ void
2872
+ /* fn */ ditto_release_disk_usage_callback (
2873
+ DiskUsageObserver_t * _handle);
2874
+
2875
+ /** <No documentation available> */
2876
+ int32_t
2877
+ /* fn */ ditto_remove_subscription (
2878
+ CDitto_t const * ditto,
2879
+ char const * collection,
2880
+ char const * query,
2881
+ slice_ref_uint8_t query_args_cbor,
2882
+ slice_ref_COrderByParam_t order_by,
2883
+ int32_t limit,
2884
+ uint32_t offset);
2885
+
2886
+ /** <No documentation available> */
2887
+ typedef struct CancelTokenResult {
2888
+ /** <No documentation available> */
2889
+ int32_t status_code;
2890
+
2891
+ /** <No documentation available> */
2892
+ int64_t cancel_token;
2893
+ } CancelTokenResult_t;
2894
+
2895
+ /** \brief
2896
+ * Register a new callback to resolve the attachment.
2897
+ *
2898
+ * The callback status could be:
2899
+ * * `0` -- complete, with a handle that can be used in ditto_get_complete_attachment_path
2900
+ * * `1` -- progress, with additional info about bytes downloaded and total bytes to download
2901
+ * * `2` -- deleted, as the attachment ceased to exist in the doc database
2902
+ *
2903
+ * A cancel token with value `0` represents nil/invalid. This means either an error
2904
+ * occured, or the token has already been fetched or deleted. Note that in this case
2905
+ * the `on_complete_cb` and `on_deleted_cb` callbacks _may_ be called synchronously
2906
+ * even before this function completes.
2907
+ *
2908
+ * Returns following error codes:
2909
+ *
2910
+ * * `0` -- no error
2911
+ * * `1` -- an error
2912
+ * * `2` -- invalid id
2913
+ * * `3` -- attachment not found
2914
+ *
2915
+ * In case of a non-zero status code, error message can be retrieved using
2916
+ * `ditto_error_message` function.
2917
+ */
2918
+ CancelTokenResult_t
2919
+ /* fn */ ditto_resolve_attachment (
2920
+ CDitto_t const * ditto,
2921
+ slice_ref_uint8_t id,
2922
+ void * ctx,
2923
+ void (*retain)(void *),
2924
+ void (*release)(void *),
2925
+ void (*on_complete_cb)(void *, AttachmentHandle_t *),
2926
+ void (*on_progress_cb)(void *, uint64_t, uint64_t),
2927
+ void (*on_deleted_cb)(void *));
2928
+
2929
+ /** <No documentation available> */
2930
+ uint32_t
2931
+ /* fn */ ditto_run_garbage_collection (
2932
+ CDitto_t const * ditto);
2933
+
2934
+ /** <No documentation available> */
2935
+ bool
2936
+ /* fn */ ditto_sdk_transports_android_is_inited (void);
2937
+
2938
+ /** <No documentation available> */
2939
+ char *
2940
+ /* fn */ ditto_sdk_transports_android_missing_permissions (void);
2941
+
2942
+ /** <No documentation available> */
2943
+ void *
2944
+ /* fn */ ditto_sdk_transports_android_missing_permissions_jni_array (void);
2945
+
2946
+ /** <No documentation available> */
2947
+ void
2948
+ /* fn */ ditto_sdk_transports_android_shutdown (void);
2949
+
2950
+ /** <No documentation available> */
2951
+ typedef enum DittoSdkTransportsError {
2952
+ /** <No documentation available> */
2953
+ DITTO_SDK_TRANSPORTS_ERROR_NONE = 0,
2954
+ /** <No documentation available> */
2955
+ DITTO_SDK_TRANSPORTS_ERROR_GENERIC = 1,
2956
+ /** <No documentation available> */
2957
+ DITTO_SDK_TRANSPORTS_ERROR_UNAVAILABLE = 2,
2958
+ /** <No documentation available> */
2959
+ DITTO_SDK_TRANSPORTS_ERROR_MISSING_BLUETOOTH_INFO_PLIST_ENTRY = 3,
2960
+ /** <No documentation available> */
2961
+ DITTO_SDK_TRANSPORTS_ERROR_MISSING_BLUETOOTH_U_I_BACKGROUND_MODES_INFO_PLIST_ENTRY = 4,
2962
+ /** <No documentation available> */
2963
+ DITTO_SDK_TRANSPORTS_ERROR_MISSING_LOCAL_NETWORK_INFO_PLIST_ENTRY = 5,
2964
+ /** <No documentation available> */
2965
+ DITTO_SDK_TRANSPORTS_ERROR_MISSING_BONJOUR_SERVICES_INFO_PLIST_ENTRY = 6,
2966
+ } DittoSdkTransportsError_t;
2967
+
2968
+ /** <No documentation available> */
2969
+ char const *
2970
+ /* fn */ ditto_sdk_transports_error_description (
2971
+ DittoSdkTransportsError_t error);
2972
+
2973
+ /** \brief
2974
+ * Frees the output of `ditto_sdk_transports_error_new`.
2975
+ */
2976
+ void
2977
+ /* fn */ ditto_sdk_transports_error_free (
2978
+ DittoSdkTransportsError_t * it);
2979
+
2980
+ /** \brief
2981
+ * Obtain a fresh heap-allocated pointer to a (dummy) `DittoSdkTransportsError`.
2982
+ *
2983
+ * This is useful for languages with no access to inline/stack allocations and/or unable
2984
+ * to produce pointers themselves.
2985
+ */
2986
+ DittoSdkTransportsError_t *
2987
+ /* fn */ ditto_sdk_transports_error_new (void);
2988
+
2989
+ /** \brief
2990
+ * Obtain the value of a pointer to `DittoSdkTransportsError`
2991
+ */
2992
+ DittoSdkTransportsError_t
2993
+ /* fn */ ditto_sdk_transports_error_value (
2994
+ DittoSdkTransportsError_t const * it);
2995
+
2996
+ /** <No documentation available> */
2997
+ bool
2998
+ /* fn */ ditto_sdk_transports_init (
2999
+ DittoSdkTransportsError_t * out_error);
3000
+
3001
+ /** \brief
3002
+ * Must be called from the main thread, before `ditto_sdk_transports_init`.
3003
+ * Calling this from a background thread can result in "Error finding class live/ditto/...".
3004
+ * This is because the class loader for that thread may be the system one,
3005
+ * so attempting to find app-specific classes will fail.
3006
+ * More info at: <https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class>
3007
+ */
3008
+ bool
3009
+ /* fn */ ditto_sdk_transports_set_android_context (
3010
+ void * env,
3011
+ void * context);
3012
+
3013
+ /** <No documentation available> */
3014
+ char *
3015
+ /* fn */ ditto_set_device_name (
3016
+ CDitto_t const * ditto,
3017
+ char const * device_name);
3018
+
3019
+ /** \brief
3020
+ * Shut down Ditto.
3021
+ *
3022
+ * All of the `Peer`'s subsystems are told to shut down, which includes, but is not limited to, the
3023
+ * following happening:
3024
+ * - all advertisers shut down
3025
+ * - all servers stopped
3026
+ * - all TCP listeners stopped
3027
+ * - outbound replication stopped
3028
+ *
3029
+ * All of the live queries associated with the Ditto instance are also stopped. Any file lock
3030
+ * handles are dropped once any long-running tasks have had a chance to complete.
3031
+ */
3032
+ void
3033
+ /* fn */ ditto_shutdown (
3034
+ CDitto_t const * ditto);
3035
+
3036
+ /** \brief
3037
+ * Indicates whether small peer info feature is currently enabled.
3038
+ *
3039
+ * `true` if enabled, and `false` if currently disabled. Small peer info
3040
+ * consists of information scraped into a system collection at repeated
3041
+ * interval.
3042
+ *
3043
+ * Note: whether the background ingestion process is enabled or not is a
3044
+ * separate decision to whether this information is allowed to sync to other
3045
+ * peers (including the big peer). This is controlled by [`SyncScope`]s. For
3046
+ * the FFI function to get the current sync scope, see
3047
+ * [`ditto_small_peer_info_get_sync_scope`]. By default, the small peer info
3048
+ * document will sync to the big peer.
3049
+ *
3050
+ * [`SyncScope`]: DittoSmallPeerInfoSyncScope
3051
+ */
3052
+ bool
3053
+ /* fn */ ditto_small_peer_info_get_is_enabled (
3054
+ CDitto_t const * ditto);
3055
+
3056
+ /** \brief
3057
+ * Gets the JSON metadata being used in the small peer info document.
3058
+ *
3059
+ * The metadata is free-form, user-provided JSON data that is inserted into
3060
+ * the small peer info system doc at each collection interval. The data has no
3061
+ * schema so it is returned as a c_string. We validated the incoming data with
3062
+ * our constraints, and we do not modify this data, so the same constraints
3063
+ * hold. The validation constraints are:
3064
+ * 1. The size of the metadata does not exceed [`SMALL_PEER_INFO_METADATA_SIZE_BYTES_MAX`]
3065
+ * 2. The metadata can be parsed as a JSON string and its max depth does not exceed
3066
+ * [`SMALL_PEER_INFO_METADATA_DEPTH_MAX`]
3067
+ * 3. The metadata represents a JSON object that can be deserialized into a Map<String, Value>
3068
+ *
3069
+ * An empty JSON object string is returned if the data has not been set.
3070
+ *
3071
+ * This does not return the metadata from persistent storage. It only returns
3072
+ * the data that has been set to be used by the collector
3073
+ * (via [`ditto_small_peer_info_set_metadata`]) at each collector
3074
+ */
3075
+ char *
3076
+ /* fn */ ditto_small_peer_info_get_metadata (
3077
+ CDitto_t const * ditto);
3078
+
3079
+ /** \brief
3080
+ * Which peers to replicate the `__small_peer_info` collection to.
3081
+ *
3082
+ * The syncing behavior is dictated by internal [`SyncScope`]s.
3083
+ *
3084
+ * By default, the small peer info will sync with the big peer, as dictated by
3085
+ * the default `BigPeerOnly` scope.
3086
+ *
3087
+ * NOTE: Currently SDKs can only set [`BigPeerOnly`] or [`LocalPeerOnly`] sync
3088
+ * scopes. [`AllPeers`] and [`SmallPeersOnly`] sync scopes are currently
3089
+ * unsupported. Support for `AllPeers` and `SmallPeersOnly` will be added in
3090
+ * the future, but for that we will need an API for users to subscribe to the
3091
+ * small peer info of other peers.
3092
+ *
3093
+ * [`SyncScope`]: ::ditto_store::sync_scope::SyncScope
3094
+ * [`BigPeerOnly`]: ::ditto_store::sync_scope::SyncScope::BigPeerOnly
3095
+ * [`LocalPeerOnly`]: ::ditto_store::sync_scope::SyncScope::LocalPeerOnly
3096
+ * [`AllPeers`]: ::ditto_store::sync_scope::SyncScope::AllPeers
3097
+ * [`SmallPeersOnly`]: ::ditto_store::sync_scope::SyncScope::SmallPeersOnly
3098
+ */
3099
+ typedef enum DittoSmallPeerInfoSyncScope {
3100
+ /** <No documentation available> */
3101
+ DITTO_SMALL_PEER_INFO_SYNC_SCOPE_BIG_PEER_ONLY,
3102
+ /** <No documentation available> */
3103
+ DITTO_SMALL_PEER_INFO_SYNC_SCOPE_LOCAL_PEER_ONLY,
3104
+ } DittoSmallPeerInfoSyncScope_t;
3105
+
3106
+ /** \brief
3107
+ * Gets the sync scope for the Small Peer Info collection.
3108
+ *
3109
+ * A collection's [SyncScope] determines which "kind" of peers it will
3110
+ * replicate to. The collection does not need to exist locally for this
3111
+ * function to succeed. If no custom sync scope has been set or if the
3112
+ * collection does not exist, the returned scope will be the default
3113
+ * [`LocalPeerOnly`]. Currently, only [`BigPeerOnly`] and [`LocalPeerOnly`] are
3114
+ * supported for small peer info; see [`DittoSmallPeerInfoSyncScope`] for
3115
+ * details.
3116
+ *
3117
+ * # Return Values
3118
+ *
3119
+ * - Always returns a sync scope - either the custom override set by the user, or the default
3120
+ * scope.
3121
+ *
3122
+ * The function currently has no error conditions.
3123
+ *
3124
+ * [`SyncScope`]: DittoSmallPeerInfoSyncScope
3125
+ * [`BigPeerOnly`]: DittoSmallPeerInfoSyncScope::BigPeerOnly
3126
+ * [`LocalPeerOnly`]: DittoSmallPeerInfoSyncScope::LocalPeerOnly
3127
+ */
3128
+ DittoSmallPeerInfoSyncScope_t
3129
+ /* fn */ ditto_small_peer_info_get_sync_scope (
3130
+ CDitto_t const * ditto);
3131
+
3132
+ /** \brief
3133
+ * Enables or disables the small peer info feature.
3134
+ *
3135
+ * Small peer info consists of information scraped into a system collection at
3136
+ * repeated intervals.
3137
+ *
3138
+ * Note: whether the background ingestion process is enabled or not is a
3139
+ * separate decision to whether this information is allowed to sync to other
3140
+ * peers (including the big peer). This is controlled by [`SyncScope`]s. For
3141
+ * the FFI function to set sync scopes, see
3142
+ * [`ditto_small_peer_info_set_sync_scope`]. By default, the small peer info
3143
+ * document will sync to the big peer.
3144
+ *
3145
+ * [`SyncScope`]: DittoSmallPeerInfoSyncScope
3146
+ */
3147
+ void
3148
+ /* fn */ ditto_small_peer_info_set_enabled (
3149
+ CDitto_t const * ditto,
3150
+ bool set_enabled);
3151
+
3152
+ /** \brief
3153
+ * Sets the JSON metadata to be used in the small peer info document.
3154
+ *
3155
+ * The metadata is free-form, user-provided JSON data that is inserted into
3156
+ * the small peer info system doc at each collection interval. The data has no
3157
+ * schema and is provided as a char_p, so data validation must be performed
3158
+ * here. We validate:
3159
+ * 1. The size of the metadata does not exceed [`SMALL_PEER_INFO_METADATA_SIZE_BYTES_MAX`]
3160
+ * 2. The metadata can be parsed as a JSON string and its max depth does not exceed
3161
+ * [`SMALL_PEER_INFO_METADATA_DEPTH_MAX`]
3162
+ * 3. The metadata represents a JSON object that can be deserialized into a Map<String, Value>
3163
+ *
3164
+ * # Return Values
3165
+ *
3166
+ * - Returns `0` if the input passes validation and is successfully set to be
3167
+ * used in the small peer info document.
3168
+ * - Returns `-1` in case the observability subsystem is unavailable (which
3169
+ * should never be the case for the small peer).
3170
+ * - Returns `1` if the amount of data is too large according to our
3171
+ * self-imposed limits.
3172
+ * - Returns `2` if the amount of JSON data is too nested according to our
3173
+ * self-imposed limits, or if the data cannot be parsed to determine the depth.
3174
+ * - Returns `3` if the data cannot be parsed as a Map<String, Value>
3175
+ */
3176
+ int32_t
3177
+ /* fn */ ditto_small_peer_info_set_metadata (
3178
+ CDitto_t const * ditto,
3179
+ char const * metadata);
3180
+
3181
+ /** \brief
3182
+ * Set the sync scope for the Small Peer Info collection.
3183
+ *
3184
+ * A collection's [SyncScope] determines which "kind" of peers it will
3185
+ * replicate to. This function can be used even if the Small Peer Info
3186
+ * collection does not yet exist. Currently, only [`BigPeerOnly`] and
3187
+ * [`LocalPeerOnly`] sync scopes are supported for small peer info; see
3188
+ * [`DittoSmallPeerInfoSyncScope`] for details.
3189
+ *
3190
+ * The function currently has no error conditions.
3191
+ *
3192
+ * [`SyncScope`]: DittoSmallPeerInfoSyncScope
3193
+ * [`BigPeerOnly`]: DittoSmallPeerInfoSyncScope::BigPeerOnly
3194
+ * [`LocalPeerOnly`]: DittoSmallPeerInfoSyncScope::LocalPeerOnly
3195
+ */
3196
+ void
3197
+ /* fn */ ditto_small_peer_info_set_sync_scope (
3198
+ CDitto_t const * ditto,
3199
+ DittoSmallPeerInfoSyncScope_t scope);
3200
+
3201
+ /** \brief
3202
+ * Allows you to free the vector without dropping the Documents
3203
+ */
3204
+ void
3205
+ /* fn */ ditto_sparse_vec_documents_free (
3206
+ Vec_CDocument_ptr_t docs);
3207
+
3208
+ /** <No documentation available> */
3209
+ void
3210
+ /* fn */ ditto_transports_ble_advertisement_heard (
3211
+ TransportHandle_BleClientPlatformEvent_t const * handle,
3212
+ uint8_16_array_t const * peripheral_uuid,
3213
+ slice_ref_uint8_t manufacturer_data,
3214
+ bool manufacturer_data_includes_id,
3215
+ slice_ref_uint8_t name,
3216
+ float rssi);
3217
+
3218
+ /** \brief
3219
+ * Request bulk status information about the transports. Intended mostly for
3220
+ * statistical or debugging purposes.
3221
+ */
3222
+ char *
3223
+ /* fn */ ditto_transports_diagnostics (
3224
+ CDitto_t const * ditto);
3225
+
3226
+ /** \brief
3227
+ * The whole point
3228
+ */
3229
+ int32_t
3230
+ /* fn */ ditto_unregister_and_free_legacy_subscription (
3231
+ CDitto_t const * ditto,
3232
+ LegacySubscriptionHandle_t * handle);
3233
+
3234
+ /** <No documentation available> */
3235
+ uint32_t
3236
+ /* fn */ ditto_validate_document_id (
3237
+ slice_ref_uint8_t cbor,
3238
+ slice_boxed_uint8_t * out_cbor);
3239
+
3240
+ /** <No documentation available> */
3241
+ void
3242
+ /* fn */ ditto_vec_char_ptr_free (
3243
+ Vec_char_ptr_t char_p);
3244
+
3245
+ /** <No documentation available> */
3246
+ void
3247
+ /* fn */ ditto_vec_slice_boxed_uint8_t_free (
3248
+ Vec_slice_boxed_uint8_t slice_boxed);
3249
+
3250
+ /** <No documentation available> */
3251
+ typedef enum LicenseVerificationResult {
3252
+ /** <No documentation available> */
3253
+ LICENSE_VERIFICATION_RESULT_LICENSE_OK = 0,
3254
+ /** <No documentation available> */
3255
+ LICENSE_VERIFICATION_RESULT_VERIFICATION_FAILED = -1,
3256
+ /** <No documentation available> */
3257
+ LICENSE_VERIFICATION_RESULT_LICENSE_EXPIRED = -2,
3258
+ /** <No documentation available> */
3259
+ LICENSE_VERIFICATION_RESULT_UNSUPPORTED_FUTURE_VERSION = -3,
3260
+ } LicenseVerificationResult_t;
3261
+
3262
+ /** \brief
3263
+ * Legacy version of `dittoffi_ditto_set_offline_only_license_token_throws`.
3264
+ *
3265
+ * Verify a base64 encoded license string
3266
+ *
3267
+ * # Parameters
3268
+ * - `ditto`: The Ditto instance to activate.
3269
+ * - `license`: A base64 encoded license string. This should be the output of
3270
+ * `ditto_licenser::license_mgr::generate()`.
3271
+ * - `out_error_msg`: An optional error message out parameter which will be written to if the
3272
+ * license verification. This error message is simplified and appropriate to show directly to an
3273
+ * SDK user.
3274
+ */
3275
+ LicenseVerificationResult_t
3276
+ /* fn */ ditto_verify_license (
3277
+ CDitto_t const * ditto,
3278
+ char const * license,
3279
+ char * * out_err_msg);
3280
+
3281
+ /** \brief
3282
+ * The SDK requests to drop its handle to the WifiAware discovery transport
3283
+ *
3284
+ * At some point dropping this events channel will effectively shut down and
3285
+ * remove the Transport. At time of writing, the Transport is still owned
3286
+ * within Peer.
3287
+ */
3288
+ void
3289
+ /* fn */ ditto_wifi_aware_client_free_handle (
3290
+ TransportHandle_WifiAwareClientPlatformEvent_t * handle);
3291
+
3292
+ /** \brief
3293
+ * The platform tells Rust that it should go offline.
3294
+ */
3295
+ void
3296
+ /* fn */ ditto_wifi_aware_client_go_offline_request (
3297
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle);
3298
+
3299
+ /** \brief
3300
+ * The platform tells Rust that it should go online (because the platform has attached to the WiFi
3301
+ * Aware session)
3302
+ */
3303
+ void
3304
+ /* fn */ ditto_wifi_aware_client_go_online_request (
3305
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle);
3306
+
3307
+ /** \brief
3308
+ * The platform advises Rust that we have resolved a peer's hostname and port
3309
+ */
3310
+ void
3311
+ /* fn */ ditto_wifi_aware_client_network_did_create (
3312
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3313
+ char const * announce_string,
3314
+ char const * hostname,
3315
+ uint16_t port);
3316
+
3317
+ /** \brief
3318
+ * The platform advises Rust that a peer has been identified.
3319
+ */
3320
+ void
3321
+ /* fn */ ditto_wifi_aware_client_peer_appeared (
3322
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3323
+ char const * announce_string);
3324
+
3325
+ /** \brief
3326
+ * The platform advises Rust that we failed to resolve a peer's hostname and
3327
+ * port
3328
+ */
3329
+ void
3330
+ /* fn */ ditto_wifi_aware_client_peer_did_not_connect (
3331
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3332
+ char const * announce_string);
3333
+
3334
+ /** \brief
3335
+ * The platform advises Rust that a peer's service has disappeared from WifiAware.
3336
+ */
3337
+ void
3338
+ /* fn */ ditto_wifi_aware_client_peer_disappeared (
3339
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3340
+ char const * announce_string);
3341
+
3342
+ /** \brief
3343
+ * The platform advises Rust that the status of searching for services has
3344
+ * changed.
3345
+ */
3346
+ void
3347
+ /* fn */ ditto_wifi_aware_client_scanning_state_changed (
3348
+ TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3349
+ OnlineState_t state,
3350
+ TransportCondition_t condition);
3351
+
3352
+ /** \brief
3353
+ * The platform advises Rust that the status of publishing our service has
3354
+ * changed.
3355
+ */
3356
+ void
3357
+ /* fn */ ditto_wifi_aware_server_advertising_state_changed (
3358
+ TransportHandle_WifiAwareServerPlatformEvent_t const * handle,
3359
+ OnlineState_t state,
3360
+ TransportCondition_t condition);
3361
+
3362
+ /** \brief
3363
+ * The SDK requests to drop its handle to the WifiAware advertising service.
3364
+ *
3365
+ * Ideally this should remove the advertiser automatically.
3366
+ * At time of writing now this must be done manually through Peer.
3367
+ */
3368
+ void
3369
+ /* fn */ ditto_wifi_aware_server_free_handle (
3370
+ TransportHandle_WifiAwareServerPlatformEvent_t * handle);
3371
+
3372
+ /** \brief
3373
+ * The platform tells Rust that it should go offline.
3374
+ */
3375
+ void
3376
+ /* fn */ ditto_wifi_aware_server_go_offline_request (
3377
+ TransportHandle_WifiAwareServerPlatformEvent_t const * handle);
3378
+
3379
+ /** \brief
3380
+ * The platform tells Rust that it should go online (because the platform has attached to the WiFi
3381
+ * Aware session)
3382
+ */
3383
+ void
3384
+ /* fn */ ditto_wifi_aware_server_go_online_request (
3385
+ TransportHandle_WifiAwareServerPlatformEvent_t const * handle);
3386
+
3387
+ /** <No documentation available> */
3388
+ typedef struct CWriteTransactionResult {
3389
+ /** <No documentation available> */
3390
+ int32_t status_code;
3391
+
3392
+ /** <No documentation available> */
3393
+ CWriteTransaction_t * txn;
3394
+ } CWriteTransactionResult_t;
3395
+
3396
+ /** <No documentation available> */
3397
+ CWriteTransactionResult_t
3398
+ /* fn */ ditto_write_transaction (
3399
+ CDitto_t const * ditto,
3400
+ char const * log_hint);
3401
+
3402
+ /** \brief
3403
+ * Sets some arbitrary metadata on a write transaction.
3404
+ *
3405
+ * This is currently only useful and relevant if history tracking is enabled in
3406
+ * the store that the write transaction relates to. If history tracking is
3407
+ * enabled and metadata is set on a write transaction then the document
3408
+ * inserted into the `__history` collection will have (at least) the provided
3409
+ * metadata stored under the `meta` key of the document.
3410
+ *
3411
+ * Return codes:
3412
+ *
3413
+ * * `0` -- success
3414
+ * * `1` -- invalid metadata CBOR
3415
+ * * `-1` -- valid metadata CBOR but the CBOR does not represent an object
3416
+ * * `-2` -- [js only] missing `await`s
3417
+ */
3418
+ int32_t
3419
+ /* fn */ ditto_write_transaction_add_metadata (
3420
+ CWriteTransaction_t * transaction,
3421
+ slice_ref_uint8_t metadata_cbor);
3422
+
3423
+ /** \brief
3424
+ * Commits the given txn.
3425
+ *
3426
+ * [js only]: returns -1 on failure, in case of missing `await`s.
3427
+ */
3428
+ int32_t
3429
+ /* fn */ ditto_write_transaction_commit (
3430
+ CDitto_t const * _ditto,
3431
+ CWriteTransaction_t * transaction);
3432
+
3433
+ /** \brief
3434
+ * Frees the txn handle, *falling back* to a rollback, which requires
3435
+ * `async`-in-drop. Only useful as a safeguard for RAII-with-proper-ownership
3436
+ * languages, _i.e._, the Rust SDK.
3437
+ *
3438
+ * For other languages, favor using `ditto_write_transaction_rollback`
3439
+ */
3440
+ void
3441
+ /* fn */ ditto_write_transaction_free (
3442
+ CWriteTransaction_t * transaction);
3443
+
3444
+ /** \brief
3445
+ * For SDKs using the batched/scoped write-txn APIs, if an error occurs
3446
+ * mid-operation (_e.g._, customer callback throwing an exception), then the
3447
+ * txn must not be committed, but it ought to be disposed of, _via_ a rollback.
3448
+ *
3449
+ * [js only]: returns -1 on failure, in case of missing `await`s.
3450
+ */
3451
+ int32_t
3452
+ /* fn */ ditto_write_transaction_rollback (
3453
+ CDitto_t const * _ditto,
3454
+ CWriteTransaction_t * transaction);
3455
+
3456
+ /** <No documentation available> */
3457
+ void
3458
+ /* fn */ dittoffi_authentication_register_local_server_backend (
3459
+ CDitto_t const * ditto,
3460
+ void * ctx,
3461
+ void (*retain)(void *),
3462
+ void (*release)(void *),
3463
+ void (*auth_cb)(void *, CAuthServerAuthRequest_t *, slice_ref_uint8_t),
3464
+ void (*refresh_cb)(void *, CAuthServerRefreshRequest_t *, slice_ref_uint8_t));
3465
+
3466
+ /** <No documentation available> */
3467
+ typedef struct dittoffi_authentication_status dittoffi_authentication_status_t;
3468
+
3469
+ /** \brief
3470
+ * Dispose of the auth status.
3471
+ */
3472
+ void
3473
+ /* fn */ dittoffi_authentication_status_free (
3474
+ dittoffi_authentication_status_t * __arg_0);
3475
+
3476
+ /** \brief
3477
+ * Extract the authenticated state.
3478
+ */
3479
+ bool
3480
+ /* fn */ dittoffi_authentication_status_is_authenticated (
3481
+ dittoffi_authentication_status_t const * auth_status);
3482
+
3483
+ /** \brief
3484
+ * Extract the user ID.
3485
+ */
3486
+ char *
3487
+ /* fn */ dittoffi_authentication_status_user_id (
3488
+ dittoffi_authentication_status_t const * auth_status);
3489
+
3490
+ /** \brief
3491
+ * To be used when base64 encoding or decoding.
3492
+ *
3493
+ * When encoding, specifies whether to produce padded or unpadded output. When decoding, specifies
3494
+ * whether or not to accept a padded input string.
3495
+ */
3496
+ typedef enum Base64PaddingMode {
3497
+ /** <No documentation available> */
3498
+ BASE64_PADDING_MODE_PADDED = 1,
3499
+ /** <No documentation available> */
3500
+ BASE64_PADDING_MODE_UNPADDED,
3501
+ } Base64PaddingMode_t;
3502
+
3503
+ /** \brief
3504
+ * Encodes a slice of bytes as a URL-safe base64 string. The caller can specify whether or not they
3505
+ * want the output to be padded.
3506
+ *
3507
+ * The returned string needs to be freed by the caller using `ditto_c_string_free`.
3508
+ */
3509
+ char *
3510
+ /* fn */ dittoffi_base64_encode (
3511
+ slice_ref_uint8_t bytes,
3512
+ Base64PaddingMode_t padding_mode);
3513
+
3514
+ /** <No documentation available> */
3515
+ BoolResult_t
3516
+ /* fn */ dittoffi_check_doc_cbor_against_provided_cbor (
3517
+ slice_ref_uint8_t document_cbor,
3518
+ slice_ref_uint8_t provided_cbor);
3519
+
3520
+ /** \brief
3521
+ * Opaque type encapsulating the different args provided to the `.on_connecting()`
3522
+ * callback in a future-proof fashion.
3523
+ *
3524
+ * This is the lowest-level "wrapped" callback, i.e. the most convenient set of types for
3525
+ * passing across the FFI barrier.
3526
+ *
3527
+ * Typically, SDKs will have a wrapping method that does the (de)serialization to/from CBOR
3528
+ * to create a more user-friendly function signature for `connecting_peer`.
3529
+ */
3530
+ typedef struct dittoffi_connection_request dittoffi_connection_request_t;
3531
+
3532
+ /** <No documentation available> */
3533
+ typedef enum dittoffi_connection_request_authorization {
3534
+ /** <No documentation available> */
3535
+ DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_DENY,
3536
+ /** <No documentation available> */
3537
+ DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_ALLOW,
3538
+ } dittoffi_connection_request_authorization_t;
3539
+
3540
+ /** \brief
3541
+ * Answer/output of the `connection_request_handler`, communicated through the `connection_request`
3542
+ * object.
3543
+ * `true` allows the connection, `false` rejects it.
3544
+ */
3545
+ void
3546
+ /* fn */ dittoffi_connection_request_authorize (
3547
+ dittoffi_connection_request_t const * r,
3548
+ dittoffi_connection_request_authorization_t authorized);
3549
+
3550
+ /** \brief
3551
+ * A simplified [`ConnectionType`] exposed to the SDKs
3552
+ */
3553
+ typedef enum dittoffi_connection_type {
3554
+ /** <No documentation available> */
3555
+ DITTOFFI_CONNECTION_TYPE_BLUETOOTH,
3556
+ /** <No documentation available> */
3557
+ DITTOFFI_CONNECTION_TYPE_ACCESS_POINT,
3558
+ /** <No documentation available> */
3559
+ DITTOFFI_CONNECTION_TYPE_P2_P_WI_FI,
3560
+ /** <No documentation available> */
3561
+ DITTOFFI_CONNECTION_TYPE_WEB_SOCKET,
3562
+ } dittoffi_connection_type_t;
3563
+
3564
+ /** \brief
3565
+ * The connection type being used to connect with the connecting peer.
3566
+ */
3567
+ dittoffi_connection_type_t
3568
+ /* fn */ dittoffi_connection_request_connection_type (
3569
+ dittoffi_connection_request_t const * r);
3570
+
3571
+ /** <No documentation available> */
3572
+ void
3573
+ /* fn */ dittoffi_connection_request_free (
3574
+ dittoffi_connection_request_t * __arg_0);
3575
+
3576
+ /** \brief
3577
+ * Getter for the `identity_service` as a JSON (string / UTF-8 data).
3578
+ */
3579
+ slice_ref_uint8_t
3580
+ /* fn */ dittoffi_connection_request_identity_service_metadata_json (
3581
+ dittoffi_connection_request_t const * r);
3582
+
3583
+ /** \brief
3584
+ * The connecting peer's (pub) key (empty for legacy peers), hex-encoded as a string
3585
+ */
3586
+ char *
3587
+ /* fn */ dittoffi_connection_request_peer_key_string (
3588
+ dittoffi_connection_request_t const * r);
3589
+
3590
+ /** \brief
3591
+ * Getter for the `peer_metadata` as a JSON (string / UTF-8 data).
3592
+ */
3593
+ slice_ref_uint8_t
3594
+ /* fn */ dittoffi_connection_request_peer_metadata_json (
3595
+ dittoffi_connection_request_t const * r);
3596
+
3597
+ /** \brief
3598
+ * Generates 32 random bytes and returns them as a base64 (URL safe and padded) encoded string.
3599
+ *
3600
+ * The returned string needs to be freed using `ditto_c_string_free`.
3601
+ *
3602
+ * Note: This is currently only being used by the JS SDK. Any other usage of this function is
3603
+ * likely indicative of a deficiency in the API being provided to SDKs.
3604
+ */
3605
+ char *
3606
+ /* fn */ dittoffi_crypto_generate_secure_random_token (void);
3607
+
3608
+ /** \brief
3609
+ * Internal helper function to do integration testing of stacktrace generation in the SDKs.
3610
+ */
3611
+ char *
3612
+ /* fn */ dittoffi_ditto_capture_stack_trace_string_internal (void);
3613
+
3614
+ /** \brief
3615
+ * The ditto error type, opaque.
3616
+ */
3617
+ typedef struct dittoffi_error dittoffi_error_t;
3618
+
3619
+ /** <No documentation available> */
3620
+ typedef struct dittoffi_result_uint64 {
3621
+ /** \brief
3622
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3623
+ */
3624
+ dittoffi_error_t * error;
3625
+
3626
+ /** \brief
3627
+ * When no error occurred, the success value payload can be retrieved here.
3628
+ *
3629
+ * Otherwise, the value is to be ignored.
3630
+ */
3631
+ uint64_t success;
3632
+ } dittoffi_result_uint64_t;
3633
+
3634
+ /** <No documentation available> */
3635
+ dittoffi_result_uint64_t
3636
+ /* fn */ dittoffi_ditto_get_system_parameter_u64 (
3637
+ CDitto_t const * ditto,
3638
+ char const * parameter_name);
3639
+
3640
+ /** \brief
3641
+ * Returns whether or not the Ditto instance has been activated with a valid license token.
3642
+ *
3643
+ * When a Ditto instance is using non-online identity types then this will always return `true`.
3644
+ */
3645
+ bool
3646
+ /* fn */ dittoffi_ditto_is_activated (
3647
+ CDitto_t const * ditto);
3648
+
3649
+ /** <No documentation available> */
3650
+ bool
3651
+ /* fn */ dittoffi_ditto_is_sync_active (
3652
+ CDitto_t const * ditto);
3653
+
3654
+ /** \brief
3655
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
3656
+ */
3657
+ typedef struct BoxDynFnMut1_void_dittoffi_authentication_status_ptr {
3658
+ /** <No documentation available> */
3659
+ void * env_ptr;
3660
+
3661
+ /** <No documentation available> */
3662
+ void (*call)(void *, dittoffi_authentication_status_t *);
3663
+
3664
+ /** <No documentation available> */
3665
+ void (*free)(void *);
3666
+ } BoxDynFnMut1_void_dittoffi_authentication_status_ptr_t;
3667
+
3668
+ /** <No documentation available> */
3669
+ typedef BoxDynFnMut1_void_dittoffi_authentication_status_ptr_t dittoffi_authentication_status_handler_t;
3670
+
3671
+ /** <No documentation available> */
3672
+ void
3673
+ /* fn */ dittoffi_ditto_set_authentication_status_handler (
3674
+ CDitto_t const * ditto,
3675
+ dittoffi_authentication_status_handler_t handler);
3676
+
3677
+ /** \brief
3678
+ * Set whether or not the cloud sync should be enabled for the Ditto instance.
3679
+ *
3680
+ * This is a bit of a hack for now. It should only be called once, at the start of a (SDK) Ditto's
3681
+ * instance's lifecycle. Calling this ensures that correct transport configs will be computed when
3682
+ * using the "transports behind core" logic (i.e. using the core-defined logic for ensuring the
3683
+ * correct transports are started/stopped at the correct time).
3684
+ *
3685
+ * Eventually this should likely be folded into `TransportConfig` somehow.
3686
+ */
3687
+ void
3688
+ /* fn */ dittoffi_ditto_set_cloud_sync_enabled (
3689
+ CDitto_t const * ditto,
3690
+ bool enabled);
3691
+
3692
+ /** <No documentation available> */
3693
+ typedef struct dittoffi_result_void {
3694
+ /** \brief
3695
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3696
+ */
3697
+ dittoffi_error_t * error;
3698
+ } dittoffi_result_void_t;
3699
+
3700
+ /** \brief
3701
+ * Verify a base64 encoded license string.
3702
+ *
3703
+ * # Parameters
3704
+ * - `ditto`: The Ditto instance to activate.
3705
+ * - `license`: A base64 encoded license string. This should be the output of
3706
+ * `ditto_licenser::license_mgr::generate()`.
3707
+ */
3708
+ dittoffi_result_void_t
3709
+ /* fn */ dittoffi_ditto_set_offline_only_license_token_throws (
3710
+ CDitto_t const * ditto,
3711
+ char const * license);
3712
+
3713
+ /** <No documentation available> */
3714
+ typedef struct dittoffi_panic dittoffi_panic_t;
3715
+
3716
+ /** \brief
3717
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
3718
+ */
3719
+ typedef struct BoxDynFnMut1_void_dittoffi_panic_ptr {
3720
+ /** <No documentation available> */
3721
+ void * env_ptr;
3722
+
3723
+ /** <No documentation available> */
3724
+ void (*call)(void *, dittoffi_panic_t *);
3725
+
3726
+ /** <No documentation available> */
3727
+ void (*free)(void *);
3728
+ } BoxDynFnMut1_void_dittoffi_panic_ptr_t;
3729
+
3730
+ /** <No documentation available> */
3731
+ typedef BoxDynFnMut1_void_dittoffi_panic_ptr_t dittoffi_panic_handler_t;
3732
+
3733
+ /** \brief
3734
+ * Registers a custom callback/hook to report a panic message and stacktrace right before the
3735
+ * process aborts, if none have been registered beforehand.
3736
+ *
3737
+ * Else, a default console logging hooks takes place, which for certain SDKs such as Android,
3738
+ * yields hard-to-access crash reports.
3739
+ *
3740
+ * Do note that this "handler" does not really "handle" anything, insofar it cannot prevent the
3741
+ * impending doom/abort. It's really just a reporter, to say the last words of the process.
3742
+ */
3743
+ void
3744
+ /* fn */ dittoffi_ditto_set_panic_handler (
3745
+ dittoffi_panic_handler_t panic_handler);
3746
+
3747
+ /** <No documentation available> */
3748
+ void
3749
+ /* fn */ dittoffi_ditto_stop_sync (
3750
+ CDitto_t const * ditto);
3751
+
3752
+ /** <No documentation available> */
3753
+ slice_boxed_uint8_t
3754
+ /* fn */ dittoffi_ditto_transport_config (
3755
+ CDitto_t const * ditto);
3756
+
3757
+ /** \brief
3758
+ * Internal helper function to do integration testing of panics in the SDKs.
3759
+ */
3760
+ int32_t
3761
+ /* fn */ dittoffi_ditto_trigger_test_panic (void);
3762
+
3763
+ /** \brief
3764
+ * Internal helper function to do integration testing of panics in the SDKs.
3765
+ */
3766
+ void
3767
+ /* fn */ dittoffi_ditto_trigger_test_panic_in_background (void);
3768
+
3769
+ /** \brief
3770
+ * Whether or not the default values for parts of a `TransportConfig` that could be
3771
+ * platform-dependent should be determined based on the platform that the SDK is running on.
3772
+ *
3773
+ * For example, if `PlatformDependent` is chosen for the `TransportConfigMode`, then the default
3774
+ * value for whether AWDL would be enabled would be based on whether the SDK is running on an Apple
3775
+ * platform. Specifically, if you were running on an iOS device, for example, then AWDL would
3776
+ * default to enabled, but if you were using the .NET SDK running on a Windows machine then AWDL
3777
+ * would default to false.
3778
+ *
3779
+ * If `TransportConfigMode::PlatformIndependent` is chosen, then the default value would always be
3780
+ * true (at least in the case of whether or not AWDL is enabled).
3781
+ *
3782
+ * This really only exists to cater for the difference in behavior between the JS (and Flutter) and
3783
+ * other SDKs. The JS SDK's default value for platform-specific transports will be determined by
3784
+ * the platform that the JS SDK is running on, whereas the other SDKs will default to the same
3785
+ * value regardless of the platform that they are running on.
3786
+ */
3787
+ typedef enum TransportConfigMode {
3788
+ /** <No documentation available> */
3789
+ TRANSPORT_CONFIG_MODE_PLATFORM_DEPENDENT,
3790
+ /** <No documentation available> */
3791
+ TRANSPORT_CONFIG_MODE_PLATFORM_INDEPENDENT,
3792
+ } TransportConfigMode_t;
3793
+
3794
+ /** <No documentation available> */
3795
+ typedef struct dittoffi_result_CDitto_ptr {
3796
+ /** \brief
3797
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3798
+ */
3799
+ dittoffi_error_t * error;
3800
+
3801
+ /** \brief
3802
+ * When no error occurred, the success value payload can be retrieved here.
3803
+ *
3804
+ * Otherwise, the value is to be ignored.
3805
+ */
3806
+ CDitto_t * success;
3807
+ } dittoffi_result_CDitto_ptr_t;
3808
+
3809
+ /** \brief
3810
+ * Same as `ditto_make`, but properly fallible (but not yet `async`).
3811
+ */
3812
+ dittoffi_result_CDitto_ptr_t
3813
+ /* fn */ dittoffi_ditto_try_new_blocking (
3814
+ char const * working_dir,
3815
+ CIdentityConfig_t * identity_config,
3816
+ HistoryTracking_t history_tracking,
3817
+ char const * experimental_passphrase,
3818
+ TransportConfigMode_t transport_config_mode);
3819
+
3820
+ /** \brief
3821
+ * Set the transport config, start/stop transports as needed.
3822
+ *
3823
+ * * `ditto` - The Ditto instance.
3824
+ * * `transport_config_cbor` - `TransportConfig` serialized as CBOR.
3825
+ * * `should_validate` - If true, the `TransportConfig` will be validated before being set.
3826
+ *
3827
+ * Returns error on failure to deserialize `transport_config_cbor`, or if `should_validate` is true
3828
+ * and the `TransportConfig` fails validation.
3829
+ */
3830
+ dittoffi_result_void_t
3831
+ /* fn */ dittoffi_ditto_try_set_transport_config (
3832
+ CDitto_t const * ditto,
3833
+ slice_ref_uint8_t transport_config_cbor,
3834
+ bool should_validate);
3835
+
3836
+ /** <No documentation available> */
3837
+ dittoffi_result_void_t
3838
+ /* fn */ dittoffi_ditto_try_start_sync (
3839
+ CDitto_t const * ditto);
3840
+
3841
+ /** \brief
3842
+ * Whether to use a helper thread for calling into the panic handler.
3843
+ *
3844
+ * Defaults to `false` when the `js` feature is enabled (Node.js &
3845
+ * Wasm), and `true` otherwise.
3846
+ */
3847
+ void
3848
+ /* fn */ dittoffi_ditto_use_helper_thread_for_panic_handler_internal (
3849
+ bool value);
3850
+
3851
+ /** \brief
3852
+ * The error codes for `ditto_error_t`
3853
+ */
3854
+ typedef enum dittoffi_error_code {
3855
+ /** \brief
3856
+ * The license is valid but expired.
3857
+ */
3858
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_EXPIRED,
3859
+ /** \brief
3860
+ * The license signature failed verification. This could be due to incorrectly
3861
+ * encoded/truncated data or could indicate tampering.
3862
+ */
3863
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_INVALID,
3864
+ /** \brief
3865
+ * The provided license data was from a future version of Ditto and is incompatible with this
3866
+ * version.
3867
+ */
3868
+ DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_UNSUPPORTED_FUTURE_VERSION,
3869
+ /** \brief
3870
+ * The operation failed because the Ditto instance is not yet activated, which is achieved by
3871
+ * setting a valid license token.
3872
+ */
3873
+ DITTOFFI_ERROR_CODE_ACTIVATION_NOT_ACTIVATED,
3874
+ /** \brief
3875
+ * Activation (via setting a valid license token) is unnecessary for the active identity type.
3876
+ */
3877
+ DITTOFFI_ERROR_CODE_ACTIVATION_UNNECESSARY,
3878
+ /** \brief
3879
+ * Invalid input provided for base64 decoding.
3880
+ */
3881
+ DITTOFFI_ERROR_CODE_BASE64_INVALID,
3882
+ /** \brief
3883
+ * Invalid CBOR-encoded input.
3884
+ */
3885
+ DITTOFFI_ERROR_CODE_CBOR_INVALID,
3886
+ /** \brief
3887
+ * Unsupported CBOR type.
3888
+ */
3889
+ DITTOFFI_ERROR_CODE_CBOR_UNSUPPORTED,
3890
+ /** <No documentation available> */
3891
+ DITTOFFI_ERROR_CODE_CRDT,
3892
+ /** \brief
3893
+ * Dql query execution failed in flight.
3894
+ */
3895
+ DITTOFFI_ERROR_CODE_DQL_EVALUATION_ERROR,
3896
+ /** \brief
3897
+ * Invalid CBOR-encoded query arguments.
3898
+ */
3899
+ DITTOFFI_ERROR_CODE_DQL_INVALID_QUERY_ARGS,
3900
+ /** \brief
3901
+ * Failed to compile the given query.
3902
+ *
3903
+ * For more information on Ditto's query language see:
3904
+ * <https://docs.ditto.live/dql-guide>
3905
+ */
3906
+ DITTOFFI_ERROR_CODE_DQL_QUERY_COMPILATION,
3907
+ /** \brief
3908
+ * Unsupported features were used in a DQL statement or query.
3909
+ */
3910
+ DITTOFFI_ERROR_CODE_DQL_UNSUPPORTED,
3911
+ /** \brief
3912
+ * Unexpected passphrase provided for the currently unencrypted store.
3913
+ */
3914
+ DITTOFFI_ERROR_CODE_ENCRYPTION_EXTRANEOUS_PASSPHRASE_GIVEN,
3915
+ /** \brief
3916
+ * Incorrect passphrase provided for the currently encrypted store.
3917
+ */
3918
+ DITTOFFI_ERROR_CODE_ENCRYPTION_PASSPHRASE_INVALID,
3919
+ /** \brief
3920
+ * Missing passphrase for the currently encrypted store.
3921
+ */
3922
+ DITTOFFI_ERROR_CODE_ENCRYPTION_PASSPHRASE_NOT_GIVEN,
3923
+ /** \brief
3924
+ * Javascript only. Missing `await` on outstanding store operation.
3925
+ */
3926
+ DITTOFFI_ERROR_CODE_JS_FLOATING_STORE_OPERATION,
3927
+ /** \brief
3928
+ * An I/O operation failed because the specified entity (such as a file) already exists.
3929
+ */
3930
+ DITTOFFI_ERROR_CODE_IO_ALREADY_EXISTS,
3931
+ /** \brief
3932
+ * An I/O operation failed because the specified entity (such as a file) was not found.
3933
+ */
3934
+ DITTOFFI_ERROR_CODE_IO_NOT_FOUND,
3935
+ /** \brief
3936
+ * An I/O operation failed.
3937
+ */
3938
+ DITTOFFI_ERROR_CODE_IO_OPERATION_FAILED,
3939
+ /** \brief
3940
+ * An I/O operation failed because the necessary privileges to complete it were not present.
3941
+ */
3942
+ DITTOFFI_ERROR_CODE_IO_PERMISSION_DENIED,
3943
+ /** \brief
3944
+ * Outstanding usage of ditto's working directory detected when trying to instantiate a new
3945
+ * `Ditto`, which would have led to concurrent usage of the backing database files.
3946
+ */
3947
+ DITTOFFI_ERROR_CODE_LOCKED_DITTO_WORKING_DIRECTORY,
3948
+ /** \brief
3949
+ * A query to alter or retrieve a system parameter (ALTER SYSTEM or SHOW) failed.
3950
+ */
3951
+ DITTOFFI_ERROR_CODE_PARAMETER_QUERY,
3952
+ /** <No documentation available> */
3953
+ DITTOFFI_ERROR_CODE_STORE_DATABASE,
3954
+ /** \brief
3955
+ * Found an invalid document id.
3956
+ */
3957
+ DITTOFFI_ERROR_CODE_STORE_DOCUMENT_ID,
3958
+ /** \brief
3959
+ * The requested document could not be found.
3960
+ */
3961
+ DITTOFFI_ERROR_CODE_STORE_DOCUMENT_NOT_FOUND,
3962
+ /** <No documentation available> */
3963
+ DITTOFFI_ERROR_CODE_STORE_QUERY,
3964
+ /** \brief
3965
+ * A mutating DQL query was attempted using a read-only transaction.
3966
+ */
3967
+ DITTOFFI_ERROR_CODE_STORE_TRANSACTION_READ_ONLY,
3968
+ /** \brief
3969
+ * Error from the transport layer.
3970
+ */
3971
+ DITTOFFI_ERROR_CODE_TRANSPORT,
3972
+ /** \brief
3973
+ * Feature is not (yet?) supported (on this platform?).
3974
+ *
3975
+ * See the documentation of the feature for more info.
3976
+ */
3977
+ DITTOFFI_ERROR_CODE_UNSUPPORTED,
3978
+ /** \brief
3979
+ * Exceeded a depth limit.
3980
+ */
3981
+ DITTOFFI_ERROR_CODE_VALIDATION_DEPTH_LIMIT_EXCEEDED,
3982
+ /** \brief
3983
+ * Invalid CBOR provided.
3984
+ */
3985
+ DITTOFFI_ERROR_CODE_VALIDATION_INVALID_CBOR,
3986
+ /** \brief
3987
+ * Invalid JSON provided.
3988
+ */
3989
+ DITTOFFI_ERROR_CODE_VALIDATION_INVALID_JSON,
3990
+ /** \brief
3991
+ * Invalid TransportConfig.
3992
+ */
3993
+ DITTOFFI_ERROR_CODE_VALIDATION_INVALID_TRANSPORT_CONFIG,
3994
+ /** \brief
3995
+ * The value was not a map.
3996
+ */
3997
+ DITTOFFI_ERROR_CODE_VALIDATION_NOT_A_MAP,
3998
+ /** \brief
3999
+ * Exceeded the size limit.
4000
+ */
4001
+ DITTOFFI_ERROR_CODE_VALIDATION_SIZE_LIMIT_EXCEEDED,
4002
+ /** \brief
4003
+ * Attempted to use a Ditto feature after closing Ditto.
4004
+ * An unknown error occurred.
4005
+ */
4006
+ DITTOFFI_ERROR_CODE_UNKNOWN,
4007
+ /** \brief
4008
+ * Some not-yet-categorized error occurred.
4009
+ */
4010
+ DITTOFFI_ERROR_CODE_INTERNAL,
4011
+ } dittoffi_error_code_t;
4012
+
4013
+ /** <No documentation available> */
4014
+ dittoffi_error_code_t
4015
+ /* fn */ dittoffi_error_code (
4016
+ dittoffi_error_t const * error);
4017
+
4018
+ /** <No documentation available> */
4019
+ char *
4020
+ /* fn */ dittoffi_error_description (
4021
+ dittoffi_error_t const * error);
4022
+
4023
+ /** <No documentation available> */
4024
+ void
4025
+ /* fn */ dittoffi_error_free (
4026
+ dittoffi_error_t * error);
4027
+
4028
+ /** \brief
4029
+ * Internal helper function to extract the inner error code from `Internal` errors.
4030
+ *
4031
+ * Must only be called after having checked that the `dittoffi_error_code()` does yield
4032
+ * `FfiErrorCode::Internal`, lest it panic.
4033
+ */
4034
+ DittoErrorCode_t
4035
+ /* fn */ dittoffi_error_internal_get_legacy_error_code (
4036
+ dittoffi_error_t const * error);
4037
+
4038
+ /** \brief
4039
+ * Returns a human-readable SDK version string, restricted to the SemVer
4040
+ * "number" (including the pre-release specifier, if any).
4041
+ *
4042
+ * The returned string must be freed.
4043
+ */
4044
+ char *
4045
+ /* fn */ dittoffi_get_sdk_semver (void);
4046
+
4047
+ /** \brief
4048
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
4049
+ */
4050
+ typedef struct BoxDynFnMut1_void_dittoffi_result_uint64 {
4051
+ /** <No documentation available> */
4052
+ void * env_ptr;
4053
+
4054
+ /** <No documentation available> */
4055
+ void (*call)(void *, dittoffi_result_uint64_t);
4056
+
4057
+ /** <No documentation available> */
4058
+ void (*free)(void *);
4059
+ } BoxDynFnMut1_void_dittoffi_result_uint64_t;
4060
+
4061
+ /** \brief
4062
+ * Continuation (`repr_c::Box<dyn FnMut(…)>` FFI-safe callback) to be used as
4063
+ * the *completion handler* for conceptually-`async` APIs.
4064
+ */
4065
+ typedef BoxDynFnMut1_void_dittoffi_result_uint64_t continuation_dittoffi_result_uint64_t;
4066
+
4067
+ /** \brief
4068
+ * Export previously collected on-disk logs to a single file at the specified path.
4069
+ *
4070
+ * Returns one of the following errors on failure:
4071
+ *
4072
+ * - [`FfiError::IoNotFound`]
4073
+ * - [`FfiError::IoPermissionDenied`]
4074
+ * - [`FfiError::IoAlreadyExists`]
4075
+ * - [`FfiError::IoOperationFailed`]
4076
+ * - [`FfiError::Unsupported`]
4077
+ * - [`FfiError::Unknown`]
4078
+ */
4079
+ void
4080
+ /* fn */ dittoffi_logger_try_export_to_file_async (
4081
+ char const * dest_path,
4082
+ continuation_dittoffi_result_uint64_t continuation);
4083
+
4084
+ /** \brief
4085
+ * The same as `ditto_make` but it allows for an explicit value for `TransportConfigMode` to be
4086
+ * provided.
4087
+ */
4088
+ CDitto_t *
4089
+ /* fn */ dittoffi_make_with_transport_config_mode (
4090
+ char const * working_dir,
4091
+ CIdentityConfig_t * identity_config,
4092
+ HistoryTracking_t history_tracking,
4093
+ TransportConfigMode_t transport_config_mode);
4094
+
4095
+ /** \brief
4096
+ * Dispose of the panic handle (even if the process is about to abort anyways).
4097
+ */
4098
+ void
4099
+ /* fn */ dittoffi_panic_free (
4100
+ dittoffi_panic_t * __arg_0);
4101
+
4102
+ /** \brief
4103
+ * Extract the panic message.
4104
+ */
4105
+ char *
4106
+ /* fn */ dittoffi_panic_message (
4107
+ dittoffi_panic_t const * panic);
4108
+
4109
+ /** \brief
4110
+ * Extract the stacktrace whence the panic occurred, currently as a C string with newlines in it.
4111
+ */
4112
+ char *
4113
+ /* fn */ dittoffi_panic_stack_trace_string (
4114
+ dittoffi_panic_t const * panic);
4115
+
4116
+ /** \brief
4117
+ * Getter for the `peer_metadata` as a JSON (string / UTF-8 data).
4118
+ */
4119
+ slice_boxed_uint8_t
4120
+ /* fn */ dittoffi_presence_peer_metadata_json (
4121
+ CDitto_t const * ditto);
4122
+
4123
+ /** <No documentation available> */
4124
+ typedef struct Erased Erased_t;
4125
+
4126
+ /** <No documentation available> */
4127
+ typedef struct FfiConnectionRequestHandlerVTable {
4128
+ /** <No documentation available> */
4129
+ void (*release_vptr)(Erased_t *);
4130
+
4131
+ /** <No documentation available> */
4132
+ Erased_t * (*retain_vptr)(Erased_t const *);
4133
+
4134
+ /** <No documentation available> */
4135
+ void (*on_connecting)(Erased_t const *, dittoffi_connection_request_t *);
4136
+ } FfiConnectionRequestHandlerVTable_t;
4137
+
4138
+ /** <No documentation available> */
4139
+ typedef struct VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable {
4140
+ /** <No documentation available> */
4141
+ Erased_t * ptr;
4142
+
4143
+ /** <No documentation available> */
4144
+ FfiConnectionRequestHandlerVTable_t vtable;
4145
+ } VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t;
4146
+
4147
+ /** \brief
4148
+ * Register a function that will be called every time a peer connection attempt is made.
4149
+ * The function can return true to continue connecting, and false to reject the connection,
4150
+ * based on the supplied metadata about the peer.
4151
+ */
4152
+ void
4153
+ /* fn */ dittoffi_presence_set_connection_request_handler (
4154
+ CDitto_t const * ditto,
4155
+ VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t ffi_handler);
4156
+
4157
+ /** \brief
4158
+ * Sets the signed peer info / peer metadata to which the `on_connecting` /
4159
+ * `connectionRequestHandler` callback shall have access.
4160
+ *
4161
+ * The `peer_info` is expected to represent the UTF-8 bytes of a serialized JSON instead of CBOR.
4162
+ */
4163
+ dittoffi_result_void_t
4164
+ /* fn */ dittoffi_presence_try_set_peer_metadata_json (
4165
+ CDitto_t const * ditto,
4166
+ slice_ref_uint8_t peer_info);
4167
+
4168
+ /** <No documentation available> */
4169
+ typedef struct dittoffi_query_result dittoffi_query_result_t;
4170
+
4171
+ /** <No documentation available> */
4172
+ void
4173
+ /* fn */ dittoffi_query_result_free (
4174
+ dittoffi_query_result_t * result);
4175
+
4176
+ /** <No documentation available> */
4177
+ typedef struct dittoffi_query_result_item dittoffi_query_result_item_t;
4178
+
4179
+ /** <No documentation available> */
4180
+ dittoffi_query_result_item_t *
4181
+ /* fn */ dittoffi_query_result_item_at (
4182
+ dittoffi_query_result_t const * result,
4183
+ size_t idx);
4184
+
4185
+ /** <No documentation available> */
4186
+ slice_boxed_uint8_t
4187
+ /* fn */ dittoffi_query_result_item_cbor (
4188
+ dittoffi_query_result_item_t const * item);
4189
+
4190
+ /** <No documentation available> */
4191
+ size_t
4192
+ /* fn */ dittoffi_query_result_item_count (
4193
+ dittoffi_query_result_t const * result);
4194
+
4195
+ /** <No documentation available> */
4196
+ void
4197
+ /* fn */ dittoffi_query_result_item_free (
4198
+ dittoffi_query_result_item_t * item);
4199
+
4200
+ /** <No documentation available> */
4201
+ char *
4202
+ /* fn */ dittoffi_query_result_item_json (
4203
+ dittoffi_query_result_item_t const * item);
4204
+
4205
+ /** <No documentation available> */
4206
+ slice_boxed_uint8_t
4207
+ /* fn */ dittoffi_query_result_mutated_document_id_at (
4208
+ dittoffi_query_result_t const * result,
4209
+ size_t idx);
4210
+
4211
+ /** <No documentation available> */
4212
+ size_t
4213
+ /* fn */ dittoffi_query_result_mutated_document_id_count (
4214
+ dittoffi_query_result_t const * result);
4215
+
4216
+ /** \brief
4217
+ * Alias for `Ditto`, to better convey the notion of a store handle for store APIs,
4218
+ * TownHouse™-style.
4219
+ */
4220
+ typedef CDitto_t dittoffi_store_t;
4221
+
4222
+ /** \brief
4223
+ * FFI appropriate representation of the options available when beginning a transaction.
4224
+ */
4225
+ typedef struct dittoffi_store_begin_transaction_options {
4226
+ /** \brief
4227
+ * Whether the transaction is read-only. Defaults to `false`.
4228
+ */
4229
+ bool is_read_only;
4230
+
4231
+ /** \brief
4232
+ * An optional hint for the transaction. This is often useful for identifying a transaction in
4233
+ * logs.
4234
+ */
4235
+ char const * hint;
4236
+ } dittoffi_store_begin_transaction_options_t;
4237
+
4238
+ /** <No documentation available> */
4239
+ typedef struct dittoffi_transaction dittoffi_transaction_t;
4240
+
4241
+ /** <No documentation available> */
4242
+ typedef struct dittoffi_result_dittoffi_transaction_ptr {
4243
+ /** \brief
4244
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4245
+ */
4246
+ dittoffi_error_t * error;
4247
+
4248
+ /** \brief
4249
+ * When no error occurred, the success value payload can be retrieved here.
4250
+ *
4251
+ * Otherwise, the value is to be ignored.
4252
+ */
4253
+ dittoffi_transaction_t * success;
4254
+ } dittoffi_result_dittoffi_transaction_ptr_t;
4255
+
4256
+ /** \brief
4257
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
4258
+ */
4259
+ typedef struct BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_ptr {
4260
+ /** <No documentation available> */
4261
+ void * env_ptr;
4262
+
4263
+ /** <No documentation available> */
4264
+ void (*call)(void *, dittoffi_result_dittoffi_transaction_ptr_t);
4265
+
4266
+ /** <No documentation available> */
4267
+ void (*free)(void *);
4268
+ } BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_ptr_t;
4269
+
4270
+ /** \brief
4271
+ * Continuation (`repr_c::Box<dyn FnMut(…)>` FFI-safe callback) to be used as
4272
+ * the *completion handler* for conceptually-`async` APIs.
4273
+ */
4274
+ typedef BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_ptr_t continuation_dittoffi_result_dittoffi_transaction_ptr_t;
4275
+
4276
+ /** \brief
4277
+ * Creates a new transaction.
4278
+ */
4279
+ void
4280
+ /* fn */ dittoffi_store_begin_transaction_async_throws (
4281
+ dittoffi_store_t const * store,
4282
+ dittoffi_store_begin_transaction_options_t options,
4283
+ continuation_dittoffi_result_dittoffi_transaction_ptr_t continuation);
4284
+
4285
+ /** <No documentation available> */
4286
+ dittoffi_store_begin_transaction_options_t
4287
+ /* fn */ dittoffi_store_begin_transaction_options_make (void);
4288
+
4289
+ /** <No documentation available> */
4290
+ typedef slice_boxed_uint8_t dittoffi_cbor_data_t;
4291
+
4292
+ /** \brief
4293
+ * Returns all transactions currently in flight.
4294
+ */
4295
+ dittoffi_cbor_data_t
4296
+ /* fn */ dittoffi_store_transactions (
4297
+ dittoffi_store_t const * ffi_store);
4298
+
4299
+ /** <No documentation available> */
4300
+ typedef struct dittoffi_sync_subscription dittoffi_sync_subscription_t;
4301
+
4302
+ /** <No documentation available> */
4303
+ typedef struct dittoffi_result_dittoffi_sync_subscription_ptr {
4304
+ /** \brief
4305
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4306
+ */
4307
+ dittoffi_error_t * error;
4308
+
4309
+ /** \brief
4310
+ * When no error occurred, the success value payload can be retrieved here.
4311
+ *
4312
+ * Otherwise, the value is to be ignored.
4313
+ */
4314
+ dittoffi_sync_subscription_t * success;
4315
+ } dittoffi_result_dittoffi_sync_subscription_ptr_t;
4316
+
4317
+ /** <No documentation available> */
4318
+ dittoffi_result_dittoffi_sync_subscription_ptr_t
4319
+ /* fn */ dittoffi_sync_register_subscription_throws (
4320
+ CDitto_t const * ditto,
4321
+ char const * query,
4322
+ slice_ref_uint8_t query_args_cbor);
4323
+
4324
+ /** <No documentation available> */
4325
+ void
4326
+ /* fn */ dittoffi_sync_subscription_cancel (
4327
+ dittoffi_sync_subscription_t const * handle);
4328
+
4329
+ /** \brief
4330
+ * Free a singular boxed [`FfiSyncSubscription`].
4331
+ */
4332
+ void
4333
+ /* fn */ dittoffi_sync_subscription_free (
4334
+ dittoffi_sync_subscription_t * __arg_0);
4335
+
4336
+ /** \brief
4337
+ * Implementation detail needed for implementing Eq+Ord+Hash on `SyncSubscription`.
4338
+ */
4339
+ slice_boxed_uint8_t
4340
+ /* fn */ dittoffi_sync_subscription_id (
4341
+ dittoffi_sync_subscription_t const * handle);
4342
+
4343
+ /** <No documentation available> */
4344
+ bool
4345
+ /* fn */ dittoffi_sync_subscription_is_cancelled (
4346
+ dittoffi_sync_subscription_t const * handle);
4347
+
4348
+ /** \brief
4349
+ * From a `FfiSyncSubscription` handle, extract the DQL query query arguments as a CBOR buffer.
4350
+ */
4351
+ slice_boxed_uint8_t
4352
+ /* fn */ dittoffi_sync_subscription_query_arguments (
4353
+ dittoffi_sync_subscription_t const * handle);
4354
+
4355
+ /** \brief
4356
+ * From a `FfiSyncSubscription` handle, extract the DQL query string.
4357
+ */
4358
+ char *
4359
+ /* fn */ dittoffi_sync_subscription_query_string (
4360
+ dittoffi_sync_subscription_t const * handle);
4361
+
4362
+ /** \brief
4363
+ * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
4364
+ */
4365
+ typedef struct Vec_dittoffi_sync_subscription_ptr {
4366
+ /** <No documentation available> */
4367
+ dittoffi_sync_subscription_t * * ptr;
4368
+
4369
+ /** <No documentation available> */
4370
+ size_t len;
4371
+
4372
+ /** <No documentation available> */
4373
+ size_t cap;
4374
+ } Vec_dittoffi_sync_subscription_ptr_t;
4375
+
4376
+ /** <No documentation available> */
4377
+ Vec_dittoffi_sync_subscription_ptr_t
4378
+ /* fn */ dittoffi_sync_subscriptions (
4379
+ CDitto_t const * ditto);
4380
+
4381
+ /** \brief
4382
+ * Free a vector of boxed [`FfiSyncSubscription`]s.
4383
+ *
4384
+ * # IMPORTANT
4385
+ *
4386
+ * This freeing function ignores the given `.len` and treats it as if `.len = 0`
4387
+ * (to avoid double-freeing).
4388
+ *
4389
+ * SDK callers should have taken ownership of each individual `FfiSyncSubscription`
4390
+ * (either by having freed each, or by having wrapped them in some SDK class that
4391
+ * eventually will), in order to avoid memory leaks.
4392
+ */
4393
+ void
4394
+ /* fn */ dittoffi_sync_subscriptions_free_sparse (
4395
+ Vec_dittoffi_sync_subscription_ptr_t v);
4396
+
4397
+ /** \brief
4398
+ * The action to take when completing a transaction.
4399
+ */
4400
+ typedef enum dittoffi_transaction_completion_action {
4401
+ /** <No documentation available> */
4402
+ DITTOFFI_TRANSACTION_COMPLETION_ACTION_COMMIT,
4403
+ /** <No documentation available> */
4404
+ DITTOFFI_TRANSACTION_COMPLETION_ACTION_ROLLBACK,
4405
+ } dittoffi_transaction_completion_action_t;
4406
+
4407
+ /** <No documentation available> */
4408
+ typedef struct dittoffi_result_dittoffi_transaction_completion_action {
4409
+ /** \brief
4410
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4411
+ */
4412
+ dittoffi_error_t * error;
4413
+
4414
+ /** \brief
4415
+ * When no error occurred, the success value payload can be retrieved here.
4416
+ *
4417
+ * Otherwise, the value is to be ignored.
4418
+ */
4419
+ dittoffi_transaction_completion_action_t success;
4420
+ } dittoffi_result_dittoffi_transaction_completion_action_t;
4421
+
4422
+ /** \brief
4423
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
4424
+ */
4425
+ typedef struct BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_completion_action {
4426
+ /** <No documentation available> */
4427
+ void * env_ptr;
4428
+
4429
+ /** <No documentation available> */
4430
+ void (*call)(void *, dittoffi_result_dittoffi_transaction_completion_action_t);
4431
+
4432
+ /** <No documentation available> */
4433
+ void (*free)(void *);
4434
+ } BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_completion_action_t;
4435
+
4436
+ /** \brief
4437
+ * Continuation (`repr_c::Box<dyn FnMut(…)>` FFI-safe callback) to be used as
4438
+ * the *completion handler* for conceptually-`async` APIs.
4439
+ */
4440
+ typedef BoxDynFnMut1_void_dittoffi_result_dittoffi_transaction_completion_action_t continuation_dittoffi_result_dittoffi_transaction_completion_action_t;
4441
+
4442
+ /** \brief
4443
+ * Complete a transaction asynchronously.
4444
+ *
4445
+ * In practice this means either committing or rolling back the transaction.
4446
+ */
4447
+ void
4448
+ /* fn */ dittoffi_transaction_complete_async_throws (
4449
+ dittoffi_transaction_t const * transaction,
4450
+ dittoffi_transaction_completion_action_t action,
4451
+ continuation_dittoffi_result_dittoffi_transaction_completion_action_t continuation);
4452
+
4453
+ /** <No documentation available> */
4454
+ typedef struct dittoffi_result_dittoffi_query_result_ptr {
4455
+ /** \brief
4456
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4457
+ */
4458
+ dittoffi_error_t * error;
4459
+
4460
+ /** \brief
4461
+ * When no error occurred, the success value payload can be retrieved here.
4462
+ *
4463
+ * Otherwise, the value is to be ignored.
4464
+ */
4465
+ dittoffi_query_result_t * success;
4466
+ } dittoffi_result_dittoffi_query_result_ptr_t;
4467
+
4468
+ /** \brief
4469
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
4470
+ */
4471
+ typedef struct BoxDynFnMut1_void_dittoffi_result_dittoffi_query_result_ptr {
4472
+ /** <No documentation available> */
4473
+ void * env_ptr;
4474
+
4475
+ /** <No documentation available> */
4476
+ void (*call)(void *, dittoffi_result_dittoffi_query_result_ptr_t);
4477
+
4478
+ /** <No documentation available> */
4479
+ void (*free)(void *);
4480
+ } BoxDynFnMut1_void_dittoffi_result_dittoffi_query_result_ptr_t;
4481
+
4482
+ /** \brief
4483
+ * Continuation (`repr_c::Box<dyn FnMut(…)>` FFI-safe callback) to be used as
4484
+ * the *completion handler* for conceptually-`async` APIs.
4485
+ */
4486
+ typedef BoxDynFnMut1_void_dittoffi_result_dittoffi_query_result_ptr_t continuation_dittoffi_result_dittoffi_query_result_ptr_t;
4487
+
4488
+ /** \brief
4489
+ * Execute a query using the passed in transaction.
4490
+ */
4491
+ void
4492
+ /* fn */ dittoffi_transaction_execute_async_throws (
4493
+ dittoffi_transaction_t const * transaction,
4494
+ char const * query,
4495
+ slice_ref_uint8_t query_args_cbor,
4496
+ continuation_dittoffi_result_dittoffi_query_result_ptr_t continuation);
4497
+
4498
+ /** \brief
4499
+ * Free the passed in transaction.
4500
+ */
4501
+ void
4502
+ /* fn */ dittoffi_transaction_free (
4503
+ dittoffi_transaction_t * _transaction);
4504
+
4505
+ /** \brief
4506
+ * Get info about a given transaction.
4507
+ */
4508
+ dittoffi_cbor_data_t
4509
+ /* fn */ dittoffi_transaction_info (
4510
+ dittoffi_transaction_t const * transaction);
4511
+
4512
+ /** <No documentation available> */
4513
+ void
4514
+ /* fn */ dittoffi_transports_refresh_permissions (
4515
+ CDitto_t const * ditto);
4516
+
4517
+ /** <No documentation available> */
4518
+ void
4519
+ /* fn */ dittoffi_transports_update_app_in_foreground (
4520
+ CDitto_t const * ditto,
4521
+ bool in_foreground);
4522
+
4523
+ /** <No documentation available> */
4524
+ dittoffi_result_void_t
4525
+ /* fn */ dittoffi_try_add_subscription (
4526
+ CDitto_t const * ditto,
4527
+ char const * collection,
4528
+ char const * query,
4529
+ slice_ref_uint8_t query_args_cbor,
4530
+ slice_ref_COrderByParam_t order_by,
4531
+ int32_t limit,
4532
+ uint32_t offset);
4533
+
4534
+ /** \brief
4535
+ * Adds a DQL sync subscription.
4536
+ *
4537
+ * Only `SELECT` statements are supported here.
4538
+ *
4539
+ * Returns no meaningful value but for the resulting potential `.error`.
4540
+ */
4541
+ dittoffi_result_void_t
4542
+ /* fn */ dittoffi_try_add_sync_subscription (
4543
+ CDitto_t const * ditto,
4544
+ char const * query,
4545
+ slice_ref_uint8_t query_args_cbor);
4546
+
4547
+ /** <No documentation available> */
4548
+ typedef struct dittoffi_result_slice_boxed_uint8 {
4549
+ /** \brief
4550
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4551
+ */
4552
+ dittoffi_error_t * error;
4553
+
4554
+ /** \brief
4555
+ * When no error occurred, the success value payload can be retrieved here.
4556
+ *
4557
+ * Otherwise, the value is to be ignored.
4558
+ */
4559
+ slice_boxed_uint8_t success;
4560
+ } dittoffi_result_slice_boxed_uint8_t;
4561
+
4562
+ /** \brief
4563
+ * Decodes a URL-safe base64-encoded string. The caller can specify whether or not they want to
4564
+ * allow padded input. By default, both padded and unpadded input is accepted.
4565
+ *
4566
+ * In the success case, the returned bytes need to be freed by the caller using
4567
+ * `ditto_c_bytes_free`.
4568
+ *
4569
+ * Throws `FfiError::Base64Invalid` if:
4570
+ * - the input string is not a valid base64-encoded string, or
4571
+ * - the desired padding mode is specified as `Unpadded` and the input string is padded.
4572
+ */
4573
+ dittoffi_result_slice_boxed_uint8_t
4574
+ /* fn */ dittoffi_try_base64_decode (
4575
+ char const * str,
4576
+ Base64PaddingMode_t padding_mode);
4577
+
4578
+ /** <No documentation available> */
4579
+ dittoffi_result_void_t
4580
+ /* fn */ dittoffi_try_collection (
4581
+ CDitto_t const * ditto,
4582
+ char const * name);
4583
+
4584
+ /** <No documentation available> */
4585
+ typedef struct dittoffi_result_bool {
4586
+ /** \brief
4587
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4588
+ */
4589
+ dittoffi_error_t * error;
4590
+
4591
+ /** \brief
4592
+ * When no error occurred, the success value payload can be retrieved here.
4593
+ *
4594
+ * Otherwise, the value is to be ignored.
4595
+ */
4596
+ bool success;
4597
+ } dittoffi_result_bool_t;
4598
+
4599
+ /** <No documentation available> */
4600
+ dittoffi_result_bool_t
4601
+ /* fn */ dittoffi_try_collection_evict (
4602
+ CDitto_t const * ditto,
4603
+ char const * coll_name,
4604
+ CWriteTransaction_t * transaction,
4605
+ slice_ref_uint8_t id);
4606
+
4607
+ /** <No documentation available> */
4608
+ typedef struct dittoffi_result_Vec_slice_boxed_uint8 {
4609
+ /** \brief
4610
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4611
+ */
4612
+ dittoffi_error_t * error;
4613
+
4614
+ /** \brief
4615
+ * When no error occurred, the success value payload can be retrieved here.
4616
+ *
4617
+ * Otherwise, the value is to be ignored.
4618
+ */
4619
+ Vec_slice_boxed_uint8_t success;
4620
+ } dittoffi_result_Vec_slice_boxed_uint8_t;
4621
+
4622
+ /** <No documentation available> */
4623
+ dittoffi_result_Vec_slice_boxed_uint8_t
4624
+ /* fn */ dittoffi_try_collection_evict_by_ids (
4625
+ CDitto_t const * ditto,
4626
+ char const * coll_name,
4627
+ CWriteTransaction_t * transaction,
4628
+ slice_ref_slice_boxed_uint8_t ids);
4629
+
4630
+ /** <No documentation available> */
4631
+ dittoffi_result_Vec_slice_boxed_uint8_t
4632
+ /* fn */ dittoffi_try_collection_evict_query_str (
4633
+ CDitto_t const * ditto,
4634
+ char const * coll_name,
4635
+ CWriteTransaction_t * transaction,
4636
+ char const * query,
4637
+ slice_ref_uint8_t query_args_cbor,
4638
+ slice_ref_COrderByParam_t order_by_params,
4639
+ int32_t limit,
4640
+ uint32_t offset);
4641
+
4642
+ /** <No documentation available> */
4643
+ typedef struct docs_and_ids {
4644
+ /** <No documentation available> */
4645
+ Vec_CDocument_ptr_t documents;
4646
+
4647
+ /** <No documentation available> */
4648
+ Vec_slice_boxed_uint8_t ids;
4649
+ } docs_and_ids_t;
4650
+
4651
+ /** <No documentation available> */
4652
+ typedef struct dittoffi_result_docs_and_ids {
4653
+ /** \brief
4654
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4655
+ */
4656
+ dittoffi_error_t * error;
4657
+
4658
+ /** \brief
4659
+ * When no error occurred, the success value payload can be retrieved here.
4660
+ *
4661
+ * Otherwise, the value is to be ignored.
4662
+ */
4663
+ docs_and_ids_t success;
4664
+ } dittoffi_result_docs_and_ids_t;
4665
+
4666
+ /** <No documentation available> */
4667
+ dittoffi_result_docs_and_ids_t
4668
+ /* fn */ dittoffi_try_collection_find_by_ids (
4669
+ CDitto_t const * ditto,
4670
+ char const * coll_name,
4671
+ slice_ref_slice_boxed_uint8_t ids,
4672
+ CReadTransaction_t * transaction);
4673
+
4674
+ /** <No documentation available> */
4675
+ typedef struct dittoffi_result_CDocument_ptr {
4676
+ /** \brief
4677
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4678
+ */
4679
+ dittoffi_error_t * error;
4680
+
4681
+ /** \brief
4682
+ * When no error occurred, the success value payload can be retrieved here.
4683
+ *
4684
+ * Otherwise, the value is to be ignored.
4685
+ */
4686
+ CDocument_t * success;
4687
+ } dittoffi_result_CDocument_ptr_t;
4688
+
4689
+ /** \brief
4690
+ * [js only] Returns `-1` in case of outstanding non-`awaited` transaction operation.
4691
+ */
4692
+ dittoffi_result_CDocument_ptr_t
4693
+ /* fn */ dittoffi_try_collection_get (
4694
+ CDitto_t const * _ditto,
4695
+ char const * coll_name,
4696
+ slice_ref_uint8_t id,
4697
+ CReadTransaction_t * transaction);
4698
+
4699
+ /** <No documentation available> */
4700
+ dittoffi_result_slice_boxed_uint8_t
4701
+ /* fn */ dittoffi_try_collection_insert_value (
4702
+ CDitto_t const * ditto,
4703
+ char const * coll_name,
4704
+ slice_ref_uint8_t doc_cbor,
4705
+ WriteStrategyRs_t write_strategy,
4706
+ char const * log_hint,
4707
+ CWriteTransaction_t * txn);
4708
+
4709
+ /** <No documentation available> */
4710
+ dittoffi_result_bool_t
4711
+ /* fn */ dittoffi_try_collection_remove (
4712
+ CDitto_t const * _ditto,
4713
+ char const * coll_name,
4714
+ CWriteTransaction_t * transaction,
4715
+ slice_ref_uint8_t id);
4716
+
4717
+ /** <No documentation available> */
4718
+ dittoffi_result_Vec_slice_boxed_uint8_t
4719
+ /* fn */ dittoffi_try_collection_remove_by_ids (
4720
+ CDitto_t const * ditto,
4721
+ char const * coll_name,
4722
+ CWriteTransaction_t * transaction,
4723
+ slice_ref_slice_boxed_uint8_t ids);
4724
+
4725
+ /** <No documentation available> */
4726
+ dittoffi_result_Vec_slice_boxed_uint8_t
4727
+ /* fn */ dittoffi_try_collection_remove_query_str (
4728
+ CDitto_t const * ditto,
4729
+ char const * coll_name,
4730
+ CWriteTransaction_t * transaction,
4731
+ char const * query,
4732
+ slice_ref_uint8_t query_args_cbor,
4733
+ slice_ref_COrderByParam_t order_by_params,
4734
+ int32_t limit,
4735
+ uint32_t offset);
4736
+
4737
+ /** <No documentation available> */
4738
+ dittoffi_result_void_t
4739
+ /* fn */ dittoffi_try_collection_update (
4740
+ CDitto_t const * _ditto,
4741
+ char const * coll_name,
4742
+ CWriteTransaction_t * transaction,
4743
+ CDocument_t * document);
4744
+
4745
+ /** <No documentation available> */
4746
+ dittoffi_result_void_t
4747
+ /* fn */ dittoffi_try_collection_update_multiple (
4748
+ CDitto_t const * _ditto,
4749
+ char const * coll_name,
4750
+ CWriteTransaction_t * transaction,
4751
+ Vec_CDocument_ptr_t documents);
4752
+
4753
+ /** <No documentation available> */
4754
+ dittoffi_result_slice_boxed_uint8_t
4755
+ /* fn */ dittoffi_try_document_get_cbor_with_path_type (
4756
+ CDocument_t const * document,
4757
+ char const * pointer,
4758
+ PathAccessorType_t path_type);
4759
+
4760
+ /** \brief
4761
+ * Execute specified DQL statement.
4762
+ *
4763
+ * Returns a [`QueryResult`], which contains a vector of [`QueryResultItem`]s.
4764
+ *
4765
+ * This is replacement for the old FFI, which was returning documents, but still uses the "old"
4766
+ * style of FFI transaction API.
4767
+ *
4768
+ * [`QueryResultItem`]: crate::store::dql::response::QueryResultItem
4769
+ */
4770
+ dittoffi_result_dittoffi_query_result_ptr_t
4771
+ /* fn */ dittoffi_try_exec_statement (
4772
+ CDitto_t const * ditto,
4773
+ char const * statement,
4774
+ slice_ref_uint8_t args_cbor);
4775
+
4776
+ /** <No documentation available> */
4777
+ typedef struct ChangeHandlerWithQueryResult {
4778
+ /** \brief
4779
+ * Must be freed with `dittoffi_query_result_free`.
4780
+ */
4781
+ dittoffi_query_result_t * query_result;
4782
+ } ChangeHandlerWithQueryResult_t;
4783
+
4784
+ /** <No documentation available> */
4785
+ typedef struct dittoffi_result_int64 {
4786
+ /** \brief
4787
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4788
+ */
4789
+ dittoffi_error_t * error;
4790
+
4791
+ /** \brief
4792
+ * When no error occurred, the success value payload can be retrieved here.
4793
+ *
4794
+ * Otherwise, the value is to be ignored.
4795
+ */
4796
+ int64_t success;
4797
+ } dittoffi_result_int64_t;
4798
+
4799
+ /** <No documentation available> */
4800
+ dittoffi_result_int64_t
4801
+ /* fn */ dittoffi_try_experimental_register_change_observer_str (
4802
+ CDitto_t const * ditto,
4803
+ char const * query,
4804
+ slice_ref_uint8_t query_args_cbor,
4805
+ LiveQueryAvailability_t lq_availability,
4806
+ void * ctx,
4807
+ void (*retain)(void *),
4808
+ void (*release)(void *),
4809
+ void (*c_cb)(void *, ChangeHandlerWithQueryResult_t));
4810
+
4811
+ /** <No documentation available> */
4812
+ typedef struct dittoffi_result_Vec_char_ptr {
4813
+ /** \brief
4814
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4815
+ */
4816
+ dittoffi_error_t * error;
4817
+
4818
+ /** \brief
4819
+ * When no error occurred, the success value payload can be retrieved here.
4820
+ *
4821
+ * Otherwise, the value is to be ignored.
4822
+ */
4823
+ Vec_char_ptr_t success;
4824
+ } dittoffi_result_Vec_char_ptr_t;
4825
+
4826
+ /** <No documentation available> */
4827
+ dittoffi_result_Vec_char_ptr_t
4828
+ /* fn */ dittoffi_try_get_collection_names (
4829
+ CDitto_t const * ditto);
4830
+
4831
+ /** <No documentation available> */
4832
+ dittoffi_result_void_t
4833
+ /* fn */ dittoffi_try_live_query_start (
4834
+ CDitto_t const * ditto,
4835
+ int64_t id);
4836
+
4837
+ /** <No documentation available> */
4838
+ dittoffi_result_uint64_t
4839
+ /* fn */ dittoffi_try_queries_hash (
4840
+ CDitto_t const * ditto,
4841
+ slice_ref_char_const_ptr_t coll_names,
4842
+ slice_ref_char_const_ptr_t queries);
4843
+
4844
+ /** <No documentation available> */
4845
+ typedef struct dittoffi_result_char_ptr {
4846
+ /** \brief
4847
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4848
+ */
4849
+ dittoffi_error_t * error;
4850
+
4851
+ /** \brief
4852
+ * When no error occurred, the success value payload can be retrieved here.
4853
+ *
4854
+ * Otherwise, the value is to be ignored.
4855
+ */
4856
+ char * success;
4857
+ } dittoffi_result_char_ptr_t;
4858
+
4859
+ /** <No documentation available> */
4860
+ dittoffi_result_char_ptr_t
4861
+ /* fn */ dittoffi_try_queries_hash_mnemonic (
4862
+ CDitto_t const * ditto,
4863
+ slice_ref_char_const_ptr_t coll_names,
4864
+ slice_ref_char_const_ptr_t queries);
4865
+
4866
+ /** <No documentation available> */
4867
+ dittoffi_result_int64_t
4868
+ /* fn */ dittoffi_try_register_store_observer (
4869
+ CDitto_t const * ditto,
4870
+ char const * coll_name,
4871
+ char const * query,
4872
+ slice_ref_uint8_t query_args_cbor,
4873
+ slice_ref_COrderByParam_t order_by,
4874
+ int32_t limit,
4875
+ uint32_t offset,
4876
+ LiveQueryAvailability_t lq_availability,
4877
+ void * ctx,
4878
+ void (*retain)(void *),
4879
+ void (*release)(void *),
4880
+ void (*c_cb)(void *, c_cb_params_t));
4881
+
4882
+ /** <No documentation available> */
4883
+ dittoffi_result_void_t
4884
+ /* fn */ dittoffi_try_remove_subscription (
4885
+ CDitto_t const * ditto,
4886
+ char const * collection,
4887
+ char const * query,
4888
+ slice_ref_uint8_t query_args_cbor,
4889
+ slice_ref_COrderByParam_t order_by,
4890
+ int32_t limit,
4891
+ uint32_t offset);
4892
+
4893
+ /** \brief
4894
+ * Removes a DQL sync subscription.
4895
+ *
4896
+ * The arguments should be identical to the ones used during adding the subscription.
4897
+ * Returns no meaningful value but for the resulting potential `.error`.
4898
+ */
4899
+ dittoffi_result_void_t
4900
+ /* fn */ dittoffi_try_remove_sync_subscription (
4901
+ CDitto_t const * ditto,
4902
+ char const * query,
4903
+ slice_ref_uint8_t query_args_cbor);
4904
+
4905
+ /** \brief
4906
+ * Verify a base64 encoded license string.
4907
+ *
4908
+ * # Parameters
4909
+ * - `ditto`: The Ditto instance to activate.
4910
+ * - `license`: A base64 encoded license string. This should be the output of
4911
+ * `ditto_licenser::license_mgr::generate()`.
4912
+ */
4913
+ dittoffi_result_void_t
4914
+ /* fn */ dittoffi_try_verify_license (
4915
+ CDitto_t const * ditto,
4916
+ char const * license);
4917
+
4918
+ /** \brief
4919
+ * The platform advises Rust that the status of publishing our service has
4920
+ * changed.
4921
+ */
4922
+ void
4923
+ /* fn */ mdns_advertising_state_changed (
4924
+ TransportHandle_MdnsServerPlatformEvent_t const * handle,
4925
+ OnlineState_t state,
4926
+ TransportCondition_t condition);
4927
+
4928
+ /** \brief
4929
+ * The SDK requests to drop its handle to the mDNS discovery transport
4930
+ *
4931
+ * At some point dropping this events channel will effectively shut down and
4932
+ * remove the Transport. At time of writing, the Transport is still owned
4933
+ * within Peer.
4934
+ */
4935
+ void
4936
+ /* fn */ mdns_client_free_handle (
4937
+ TransportHandle_MdnsClientPlatformEvent_t * handle);
4938
+
4939
+ /** \brief
4940
+ * The platform advises Rust that a peer has been identified.
4941
+ */
4942
+ void
4943
+ /* fn */ mdns_platform_peer_appeared (
4944
+ TransportHandle_MdnsClientPlatformEvent_t const * handle,
4945
+ char const * announce_string);
4946
+
4947
+ /** \brief
4948
+ * The platform advises Rust that a peer's service has disappeared from mDNS.
4949
+ */
4950
+ void
4951
+ /* fn */ mdns_platform_peer_disappeared (
4952
+ TransportHandle_MdnsClientPlatformEvent_t const * handle,
4953
+ char const * announce_string);
4954
+
4955
+ /** \brief
4956
+ * The platform advises Rust that the status of searching for services has
4957
+ * changed.
4958
+ */
4959
+ void
4960
+ /* fn */ mdns_scanning_state_changed (
4961
+ TransportHandle_MdnsClientPlatformEvent_t const * handle,
4962
+ OnlineState_t state,
4963
+ TransportCondition_t condition);
4964
+
4965
+ /** \brief
4966
+ * The SDK requests to drop its handle to the mDNS advertising service.
4967
+ *
4968
+ * Ideally this should remove the advertiser automatically.
4969
+ * At time of writing now this must be done manually through Peer.
4970
+ */
4971
+ void
4972
+ /* fn */ mdns_server_free_handle (
4973
+ TransportHandle_MdnsServerPlatformEvent_t * handle);
4974
+
4975
+ /** \brief
4976
+ * The platform advises Rust that the TCP listener will need to be restarted.
4977
+ */
4978
+ void
4979
+ /* fn */ mdns_server_invalidate_listener (
4980
+ TransportHandle_MdnsServerPlatformEvent_t const * handle);
4981
+
4982
+ /** \brief
4983
+ * The platform advises Rust that we failed to resolve a peer's hostname and
4984
+ * port
4985
+ */
4986
+ void
4987
+ /* fn */ mdns_service_did_not_resolve (
4988
+ TransportHandle_MdnsClientPlatformEvent_t const * handle,
4989
+ char const * announce_string);
4990
+
4991
+ /** \brief
4992
+ * The platform advises Rust that we have resolved a peer's hostname and port
4993
+ */
4994
+ void
4995
+ /* fn */ mdns_service_did_resolve (
4996
+ TransportHandle_MdnsClientPlatformEvent_t const * handle,
4997
+ char const * announce_string,
4998
+ char const * hostname,
4999
+ uint16_t port);
5000
+
5001
+
5002
+ #ifdef __cplusplus
5003
+ } /* extern \"C\" */
5004
+ #endif
5005
+
5006
+ #endif /* __RUST_DITTOFFI__ */