@dittolive/ditto 4.8.2 → 4.9.0-alpha.1

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