@dittolive/ditto 4.10.2 → 4.11.0-preview.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 (44) hide show
  1. package/DittoReactNative.podspec +1 -17
  2. package/README.md +4 -80
  3. package/node/ditto.cjs.js +444 -81
  4. package/node/ditto.darwin-arm64.node +0 -0
  5. package/node/ditto.darwin-x64.node +0 -0
  6. package/node/ditto.linux-arm64.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/package.json +1 -1
  10. package/react-native/android/build.gradle +29 -34
  11. package/react-native/android/cpp-adapter.cpp +10 -11
  12. package/react-native/android/dittoffi/src/ditto_transaction.cpp +1 -0
  13. package/react-native/android/dittoffi/src/ditto_transaction.h +91 -0
  14. package/react-native/android/dittoffi/src/dittoffi.h +587 -390
  15. package/react-native/android/dittoffi/src/dittoffi_java.cpp +3360 -1358
  16. package/react-native/android/dittoffi/src/dittoffi_java.h +59 -10
  17. package/react-native/android/dittoffi/src/dittoffi_java.i +2 -0
  18. package/react-native/android/dittoffi/src/dittostore_java.i +48 -0
  19. package/react-native/android/dittoffi/src/mesh_java_interfaces.h +81 -109
  20. package/react-native/android/gradle.properties +6 -5
  21. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.kt +23 -15
  22. package/react-native/cpp/include/DQL.h +1 -0
  23. package/react-native/cpp/include/Differ.h +14 -0
  24. package/react-native/cpp/include/Lifecycle.h +1 -1
  25. package/react-native/cpp/include/Transaction.h +18 -0
  26. package/react-native/cpp/include/Transports.h +1 -0
  27. package/react-native/cpp/include/Utils.h +27 -3
  28. package/react-native/cpp/include/main.h +2 -0
  29. package/react-native/cpp/src/DQL.cpp +21 -0
  30. package/react-native/cpp/src/Differ.cpp +57 -0
  31. package/react-native/cpp/src/Lifecycle.cpp +17 -7
  32. package/react-native/cpp/src/Misc.cpp +50 -32
  33. package/react-native/cpp/src/Transaction.cpp +195 -0
  34. package/react-native/cpp/src/Transports.cpp +77 -1
  35. package/react-native/cpp/src/Utils.cpp +11 -0
  36. package/react-native/cpp/src/main.cpp +18 -1
  37. package/react-native/ditto.es6.js +1 -1
  38. package/react-native/ios/DittoRNSDK.mm +2 -4
  39. package/types/ditto.d.ts +271 -33
  40. package/web/ditto.es6.js +1 -1
  41. package/web/ditto.umd.js +1 -1
  42. package/web/ditto.wasm +0 -0
  43. package/react-native/ios/YeetJSIUtils.h +0 -60
  44. package/react-native/ios/YeetJSIUtils.mm +0 -196
@@ -175,7 +175,7 @@ void
175
175
  *
176
176
  * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
177
177
  */
178
- typedef struct TransportHandle_AwdlClientPlatformEvent TransportHandle_AwdlClientPlatformEvent_t;
178
+ typedef struct TransportHandle_AwdlPlatformEvent TransportHandle_AwdlPlatformEvent_t;
179
179
 
180
180
  /** \brief
181
181
  * Generic enum used by crate and platforms to indicate a connection status
@@ -197,7 +197,7 @@ typedef enum ConnectState {
197
197
  */
198
198
  void
199
199
  /* fn */ awdl_client_connect_state_changed (
200
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
200
+ TransportHandle_AwdlPlatformEvent_t const * handle,
201
201
  char const * announce,
202
202
  ConnectState_t state);
203
203
 
@@ -207,27 +207,16 @@ void
207
207
  */
208
208
  void
209
209
  /* fn */ awdl_client_data_available (
210
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
210
+ TransportHandle_AwdlPlatformEvent_t const * handle,
211
211
  char const * announce);
212
212
 
213
- /** \brief
214
- * The SDK requests to drop its handle to the AWDL Client Transport
215
- *
216
- * At some point dropping this events channel will effectively shut down and
217
- * remove the Transport. At time of writing, the Transport is still owned
218
- * within Peer.
219
- */
220
- void
221
- /* fn */ awdl_client_free_handle (
222
- TransportHandle_AwdlClientPlatformEvent_t * handle);
223
-
224
213
  /** \brief
225
214
  * The platform advises Rust that a peer has been identified. We know only its
226
215
  * announce string.
227
216
  */
228
217
  void
229
218
  /* fn */ awdl_client_platform_peer_appeared (
230
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
219
+ TransportHandle_AwdlPlatformEvent_t const * handle,
231
220
  char const * announce);
232
221
 
233
222
  /** \brief
@@ -235,7 +224,7 @@ void
235
224
  */
236
225
  void
237
226
  /* fn */ awdl_client_platform_peer_disappeared (
238
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
227
+ TransportHandle_AwdlPlatformEvent_t const * handle,
239
228
  char const * announce);
240
229
 
241
230
  /** \brief
@@ -244,7 +233,7 @@ void
244
233
  */
245
234
  void
246
235
  /* fn */ awdl_client_ready_to_send (
247
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
236
+ TransportHandle_AwdlPlatformEvent_t const * handle,
248
237
  char const * announce);
249
238
 
250
239
  /** \brief
@@ -334,43 +323,16 @@ typedef enum TransportCondition {
334
323
  */
335
324
  void
336
325
  /* fn */ awdl_client_scanning_state_changed (
337
- TransportHandle_AwdlClientPlatformEvent_t const * handle,
326
+ TransportHandle_AwdlPlatformEvent_t const * handle,
338
327
  OnlineState_t state,
339
328
  TransportCondition_t condition);
340
329
 
341
- /** \brief
342
- * An opaque handle for each installed transport, heap-allocated and owned by
343
- * the SDK.
344
- *
345
- * A pointer to this handle is used to send platform events over FFI. In the
346
- * future this handle will be the SDK's only point of control over the
347
- * transport once created. In particular, a transport will be removed by
348
- * freeing the handle. The concept of online and offline will be eliminated.
349
- * (i.e., if you don't want a transport, remove it.)
350
- *
351
- * For now, the `Peer` object holds the transports and provides an API based on
352
- * a numeric id assigned to each transport instance. Until that is removed, the
353
- * id still exists and the SDK can request it from the opaque handle over FFI.
354
- *
355
- * For each transport type, define an `extern "C"` function to free that
356
- * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
357
- * plus a function to retrieve the transport id, which will be removed later.
358
- *
359
- * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
360
- * that it does not use the pointer to the `TransportHandle` after freeing it
361
- * with its respective function. In Rust we will assume it is okay to unsafely
362
- * dereference a handle.
363
- *
364
- * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
365
- */
366
- typedef struct TransportHandle_AwdlServerPlatformEvent TransportHandle_AwdlServerPlatformEvent_t;
367
-
368
330
  /** \brief
369
331
  * The platform advises Rust that advertising status changed
370
332
  */
371
333
  void
372
334
  /* fn */ awdl_server_advertising_state_changed (
373
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
335
+ TransportHandle_AwdlPlatformEvent_t const * handle,
374
336
  OnlineState_t state,
375
337
  TransportCondition_t condition);
376
338
 
@@ -380,7 +342,7 @@ void
380
342
  */
381
343
  void
382
344
  /* fn */ awdl_server_connect_state_changed (
383
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
345
+ TransportHandle_AwdlPlatformEvent_t const * handle,
384
346
  int64_t platform_id,
385
347
  ConnectState_t state);
386
348
 
@@ -390,27 +352,16 @@ void
390
352
  */
391
353
  void
392
354
  /* fn */ awdl_server_data_available (
393
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
355
+ TransportHandle_AwdlPlatformEvent_t const * handle,
394
356
  int64_t platform_id);
395
357
 
396
- /** \brief
397
- * The SDK requests to drop its handle to the AWDL Server Transport
398
- *
399
- * At some point dropping this events channel will effectively shut down and
400
- * remove the Transport. At time of writing, the Transport is still owned
401
- * within Peer.
402
- */
403
- void
404
- /* fn */ awdl_server_free_handle (
405
- TransportHandle_AwdlServerPlatformEvent_t * handle);
406
-
407
358
  /** \brief
408
359
  * The platform advises Rust that a peer has been identified. We know only its
409
360
  * announce string.
410
361
  */
411
362
  void
412
363
  /* fn */ awdl_server_platform_peer_appeared (
413
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
364
+ TransportHandle_AwdlPlatformEvent_t const * handle,
414
365
  int64_t platform_id);
415
366
 
416
367
  /** \brief
@@ -418,7 +369,7 @@ void
418
369
  */
419
370
  void
420
371
  /* fn */ awdl_server_platform_peer_disappeared (
421
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
372
+ TransportHandle_AwdlPlatformEvent_t const * handle,
422
373
  int64_t platform_id);
423
374
 
424
375
  /** \brief
@@ -427,7 +378,7 @@ void
427
378
  */
428
379
  void
429
380
  /* fn */ awdl_server_ready_to_send (
430
- TransportHandle_AwdlServerPlatformEvent_t const * handle,
381
+ TransportHandle_AwdlPlatformEvent_t const * handle,
431
382
  int64_t platform_id);
432
383
 
433
384
  /** \brief
@@ -455,12 +406,12 @@ void
455
406
  *
456
407
  * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
457
408
  */
458
- typedef struct TransportHandle_BleServerPlatformEvent TransportHandle_BleServerPlatformEvent_t;
409
+ typedef struct TransportHandle_BlePlatformEvent TransportHandle_BlePlatformEvent_t;
459
410
 
460
411
  /** <No documentation available> */
461
412
  void
462
413
  /* fn */ ble_advertising_state_changed (
463
- TransportHandle_BleServerPlatformEvent_t const * handle,
414
+ TransportHandle_BlePlatformEvent_t const * handle,
464
415
  OnlineState_t state,
465
416
  TransportCondition_t result);
466
417
 
@@ -471,7 +422,7 @@ typedef struct {
471
422
  /** <No documentation available> */
472
423
  void
473
424
  /* fn */ ble_central_finished_connecting (
474
- TransportHandle_BleServerPlatformEvent_t const * handle,
425
+ TransportHandle_BlePlatformEvent_t const * handle,
475
426
  uint8_16_array_t const * uuid,
476
427
  slice_ref_uint8_t announce,
477
428
  int32_t l2cap_available,
@@ -480,76 +431,38 @@ void
480
431
  /** <No documentation available> */
481
432
  void
482
433
  /* fn */ ble_central_l2cap_data_available (
483
- TransportHandle_BleServerPlatformEvent_t const * handle,
434
+ TransportHandle_BlePlatformEvent_t const * handle,
484
435
  uint8_16_array_t const * uuid);
485
436
 
486
437
  /** <No documentation available> */
487
438
  void
488
439
  /* fn */ ble_central_l2cap_ready_to_send (
489
- TransportHandle_BleServerPlatformEvent_t const * handle,
440
+ TransportHandle_BlePlatformEvent_t const * handle,
490
441
  uint8_16_array_t const * uuid);
491
442
 
492
443
  /** <No documentation available> */
493
444
  void
494
445
  /* fn */ ble_central_mtu_updated (
495
- TransportHandle_BleServerPlatformEvent_t const * handle,
446
+ TransportHandle_BlePlatformEvent_t const * handle,
496
447
  uint8_16_array_t const * uuid,
497
448
  uint32_t mtu);
498
449
 
499
450
  /** <No documentation available> */
500
451
  void
501
452
  /* fn */ ble_central_ready_to_send (
502
- TransportHandle_BleServerPlatformEvent_t const * handle,
453
+ TransportHandle_BlePlatformEvent_t const * handle,
503
454
  uint8_16_array_t const * uuid);
504
455
 
505
456
  /** <No documentation available> */
506
457
  void
507
458
  /* fn */ ble_central_unsubscribed (
508
- TransportHandle_BleServerPlatformEvent_t const * handle,
459
+ TransportHandle_BlePlatformEvent_t const * handle,
509
460
  uint8_16_array_t const * central_uuid);
510
461
 
511
- /** \brief
512
- * An opaque handle for each installed transport, heap-allocated and owned by
513
- * the SDK.
514
- *
515
- * A pointer to this handle is used to send platform events over FFI. In the
516
- * future this handle will be the SDK's only point of control over the
517
- * transport once created. In particular, a transport will be removed by
518
- * freeing the handle. The concept of online and offline will be eliminated.
519
- * (i.e., if you don't want a transport, remove it.)
520
- *
521
- * For now, the `Peer` object holds the transports and provides an API based on
522
- * a numeric id assigned to each transport instance. Until that is removed, the
523
- * id still exists and the SDK can request it from the opaque handle over FFI.
524
- *
525
- * For each transport type, define an `extern "C"` function to free that
526
- * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
527
- * plus a function to retrieve the transport id, which will be removed later.
528
- *
529
- * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
530
- * that it does not use the pointer to the `TransportHandle` after freeing it
531
- * with its respective function. In Rust we will assume it is okay to unsafely
532
- * dereference a handle.
533
- *
534
- * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
535
- */
536
- typedef struct TransportHandle_BleClientPlatformEvent TransportHandle_BleClientPlatformEvent_t;
537
-
538
- /** \brief
539
- * The SDK requests to drop its handle to the BLE Client Transport
540
- *
541
- * At some point dropping this events channel will effectively shut down and
542
- * remove the Transport. At time of writing, the Transport is still owned
543
- * within Peer.
544
- */
545
- void
546
- /* fn */ ble_client_free_handle (
547
- TransportHandle_BleClientPlatformEvent_t * handle);
548
-
549
462
  /** <No documentation available> */
550
463
  void
551
464
  /* fn */ ble_connection_state_changed (
552
- TransportHandle_BleClientPlatformEvent_t const * handle,
465
+ TransportHandle_BlePlatformEvent_t const * handle,
553
466
  uint8_16_array_t const * peripheral_uuid,
554
467
  ConnectState_t state,
555
468
  int32_t l2cap_available,
@@ -558,26 +471,26 @@ void
558
471
  /** <No documentation available> */
559
472
  void
560
473
  /* fn */ ble_peripheral_l2cap_data_available (
561
- TransportHandle_BleClientPlatformEvent_t const * handle,
474
+ TransportHandle_BlePlatformEvent_t const * handle,
562
475
  uint8_16_array_t const * uuid);
563
476
 
564
477
  /** <No documentation available> */
565
478
  void
566
479
  /* fn */ ble_peripheral_l2cap_ready_to_send (
567
- TransportHandle_BleClientPlatformEvent_t const * handle,
480
+ TransportHandle_BlePlatformEvent_t const * handle,
568
481
  uint8_16_array_t const * uuid);
569
482
 
570
483
  /** <No documentation available> */
571
484
  void
572
485
  /* fn */ ble_peripheral_mtu_updated (
573
- TransportHandle_BleClientPlatformEvent_t const * handle,
486
+ TransportHandle_BlePlatformEvent_t const * handle,
574
487
  uint8_16_array_t const * uuid,
575
488
  uint32_t mtu);
576
489
 
577
490
  /** <No documentation available> */
578
491
  void
579
492
  /* fn */ ble_peripheral_ready_to_send (
580
- TransportHandle_BleClientPlatformEvent_t const * handle,
493
+ TransportHandle_BlePlatformEvent_t const * handle,
581
494
  uint8_16_array_t const * uuid);
582
495
 
583
496
  /** \brief
@@ -603,7 +516,7 @@ typedef enum BleDataType {
603
516
  /** <No documentation available> */
604
517
  void
605
518
  /* fn */ ble_received_from_central (
606
- TransportHandle_BleServerPlatformEvent_t const * handle,
519
+ TransportHandle_BlePlatformEvent_t const * handle,
607
520
  uint8_16_array_t const * central_uuid,
608
521
  BleDataType_t data_type,
609
522
  slice_ref_uint8_t data);
@@ -611,7 +524,7 @@ void
611
524
  /** <No documentation available> */
612
525
  void
613
526
  /* fn */ ble_received_from_peripheral (
614
- TransportHandle_BleClientPlatformEvent_t const * handle,
527
+ TransportHandle_BlePlatformEvent_t const * handle,
615
528
  uint8_16_array_t const * peripheral_uuid,
616
529
  BleDataType_t data_type,
617
530
  slice_ref_uint8_t data);
@@ -619,21 +532,10 @@ void
619
532
  /** <No documentation available> */
620
533
  void
621
534
  /* fn */ ble_scanning_state_changed (
622
- TransportHandle_BleClientPlatformEvent_t const * handle,
535
+ TransportHandle_BlePlatformEvent_t const * handle,
623
536
  OnlineState_t state,
624
537
  TransportCondition_t result);
625
538
 
626
- /** \brief
627
- * The SDK requests to drop its handle to the BLE Server Transport
628
- *
629
- * At some point dropping this events channel will effectively shut down and
630
- * remove the Transport. At time of writing, the Transport is still owned
631
- * within Peer.
632
- */
633
- void
634
- /* fn */ ble_server_free_handle (
635
- TransportHandle_BleServerPlatformEvent_t * handle);
636
-
637
539
  /** <No documentation available> */
638
540
  typedef struct CDitto CDitto_t;
639
541
 
@@ -689,15 +591,6 @@ typedef struct AwdlClientCallbacks {
689
591
  int32_t (*read_data)(void *, char const *, slice_mut_uint8_t);
690
592
  } AwdlClientCallbacks_t;
691
593
 
692
- /** <No documentation available> */
693
- TransportHandle_AwdlClientPlatformEvent_t *
694
- /* fn */ ditto_add_awdl_client_transport (
695
- CDitto_t const * ditto,
696
- AwdlClientCallbacks_t callbacks,
697
- void * ctx,
698
- void (*retain)(void *),
699
- void (*release)(void *));
700
-
701
594
  /** <No documentation available> */
702
595
  typedef struct AwdlServerCallbacks {
703
596
  /** <No documentation available> */
@@ -717,11 +610,13 @@ typedef struct AwdlServerCallbacks {
717
610
  } AwdlServerCallbacks_t;
718
611
 
719
612
  /** <No documentation available> */
720
- TransportHandle_AwdlServerPlatformEvent_t *
721
- /* fn */ ditto_add_awdl_server_transport (
613
+ TransportHandle_AwdlPlatformEvent_t *
614
+ /* fn */ ditto_add_awdl_transport (
722
615
  CDitto_t const * ditto,
723
- AwdlServerCallbacks_t callbacks,
724
- void * ctx,
616
+ AwdlClientCallbacks_t client_callbacks,
617
+ void * client_ctx,
618
+ AwdlServerCallbacks_t server_callbacks,
619
+ void * server_ctx,
725
620
  void (*retain)(void *),
726
621
  void (*release)(void *));
727
622
 
@@ -767,15 +662,6 @@ typedef struct BleClientCallbacks {
767
662
  int32_t (*send_l2cap_to_peripheral)(void *, uint8_16_array_t const *, slice_ref_uint8_t);
768
663
  } BleClientCallbacks_t;
769
664
 
770
- /** <No documentation available> */
771
- TransportHandle_BleClientPlatformEvent_t *
772
- /* fn */ ditto_add_ble_client_transport (
773
- CDitto_t const * ditto,
774
- BleClientCallbacks_t callbacks,
775
- void * ctx,
776
- void (*retain)(void *),
777
- void (*release)(void *));
778
-
779
665
  /** <No documentation available> */
780
666
  typedef struct BleServerCallbacks {
781
667
  /** <No documentation available> */
@@ -798,11 +684,13 @@ typedef struct BleServerCallbacks {
798
684
  } BleServerCallbacks_t;
799
685
 
800
686
  /** <No documentation available> */
801
- TransportHandle_BleServerPlatformEvent_t *
802
- /* fn */ ditto_add_ble_server_transport (
687
+ TransportHandle_BlePlatformEvent_t *
688
+ /* fn */ ditto_add_ble_transport (
803
689
  CDitto_t const * ditto,
804
- BleServerCallbacks_t callbacks,
805
- void * ctx,
690
+ BleClientCallbacks_t client_callbacks,
691
+ void * client_ctx,
692
+ BleServerCallbacks_t server_callbacks,
693
+ void * server_ctx,
806
694
  void (*retain)(void *),
807
695
  void (*release)(void *));
808
696
 
@@ -818,42 +706,6 @@ typedef struct MdnsClientCallbacks {
818
706
  void (*resolve_service)(void *, slice_ref_uint8_t);
819
707
  } MdnsClientCallbacks_t;
820
708
 
821
- /** \brief
822
- * An opaque handle for each installed transport, heap-allocated and owned by
823
- * the SDK.
824
- *
825
- * A pointer to this handle is used to send platform events over FFI. In the
826
- * future this handle will be the SDK's only point of control over the
827
- * transport once created. In particular, a transport will be removed by
828
- * freeing the handle. The concept of online and offline will be eliminated.
829
- * (i.e., if you don't want a transport, remove it.)
830
- *
831
- * For now, the `Peer` object holds the transports and provides an API based on
832
- * a numeric id assigned to each transport instance. Until that is removed, the
833
- * id still exists and the SDK can request it from the opaque handle over FFI.
834
- *
835
- * For each transport type, define an `extern "C"` function to free that
836
- * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
837
- * plus a function to retrieve the transport id, which will be removed later.
838
- *
839
- * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
840
- * that it does not use the pointer to the `TransportHandle` after freeing it
841
- * with its respective function. In Rust we will assume it is okay to unsafely
842
- * dereference a handle.
843
- *
844
- * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
845
- */
846
- typedef struct TransportHandle_MdnsClientPlatformEvent TransportHandle_MdnsClientPlatformEvent_t;
847
-
848
- /** <No documentation available> */
849
- TransportHandle_MdnsClientPlatformEvent_t *
850
- /* fn */ ditto_add_mdns_client_transport (
851
- CDitto_t const * ditto,
852
- MdnsClientCallbacks_t callbacks,
853
- void * ctx,
854
- void (*retain)(void *),
855
- void (*release)(void *));
856
-
857
709
  /** <No documentation available> */
858
710
  typedef struct MdnsServerCallbacks {
859
711
  /** <No documentation available> */
@@ -888,13 +740,14 @@ typedef struct MdnsServerCallbacks {
888
740
  *
889
741
  * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
890
742
  */
891
- typedef struct TransportHandle_MdnsServerPlatformEvent TransportHandle_MdnsServerPlatformEvent_t;
743
+ typedef struct TransportHandle_MdnsPlatformEvent TransportHandle_MdnsPlatformEvent_t;
892
744
 
893
745
  /** <No documentation available> */
894
- TransportHandle_MdnsServerPlatformEvent_t *
895
- /* fn */ ditto_add_mdns_server_transport (
746
+ TransportHandle_MdnsPlatformEvent_t *
747
+ /* fn */ ditto_add_mdns_discovery (
896
748
  CDitto_t const * ditto,
897
- MdnsServerCallbacks_t callbacks,
749
+ MdnsClientCallbacks_t client_callbacks,
750
+ MdnsServerCallbacks_t server_callbacks,
898
751
  void * ctx,
899
752
  void (*retain)(void *),
900
753
  void (*release)(void *));
@@ -1008,42 +861,6 @@ typedef struct WifiAwareClientCallbacks {
1008
861
  void (*update_peer)(void *, char const *, ConnectState_t);
1009
862
  } WifiAwareClientCallbacks_t;
1010
863
 
1011
- /** \brief
1012
- * An opaque handle for each installed transport, heap-allocated and owned by
1013
- * the SDK.
1014
- *
1015
- * A pointer to this handle is used to send platform events over FFI. In the
1016
- * future this handle will be the SDK's only point of control over the
1017
- * transport once created. In particular, a transport will be removed by
1018
- * freeing the handle. The concept of online and offline will be eliminated.
1019
- * (i.e., if you don't want a transport, remove it.)
1020
- *
1021
- * For now, the `Peer` object holds the transports and provides an API based on
1022
- * a numeric id assigned to each transport instance. Until that is removed, the
1023
- * id still exists and the SDK can request it from the opaque handle over FFI.
1024
- *
1025
- * For each transport type, define an `extern "C"` function to free that
1026
- * specific monomorphisation of the `TransportHandle` using `Box::from_raw`,
1027
- * plus a function to retrieve the transport id, which will be removed later.
1028
- *
1029
- * Safety: The SDK owns the `TransportHandle`. It is responsible for ensuring
1030
- * that it does not use the pointer to the `TransportHandle` after freeing it
1031
- * with its respective function. In Rust we will assume it is okay to unsafely
1032
- * dereference a handle.
1033
- *
1034
- * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
1035
- */
1036
- typedef struct TransportHandle_WifiAwareClientPlatformEvent TransportHandle_WifiAwareClientPlatformEvent_t;
1037
-
1038
- /** <No documentation available> */
1039
- TransportHandle_WifiAwareClientPlatformEvent_t *
1040
- /* fn */ ditto_add_wifi_aware_client_transport (
1041
- CDitto_t const * ditto,
1042
- WifiAwareClientCallbacks_t callbacks,
1043
- void * ctx,
1044
- void (*retain)(void *),
1045
- void (*release)(void *));
1046
-
1047
864
  /** <No documentation available> */
1048
865
  typedef enum dittoffi_wifi_aware_system_parameter_u64 {
1049
866
  /** <No documentation available> */
@@ -1094,13 +911,14 @@ typedef struct WifiAwareServerCallbacks {
1094
911
  *
1095
912
  * The C interface of `TransportHandle` is thread-safe (`Send + Sync`).
1096
913
  */
1097
- typedef struct TransportHandle_WifiAwareServerPlatformEvent TransportHandle_WifiAwareServerPlatformEvent_t;
914
+ typedef struct TransportHandle_WifiAwarePlatformEvent TransportHandle_WifiAwarePlatformEvent_t;
1098
915
 
1099
916
  /** <No documentation available> */
1100
- TransportHandle_WifiAwareServerPlatformEvent_t *
1101
- /* fn */ ditto_add_wifi_aware_server_advertiser (
917
+ TransportHandle_WifiAwarePlatformEvent_t *
918
+ /* fn */ ditto_add_wifi_aware_transport (
1102
919
  CDitto_t const * ditto,
1103
- WifiAwareServerCallbacks_t callbacks,
920
+ WifiAwareClientCallbacks_t client_callbacks,
921
+ WifiAwareServerCallbacks_t server_callbacks,
1104
922
  void * ctx,
1105
923
  void (*retain)(void *),
1106
924
  void (*release)(void *));
@@ -1192,6 +1010,28 @@ void
1192
1010
  CDitto_t const * ditto,
1193
1011
  CLoginProvider_t * login_provider);
1194
1012
 
1013
+ /** \brief
1014
+ * The SDK requests to drop its handle to the AWDL Transport
1015
+ *
1016
+ * At some point dropping this events channel will effectively shut down and
1017
+ * remove the Transport. At time of writing, the Transport is still owned
1018
+ * within Peer.
1019
+ */
1020
+ void
1021
+ /* fn */ ditto_awdl_transport_free_handle (
1022
+ TransportHandle_AwdlPlatformEvent_t * handle);
1023
+
1024
+ /** \brief
1025
+ * The SDK requests to drop its handle to the BLE Transport
1026
+ *
1027
+ * At some point dropping this events channel will effectively shut down and
1028
+ * remove the Transport. At time of writing, the Transport is still owned
1029
+ * within Peer.
1030
+ */
1031
+ void
1032
+ /* fn */ ditto_ble_transport_free_handle (
1033
+ TransportHandle_BlePlatformEvent_t * handle);
1034
+
1195
1035
  /** \brief
1196
1036
  * [`Box`][`rust::Box`]`<[T]>` (fat pointer to a slice),
1197
1037
  * but with a guaranteed `#[repr(C)]` layout.
@@ -2492,24 +2332,13 @@ void
2492
2332
  int32_t
2493
2333
  /* fn */ ditto_live_query_start (
2494
2334
  CDitto_t const * ditto,
2495
- int64_t id);
2335
+ int64_t legacy_id);
2496
2336
 
2497
2337
  /** <No documentation available> */
2498
2338
  void
2499
2339
  /* fn */ ditto_live_query_stop (
2500
2340
  CDitto_t const * ditto,
2501
- int64_t id);
2502
-
2503
- /** <No documentation available> */
2504
- DocIdResult_t
2505
- /* fn */ ditto_live_query_webhook_register_str (
2506
- CDitto_t const * ditto,
2507
- char const * coll_name,
2508
- char const * query,
2509
- slice_ref_COrderByParam_t order_by,
2510
- int32_t limit,
2511
- uint32_t offset,
2512
- char const * url);
2341
+ int64_t legacy_id);
2513
2342
 
2514
2343
  /** <No documentation available> */
2515
2344
  typedef enum CLogLevel {
@@ -2614,6 +2443,17 @@ CDitto_t *
2614
2443
  CIdentityConfig_t * identity_config,
2615
2444
  HistoryTracking_t history_tracking);
2616
2445
 
2446
+ /** \brief
2447
+ * The SDK requests to drop its handle to the mDNS transport
2448
+ *
2449
+ * At some point dropping this events channel will effectively shut down and
2450
+ * remove the Transport. At time of writing, the Transport is still owned
2451
+ * within Peer.
2452
+ */
2453
+ void
2454
+ /* fn */ ditto_mdns_transport_free_handle (
2455
+ TransportHandle_MdnsPlatformEvent_t * handle);
2456
+
2617
2457
  /** <No documentation available> */
2618
2458
  typedef struct CAttachment {
2619
2459
  /** <No documentation available> */
@@ -3208,7 +3048,7 @@ void
3208
3048
  /** <No documentation available> */
3209
3049
  void
3210
3050
  /* fn */ ditto_transports_ble_advertisement_heard (
3211
- TransportHandle_BleClientPlatformEvent_t const * handle,
3051
+ TransportHandle_BlePlatformEvent_t const * handle,
3212
3052
  uint8_16_array_t const * peripheral_uuid,
3213
3053
  slice_ref_uint8_t manufacturer_data,
3214
3054
  bool manufacturer_data_includes_id,
@@ -3278,23 +3118,12 @@ LicenseVerificationResult_t
3278
3118
  char const * license,
3279
3119
  char * * out_err_msg);
3280
3120
 
3281
- /** \brief
3282
- * The SDK requests to drop its handle to the WifiAware discovery transport
3283
- *
3284
- * At some point dropping this events channel will effectively shut down and
3285
- * remove the Transport. At time of writing, the Transport is still owned
3286
- * within Peer.
3287
- */
3288
- void
3289
- /* fn */ ditto_wifi_aware_client_free_handle (
3290
- TransportHandle_WifiAwareClientPlatformEvent_t * handle);
3291
-
3292
3121
  /** \brief
3293
3122
  * The platform tells Rust that it should go offline.
3294
3123
  */
3295
3124
  void
3296
3125
  /* fn */ ditto_wifi_aware_client_go_offline_request (
3297
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle);
3126
+ TransportHandle_WifiAwarePlatformEvent_t const * handle);
3298
3127
 
3299
3128
  /** \brief
3300
3129
  * The platform tells Rust that it should go online (because the platform has attached to the WiFi
@@ -3302,14 +3131,14 @@ void
3302
3131
  */
3303
3132
  void
3304
3133
  /* fn */ ditto_wifi_aware_client_go_online_request (
3305
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle);
3134
+ TransportHandle_WifiAwarePlatformEvent_t const * handle);
3306
3135
 
3307
3136
  /** \brief
3308
3137
  * The platform advises Rust that we have resolved a peer's hostname and port
3309
3138
  */
3310
3139
  void
3311
3140
  /* fn */ ditto_wifi_aware_client_network_did_create (
3312
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3141
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3313
3142
  char const * announce_string,
3314
3143
  char const * hostname,
3315
3144
  uint16_t port);
@@ -3319,7 +3148,7 @@ void
3319
3148
  */
3320
3149
  void
3321
3150
  /* fn */ ditto_wifi_aware_client_peer_appeared (
3322
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3151
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3323
3152
  char const * announce_string);
3324
3153
 
3325
3154
  /** \brief
@@ -3328,7 +3157,7 @@ void
3328
3157
  */
3329
3158
  void
3330
3159
  /* fn */ ditto_wifi_aware_client_peer_did_not_connect (
3331
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3160
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3332
3161
  char const * announce_string);
3333
3162
 
3334
3163
  /** \brief
@@ -3336,7 +3165,7 @@ void
3336
3165
  */
3337
3166
  void
3338
3167
  /* fn */ ditto_wifi_aware_client_peer_disappeared (
3339
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3168
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3340
3169
  char const * announce_string);
3341
3170
 
3342
3171
  /** \brief
@@ -3345,7 +3174,7 @@ void
3345
3174
  */
3346
3175
  void
3347
3176
  /* fn */ ditto_wifi_aware_client_scanning_state_changed (
3348
- TransportHandle_WifiAwareClientPlatformEvent_t const * handle,
3177
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3349
3178
  OnlineState_t state,
3350
3179
  TransportCondition_t condition);
3351
3180
 
@@ -3355,26 +3184,16 @@ void
3355
3184
  */
3356
3185
  void
3357
3186
  /* fn */ ditto_wifi_aware_server_advertising_state_changed (
3358
- TransportHandle_WifiAwareServerPlatformEvent_t const * handle,
3187
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3359
3188
  OnlineState_t state,
3360
3189
  TransportCondition_t condition);
3361
3190
 
3362
- /** \brief
3363
- * The SDK requests to drop its handle to the WifiAware advertising service.
3364
- *
3365
- * Ideally this should remove the advertiser automatically.
3366
- * At time of writing now this must be done manually through Peer.
3367
- */
3368
- void
3369
- /* fn */ ditto_wifi_aware_server_free_handle (
3370
- TransportHandle_WifiAwareServerPlatformEvent_t * handle);
3371
-
3372
3191
  /** \brief
3373
3192
  * The platform tells Rust that it should go offline.
3374
3193
  */
3375
3194
  void
3376
3195
  /* fn */ ditto_wifi_aware_server_go_offline_request (
3377
- TransportHandle_WifiAwareServerPlatformEvent_t const * handle);
3196
+ TransportHandle_WifiAwarePlatformEvent_t const * handle);
3378
3197
 
3379
3198
  /** \brief
3380
3199
  * The platform tells Rust that it should go online (because the platform has attached to the WiFi
@@ -3382,7 +3201,34 @@ void
3382
3201
  */
3383
3202
  void
3384
3203
  /* fn */ ditto_wifi_aware_server_go_online_request (
3385
- TransportHandle_WifiAwareServerPlatformEvent_t const * handle);
3204
+ TransportHandle_WifiAwarePlatformEvent_t const * handle);
3205
+
3206
+ /** \brief
3207
+ * The platform tells Rust that a WiFi Aware network has been added
3208
+ */
3209
+ void
3210
+ /* fn */ ditto_wifi_aware_server_network_scope_id_added (
3211
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3212
+ uint32_t scope_id);
3213
+
3214
+ /** \brief
3215
+ * The platform tells Rust that a WiFi Aware network has been removed
3216
+ */
3217
+ void
3218
+ /* fn */ ditto_wifi_aware_server_network_scope_id_removed (
3219
+ TransportHandle_WifiAwarePlatformEvent_t const * handle,
3220
+ uint32_t scope_id);
3221
+
3222
+ /** \brief
3223
+ * The SDK requests to drop its handle to the WifiAware transport
3224
+ *
3225
+ * At some point dropping this events channel will effectively shut down and
3226
+ * remove the Transport. At time of writing, the Transport is still owned
3227
+ * within Peer.
3228
+ */
3229
+ void
3230
+ /* fn */ ditto_wifi_aware_transport_free_handle (
3231
+ TransportHandle_WifiAwarePlatformEvent_t * handle);
3386
3232
 
3387
3233
  /** <No documentation available> */
3388
3234
  typedef struct CWriteTransactionResult {
@@ -3453,6 +3299,13 @@ int32_t
3453
3299
  CDitto_t const * _ditto,
3454
3300
  CWriteTransaction_t * transaction);
3455
3301
 
3302
+ /** \brief
3303
+ * This is not meant to be part of the SDK surface: it's a shared secret that SDKs use when
3304
+ * constructing a "login provider" for development (fka "online playground").
3305
+ */
3306
+ char const *
3307
+ /* fn */ dittoffi_DITTO_DEVELOPMENT_PROVIDER (void);
3308
+
3456
3309
  /** <No documentation available> */
3457
3310
  void
3458
3311
  /* fn */ dittoffi_authentication_register_local_server_backend (
@@ -3606,36 +3459,167 @@ char *
3606
3459
  /* fn */ dittoffi_crypto_generate_secure_random_token (void);
3607
3460
 
3608
3461
  /** \brief
3609
- * Internal helper function to do integration testing of stacktrace generation in the SDKs.
3462
+ * An FFI appropriate, opaque representation of a differ.
3610
3463
  */
3611
- char *
3612
- /* fn */ dittoffi_ditto_capture_stack_trace_string_internal (void);
3464
+ typedef struct dittoffi_differ dittoffi_differ_t;
3613
3465
 
3614
3466
  /** \brief
3615
- * The ditto error type, opaque.
3467
+ * An individual result item from a query result (which holds a list of these items).
3616
3468
  */
3617
- typedef struct dittoffi_error dittoffi_error_t;
3618
-
3619
- /** <No documentation available> */
3620
- typedef struct dittoffi_result_uint64 {
3621
- /** \brief
3622
- * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3623
- */
3624
- dittoffi_error_t * error;
3625
-
3626
- /** \brief
3627
- * When no error occurred, the success value payload can be retrieved here.
3628
- *
3629
- * Otherwise, the value is to be ignored.
3630
- */
3631
- uint64_t success;
3632
- } dittoffi_result_uint64_t;
3469
+ typedef struct dittoffi_query_result_item dittoffi_query_result_item_t;
3633
3470
 
3634
- /** <No documentation available> */
3635
- dittoffi_result_uint64_t
3636
- /* fn */ dittoffi_ditto_get_system_parameter_u64 (
3637
- CDitto_t const * ditto,
3638
- char const * parameter_name);
3471
+ /** \brief
3472
+ * `&'lt [T]` but with a guaranteed `#[repr(C)]` layout.
3473
+ *
3474
+ * # C layout (for some given type T)
3475
+ *
3476
+ * ```c
3477
+ * typedef struct {
3478
+ * // Cannot be NULL
3479
+ * T * ptr;
3480
+ * size_t len;
3481
+ * } slice_T;
3482
+ * ```
3483
+ *
3484
+ * # Nullable pointer?
3485
+ *
3486
+ * If you want to support the above typedef, but where the `ptr` field is
3487
+ * allowed to be `NULL` (with the contents of `len` then being undefined)
3488
+ * use the `Option< slice_ptr<_> >` type.
3489
+ */
3490
+ typedef struct slice_ref_dittoffi_query_result_item_ptr {
3491
+ /** \brief
3492
+ * Pointer to the first element (if any).
3493
+ */
3494
+ dittoffi_query_result_item_t * const * ptr;
3495
+
3496
+ /** \brief
3497
+ * Element count
3498
+ */
3499
+ size_t len;
3500
+ } slice_ref_dittoffi_query_result_item_ptr_t;
3501
+
3502
+ /** <No documentation available> */
3503
+ typedef slice_boxed_uint8_t dittoffi_cbor_data_t;
3504
+
3505
+ /** \brief
3506
+ * Generate a diff between the given items and the differ's current list of items.
3507
+ *
3508
+ * The diff is returned as a CBOR serialized object, in the form of an object like this:
3509
+ *
3510
+ * ```json
3511
+ * {
3512
+ * "insertions": [0, 1],
3513
+ * "deletions": [2, 3],
3514
+ * "updates": [4, 5],
3515
+ * "moves": [[6, 7], [8, 9]]
3516
+ * }
3517
+ * ```
3518
+ *
3519
+ * Note that the `moves` array is an array of arrays, where each inner array is a pair of indices
3520
+ * representing `from` and `to` indices. The `from` index is the first element in the array and the
3521
+ * `to` index is the second element in the array, for each array in the `moves` array.
3522
+ */
3523
+ dittoffi_cbor_data_t
3524
+ /* fn */ dittoffi_differ_diff (
3525
+ dittoffi_differ_t const * differ,
3526
+ slice_ref_dittoffi_query_result_item_ptr_t items);
3527
+
3528
+ /** \brief
3529
+ * Free the differ.
3530
+ */
3531
+ void
3532
+ /* fn */ dittoffi_differ_free (
3533
+ dittoffi_differ_t * differ);
3534
+
3535
+ /** \brief
3536
+ * Returns the identity key path at the given index in the differ's list of identity key paths.
3537
+ *
3538
+ * # Safety
3539
+ *
3540
+ * The caller must ensure that the index is valid (i.e. less than the count of identity key paths).
3541
+ */
3542
+ char *
3543
+ /* fn */ dittoffi_differ_identity_key_path_at (
3544
+ dittoffi_differ_t const * differ,
3545
+ size_t idx);
3546
+
3547
+ /** \brief
3548
+ * Returns the number of identity key paths in use by the differ.
3549
+ */
3550
+ size_t
3551
+ /* fn */ dittoffi_differ_identity_key_path_count (
3552
+ dittoffi_differ_t const * differ);
3553
+
3554
+ /** \brief
3555
+ * Create a new differ.
3556
+ *
3557
+ * This differ will use the default identity key paths list, which is just `["_id"]`. This is the
3558
+ * default because the legacy query builder differ code uses the equivalent to this.
3559
+ */
3560
+ dittoffi_differ_t *
3561
+ /* fn */ dittoffi_differ_new (void);
3562
+
3563
+ /** \brief
3564
+ * The ditto error type, opaque.
3565
+ */
3566
+ typedef struct dittoffi_error dittoffi_error_t;
3567
+
3568
+ /** <No documentation available> */
3569
+ typedef struct dittoffi_result_dittoffi_differ_ptr {
3570
+ /** \brief
3571
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3572
+ */
3573
+ dittoffi_error_t * error;
3574
+
3575
+ /** \brief
3576
+ * When no error occurred, the success value payload can be retrieved here.
3577
+ *
3578
+ * Otherwise, the value is to be ignored.
3579
+ */
3580
+ dittoffi_differ_t * success;
3581
+ } dittoffi_result_dittoffi_differ_ptr_t;
3582
+
3583
+ /** \brief
3584
+ * Create a new differ using the provided identity key paths.
3585
+ */
3586
+ dittoffi_result_dittoffi_differ_ptr_t
3587
+ /* fn */ dittoffi_differ_new_with_identity_key_paths_throws (
3588
+ slice_ref_char_const_ptr_t identity_key_paths);
3589
+
3590
+ /** \brief
3591
+ * Internal helper function to do integration testing of stacktrace generation in the SDKs.
3592
+ */
3593
+ char *
3594
+ /* fn */ dittoffi_ditto_capture_stack_trace_string_internal (void);
3595
+
3596
+ /** \brief
3597
+ * Getter for `DittoConfig` serialized as CBOR, according to the DittoConfig.schema.json schema.
3598
+ */
3599
+ slice_boxed_uint8_t
3600
+ /* fn */ dittoffi_ditto_config (
3601
+ CDitto_t const * ditto);
3602
+
3603
+ /** <No documentation available> */
3604
+ typedef struct dittoffi_result_uint64 {
3605
+ /** \brief
3606
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3607
+ */
3608
+ dittoffi_error_t * error;
3609
+
3610
+ /** \brief
3611
+ * When no error occurred, the success value payload can be retrieved here.
3612
+ *
3613
+ * Otherwise, the value is to be ignored.
3614
+ */
3615
+ uint64_t success;
3616
+ } dittoffi_result_uint64_t;
3617
+
3618
+ /** <No documentation available> */
3619
+ dittoffi_result_uint64_t
3620
+ /* fn */ dittoffi_ditto_get_system_parameter_u64 (
3621
+ CDitto_t const * ditto,
3622
+ char const * parameter_name);
3639
3623
 
3640
3624
  /** \brief
3641
3625
  * Returns whether or not the Ditto instance has been activated with a valid license token.
@@ -3651,6 +3635,99 @@ bool
3651
3635
  /* fn */ dittoffi_ditto_is_sync_active (
3652
3636
  CDitto_t const * ditto);
3653
3637
 
3638
+ /** \brief
3639
+ * Whether or not the default values for parts of a `TransportConfig` that could be
3640
+ * platform-dependent should be determined based on the platform that the SDK is running on.
3641
+ *
3642
+ * For example, if `PlatformDependent` is chosen for the `TransportConfigMode`, then the default
3643
+ * value for whether AWDL would be enabled would be based on whether the SDK is running on an Apple
3644
+ * platform. Specifically, if you were running on an iOS device, for example, then AWDL would
3645
+ * default to enabled, but if you were using the .NET SDK running on a Windows machine then AWDL
3646
+ * would default to false.
3647
+ *
3648
+ * If `TransportConfigMode::PlatformIndependent` is chosen, then the default value would always be
3649
+ * true (at least in the case of whether or not AWDL is enabled).
3650
+ *
3651
+ * This really only exists to cater for the difference in behavior between the JS (and Flutter) and
3652
+ * other SDKs. The JS SDK's default value for platform-specific transports will be determined by
3653
+ * the platform that the JS SDK is running on, whereas the other SDKs will default to the same
3654
+ * value regardless of the platform that they are running on.
3655
+ */
3656
+ typedef enum TransportConfigMode {
3657
+ /** <No documentation available> */
3658
+ TRANSPORT_CONFIG_MODE_PLATFORM_DEPENDENT,
3659
+ /** <No documentation available> */
3660
+ TRANSPORT_CONFIG_MODE_PLATFORM_INDEPENDENT,
3661
+ } TransportConfigMode_t;
3662
+
3663
+ /** <No documentation available> */
3664
+ typedef struct dittoffi_result_CDitto_ptr {
3665
+ /** \brief
3666
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3667
+ */
3668
+ dittoffi_error_t * error;
3669
+
3670
+ /** \brief
3671
+ * When no error occurred, the success value payload can be retrieved here.
3672
+ *
3673
+ * Otherwise, the value is to be ignored.
3674
+ */
3675
+ CDitto_t * success;
3676
+ } dittoffi_result_CDitto_ptr_t;
3677
+
3678
+ /** \brief
3679
+ * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
3680
+ */
3681
+ typedef struct BoxDynFnMut1_void_dittoffi_result_CDitto_ptr {
3682
+ /** <No documentation available> */
3683
+ void * env_ptr;
3684
+
3685
+ /** <No documentation available> */
3686
+ void (*call)(void *, dittoffi_result_CDitto_ptr_t);
3687
+
3688
+ /** <No documentation available> */
3689
+ void (*free)(void *);
3690
+ } BoxDynFnMut1_void_dittoffi_result_CDitto_ptr_t;
3691
+
3692
+ /** \brief
3693
+ * Continuation (`repr_c::Box<dyn FnMut(…)>` FFI-safe callback) to be used as
3694
+ * the *completion handler* for conceptually-`async` APIs.
3695
+ */
3696
+ typedef BoxDynFnMut1_void_dittoffi_result_CDitto_ptr_t continuation_dittoffi_result_CDitto_ptr_t;
3697
+
3698
+ /** \brief
3699
+ * One of the two supported factory functions / constructors for opening a Ditto instance.
3700
+ *
3701
+ * * `config_cbor` - `DittoConfig` serialized as CBOR, according to the DittoConfig.schema.json
3702
+ * schema
3703
+ *
3704
+ * Nothing interesting happens in this function: it simply calls `Ditto::new` after creating a
3705
+ * `TaskRuntime`.
3706
+ *
3707
+ * See: `dittoffi_ditto_open_throws` for a synchronous version.
3708
+ */
3709
+ void
3710
+ /* fn */ dittoffi_ditto_open_async_throws (
3711
+ slice_ref_uint8_t config_cbor,
3712
+ TransportConfigMode_t transport_config_mode,
3713
+ continuation_dittoffi_result_CDitto_ptr_t continuation);
3714
+
3715
+ /** \brief
3716
+ * One of the two supported factory functions / constructors for opening a Ditto instance.
3717
+ *
3718
+ * * `config_cbor` - `DittoConfig` serialized as CBOR, according to the DittoConfig.schema.json
3719
+ * schema
3720
+ *
3721
+ * Nothing interesting happens in this function: it simply calls *and blocks on* `Ditto::new` after
3722
+ * creating a `TaskRuntime`.
3723
+ *
3724
+ * See: `dittoffi_ditto_open_async_throws` for an asynchronous version.
3725
+ */
3726
+ dittoffi_result_CDitto_ptr_t
3727
+ /* fn */ dittoffi_ditto_open_throws (
3728
+ slice_ref_uint8_t config_cbor,
3729
+ TransportConfigMode_t transport_config_mode);
3730
+
3654
3731
  /** \brief
3655
3732
  * `Box<dyn 'static + Send + FnMut(A1) -> Ret>`
3656
3733
  */
@@ -3766,46 +3843,6 @@ int32_t
3766
3843
  void
3767
3844
  /* fn */ dittoffi_ditto_trigger_test_panic_in_background (void);
3768
3845
 
3769
- /** \brief
3770
- * Whether or not the default values for parts of a `TransportConfig` that could be
3771
- * platform-dependent should be determined based on the platform that the SDK is running on.
3772
- *
3773
- * For example, if `PlatformDependent` is chosen for the `TransportConfigMode`, then the default
3774
- * value for whether AWDL would be enabled would be based on whether the SDK is running on an Apple
3775
- * platform. Specifically, if you were running on an iOS device, for example, then AWDL would
3776
- * default to enabled, but if you were using the .NET SDK running on a Windows machine then AWDL
3777
- * would default to false.
3778
- *
3779
- * If `TransportConfigMode::PlatformIndependent` is chosen, then the default value would always be
3780
- * true (at least in the case of whether or not AWDL is enabled).
3781
- *
3782
- * This really only exists to cater for the difference in behavior between the JS (and Flutter) and
3783
- * other SDKs. The JS SDK's default value for platform-specific transports will be determined by
3784
- * the platform that the JS SDK is running on, whereas the other SDKs will default to the same
3785
- * value regardless of the platform that they are running on.
3786
- */
3787
- typedef enum TransportConfigMode {
3788
- /** <No documentation available> */
3789
- TRANSPORT_CONFIG_MODE_PLATFORM_DEPENDENT,
3790
- /** <No documentation available> */
3791
- TRANSPORT_CONFIG_MODE_PLATFORM_INDEPENDENT,
3792
- } TransportConfigMode_t;
3793
-
3794
- /** <No documentation available> */
3795
- typedef struct dittoffi_result_CDitto_ptr {
3796
- /** \brief
3797
- * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
3798
- */
3799
- dittoffi_error_t * error;
3800
-
3801
- /** \brief
3802
- * When no error occurred, the success value payload can be retrieved here.
3803
- *
3804
- * Otherwise, the value is to be ignored.
3805
- */
3806
- CDitto_t * success;
3807
- } dittoffi_result_CDitto_ptr_t;
3808
-
3809
3846
  /** \brief
3810
3847
  * Same as `ditto_make`, but properly fallible (but not yet `async`).
3811
3848
  */
@@ -3889,6 +3926,8 @@ typedef enum dittoffi_error_code {
3889
3926
  DITTOFFI_ERROR_CODE_CBOR_UNSUPPORTED,
3890
3927
  /** <No documentation available> */
3891
3928
  DITTOFFI_ERROR_CODE_CRDT,
3929
+ /** <No documentation available> */
3930
+ DITTOFFI_ERROR_CODE_DIFFER_IDENTITY_KEY_PATH_INVALID,
3892
3931
  /** \brief
3893
3932
  * Dql query execution failed in flight.
3894
3933
  */
@@ -4173,9 +4212,6 @@ void
4173
4212
  /* fn */ dittoffi_query_result_free (
4174
4213
  dittoffi_query_result_t * result);
4175
4214
 
4176
- /** <No documentation available> */
4177
- typedef struct dittoffi_query_result_item dittoffi_query_result_item_t;
4178
-
4179
4215
  /** <No documentation available> */
4180
4216
  dittoffi_query_result_item_t *
4181
4217
  /* fn */ dittoffi_query_result_item_at (
@@ -4202,6 +4238,34 @@ char *
4202
4238
  /* fn */ dittoffi_query_result_item_json (
4203
4239
  dittoffi_query_result_item_t const * item);
4204
4240
 
4241
+ /** <No documentation available> */
4242
+ typedef struct dittoffi_result_dittoffi_query_result_item_ptr {
4243
+ /** \brief
4244
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4245
+ */
4246
+ dittoffi_error_t * error;
4247
+
4248
+ /** \brief
4249
+ * When no error occurred, the success value payload can be retrieved here.
4250
+ *
4251
+ * Otherwise, the value is to be ignored.
4252
+ */
4253
+ dittoffi_query_result_item_t * success;
4254
+ } dittoffi_result_dittoffi_query_result_item_ptr_t;
4255
+
4256
+ /** \brief
4257
+ * Create a query result item from JSON data.
4258
+ *
4259
+ * `query_result_item` is expected to represent the UTF-8 bytes of a serialized JSON instead of
4260
+ * CBOR.
4261
+ *
4262
+ * Note that this is only expected to be called by SDKs as part of generating test data, e.g. for
4263
+ * testing behaviour of the differ.
4264
+ */
4265
+ dittoffi_result_dittoffi_query_result_item_ptr_t
4266
+ /* fn */ dittoffi_query_result_item_new (
4267
+ slice_ref_uint8_t query_result_item);
4268
+
4205
4269
  /** <No documentation available> */
4206
4270
  slice_boxed_uint8_t
4207
4271
  /* fn */ dittoffi_query_result_mutated_document_id_at (
@@ -4216,6 +4280,10 @@ size_t
4216
4280
  /** \brief
4217
4281
  * Alias for `Ditto`, to better convey the notion of a store handle for store APIs,
4218
4282
  * TownHouse™-style.
4283
+ *
4284
+ * SDK code casts references to `Ditto`s into references to `FfiStore`s, so it's important for
4285
+ * safety that FfiStore doesn't add future invariants without checking `Transaction::store_ptr`
4286
+ * (and potentially other places too) to make sure those invariants are upheld.
4219
4287
  */
4220
4288
  typedef CDitto_t dittoffi_store_t;
4221
4289
 
@@ -4286,8 +4354,143 @@ void
4286
4354
  dittoffi_store_begin_transaction_options_t
4287
4355
  /* fn */ dittoffi_store_begin_transaction_options_make (void);
4288
4356
 
4357
+ /** \brief
4358
+ * An opaque, unique handle for a `StoreObserver`.
4359
+ *
4360
+ * This handle will be held by SDK callers above the FFI boundary. It is a required input to most
4361
+ * of the other FFI store observer functions.
4362
+ */
4363
+ typedef struct dittoffi_store_observer dittoffi_store_observer_t;
4364
+
4365
+ /** \brief
4366
+ * Cancels the observer and removes it from the list of registered observers.
4367
+ */
4368
+ void
4369
+ /* fn */ dittoffi_store_observer_cancel (
4370
+ dittoffi_store_observer_t const * observer);
4371
+
4372
+ /** \brief
4373
+ * Free an [`FfiStoreObserver`].
4374
+ */
4375
+ void
4376
+ /* fn */ dittoffi_store_observer_free (
4377
+ dittoffi_store_observer_t * _observer);
4378
+
4379
+ /** \brief
4380
+ * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
4381
+ */
4382
+ typedef struct Vec_dittoffi_store_observer_ptr {
4383
+ /** <No documentation available> */
4384
+ dittoffi_store_observer_t * * ptr;
4385
+
4386
+ /** <No documentation available> */
4387
+ size_t len;
4388
+
4389
+ /** <No documentation available> */
4390
+ size_t cap;
4391
+ } Vec_dittoffi_store_observer_ptr_t;
4392
+
4393
+ /** \brief
4394
+ * Free a Vec of [`FfiStoreObserver`]
4395
+ */
4396
+ void
4397
+ /* fn */ dittoffi_store_observer_free_sparse (
4398
+ Vec_dittoffi_store_observer_ptr_t _vec);
4399
+
4400
+ /** \brief
4401
+ * Returns the inner ID of the given observer.
4402
+ *
4403
+ * This is an implementation detail and should not be relied upon by third parties.
4404
+ */
4405
+ slice_boxed_uint8_t
4406
+ /* fn */ dittoffi_store_observer_id (
4407
+ dittoffi_store_observer_t const * observer);
4408
+
4409
+ /** \brief
4410
+ * Returns true if the given observer is cancelled.
4411
+ */
4412
+ bool
4413
+ /* fn */ dittoffi_store_observer_is_cancelled (
4414
+ dittoffi_store_observer_t const * observer);
4415
+
4416
+ /** \brief
4417
+ * Returns the DQL query arguments of the given observer, if any were given.
4418
+ */
4419
+ slice_boxed_uint8_t
4420
+ /* fn */ dittoffi_store_observer_query_arguments (
4421
+ dittoffi_store_observer_t const * observer);
4422
+
4423
+ /** \brief
4424
+ * Returns the DQL query string of the given observer.
4425
+ */
4426
+ char *
4427
+ /* fn */ dittoffi_store_observer_query_string (
4428
+ dittoffi_store_observer_t const * observer);
4429
+
4430
+ /** \brief
4431
+ * Returns a list of all registered observers.
4432
+ */
4433
+ Vec_dittoffi_store_observer_ptr_t
4434
+ /* fn */ dittoffi_store_observers (
4435
+ CDitto_t const * ditto);
4436
+
4437
+ /** \brief
4438
+ * `Arc<dyn Send + Sync + Fn() -> Ret>`
4439
+ */
4440
+ typedef struct ArcDynFn0_void {
4441
+ /** <No documentation available> */
4442
+ void * env_ptr;
4443
+
4444
+ /** <No documentation available> */
4445
+ void (*call)(void *);
4446
+
4447
+ /** <No documentation available> */
4448
+ void (*release)(void *);
4449
+
4450
+ /** <No documentation available> */
4451
+ void (*retain)(void *);
4452
+ } ArcDynFn0_void_t;
4453
+
4454
+ /** \brief
4455
+ * `Box<dyn 'static + Send + FnMut(A2, A1) -> Ret>`
4456
+ */
4457
+ typedef struct BoxDynFnMut2_void_dittoffi_query_result_ptr_ArcDynFn0_void {
4458
+ /** <No documentation available> */
4459
+ void * env_ptr;
4460
+
4461
+ /** <No documentation available> */
4462
+ void (*call)(void *, dittoffi_query_result_t *, ArcDynFn0_void_t);
4463
+
4464
+ /** <No documentation available> */
4465
+ void (*free)(void *);
4466
+ } BoxDynFnMut2_void_dittoffi_query_result_ptr_ArcDynFn0_void_t;
4467
+
4289
4468
  /** <No documentation available> */
4290
- typedef slice_boxed_uint8_t dittoffi_cbor_data_t;
4469
+ typedef struct dittoffi_result_dittoffi_store_observer_ptr {
4470
+ /** \brief
4471
+ * Non-`NULL` pointer to opaque object on error, `NULL` otherwise.
4472
+ */
4473
+ dittoffi_error_t * error;
4474
+
4475
+ /** \brief
4476
+ * When no error occurred, the success value payload can be retrieved here.
4477
+ *
4478
+ * Otherwise, the value is to be ignored.
4479
+ */
4480
+ dittoffi_store_observer_t * success;
4481
+ } dittoffi_result_dittoffi_store_observer_ptr_t;
4482
+
4483
+ /** \brief
4484
+ * Registers a new `StoreObserver` for the given DQL query and arguments.
4485
+ *
4486
+ * The observer will be notified of changes to the query results.
4487
+ */
4488
+ dittoffi_result_dittoffi_store_observer_ptr_t
4489
+ /* fn */ dittoffi_store_register_observer_throws (
4490
+ CDitto_t const * ditto,
4491
+ char const * query,
4492
+ slice_ref_uint8_t query_args_cbor,
4493
+ BoxDynFnMut2_void_dittoffi_query_result_ptr_ArcDynFn0_void_t callback);
4291
4494
 
4292
4495
  /** \brief
4293
4496
  * Returns all transactions currently in flight.
@@ -4296,7 +4499,9 @@ dittoffi_cbor_data_t
4296
4499
  /* fn */ dittoffi_store_transactions (
4297
4500
  dittoffi_store_t const * ffi_store);
4298
4501
 
4299
- /** <No documentation available> */
4502
+ /** \brief
4503
+ * An object that causes Ditto to continuously sync documents that match a query from other peers.
4504
+ */
4300
4505
  typedef struct dittoffi_sync_subscription dittoffi_sync_subscription_t;
4301
4506
 
4302
4507
  /** <No documentation available> */
@@ -4314,17 +4519,25 @@ typedef struct dittoffi_result_dittoffi_sync_subscription_ptr {
4314
4519
  dittoffi_sync_subscription_t * success;
4315
4520
  } dittoffi_result_dittoffi_sync_subscription_ptr_t;
4316
4521
 
4317
- /** <No documentation available> */
4522
+ /** \brief
4523
+ * Create a new [`FfiSyncSubscription`] from a DQL query and arguments.
4524
+ *
4525
+ * Until the subscription is cancelled, Ditto will continue to sync data matching the
4526
+ * subscription's query from other peers.
4527
+ */
4318
4528
  dittoffi_result_dittoffi_sync_subscription_ptr_t
4319
4529
  /* fn */ dittoffi_sync_register_subscription_throws (
4320
4530
  CDitto_t const * ditto,
4321
4531
  char const * query,
4322
4532
  slice_ref_uint8_t query_args_cbor);
4323
4533
 
4324
- /** <No documentation available> */
4534
+ /** \brief
4535
+ * Cancels the given sync subscription, after which Ditto will no longer sync the data matching
4536
+ * the subscription's query.
4537
+ */
4325
4538
  void
4326
4539
  /* fn */ dittoffi_sync_subscription_cancel (
4327
- dittoffi_sync_subscription_t const * handle);
4540
+ dittoffi_sync_subscription_t const * sync_subscription);
4328
4541
 
4329
4542
  /** \brief
4330
4543
  * Free a singular boxed [`FfiSyncSubscription`].
@@ -4338,26 +4551,28 @@ void
4338
4551
  */
4339
4552
  slice_boxed_uint8_t
4340
4553
  /* fn */ dittoffi_sync_subscription_id (
4341
- dittoffi_sync_subscription_t const * handle);
4554
+ dittoffi_sync_subscription_t const * sync_subscription);
4342
4555
 
4343
- /** <No documentation available> */
4556
+ /** \brief
4557
+ * Returns true if the given sync subscription has been cancelled.
4558
+ */
4344
4559
  bool
4345
4560
  /* fn */ dittoffi_sync_subscription_is_cancelled (
4346
- dittoffi_sync_subscription_t const * handle);
4561
+ dittoffi_sync_subscription_t const * sync_subscription);
4347
4562
 
4348
4563
  /** \brief
4349
- * From a `FfiSyncSubscription` handle, extract the DQL query query arguments as a CBOR buffer.
4564
+ * Returns the DQL arguments object associated with the given sync subscription, if one exists.
4350
4565
  */
4351
4566
  slice_boxed_uint8_t
4352
4567
  /* fn */ dittoffi_sync_subscription_query_arguments (
4353
- dittoffi_sync_subscription_t const * handle);
4568
+ dittoffi_sync_subscription_t const * sync_subscription);
4354
4569
 
4355
4570
  /** \brief
4356
- * From a `FfiSyncSubscription` handle, extract the DQL query string.
4571
+ * Returns the DQL query string associated with the given sync subscription.
4357
4572
  */
4358
4573
  char *
4359
4574
  /* fn */ dittoffi_sync_subscription_query_string (
4360
- dittoffi_sync_subscription_t const * handle);
4575
+ dittoffi_sync_subscription_t const * sync_subscription);
4361
4576
 
4362
4577
  /** \brief
4363
4578
  * Same as [`Vec<T>`][`rust::Vec`], but with guaranteed `#[repr(C)]` layout
@@ -4373,7 +4588,9 @@ typedef struct Vec_dittoffi_sync_subscription_ptr {
4373
4588
  size_t cap;
4374
4589
  } Vec_dittoffi_sync_subscription_ptr_t;
4375
4590
 
4376
- /** <No documentation available> */
4591
+ /** \brief
4592
+ * Returns a list of all active sync subscriptions.
4593
+ */
4377
4594
  Vec_dittoffi_sync_subscription_ptr_t
4378
4595
  /* fn */ dittoffi_sync_subscriptions (
4379
4596
  CDitto_t const * ditto);
@@ -4760,12 +4977,13 @@ dittoffi_result_slice_boxed_uint8_t
4760
4977
  /** \brief
4761
4978
  * Execute specified DQL statement.
4762
4979
  *
4763
- * Returns a [`QueryResult`], which contains a vector of [`QueryResultItem`]s.
4980
+ * Returns a [`FfiQueryResult`], which contains a vector of [`FfiQueryResultItem`]s.
4764
4981
  *
4765
4982
  * This is replacement for the old FFI, which was returning documents, but still uses the "old"
4766
4983
  * style of FFI transaction API.
4767
4984
  *
4768
- * [`QueryResultItem`]: crate::store::dql::response::QueryResultItem
4985
+ * [`FfiQueryResult`]: crate::store::dql::response::FfiQueryResult
4986
+ * [`FfiQueryResultItem`]: crate::store::dql::response::FfiQueryResultItem
4769
4987
  */
4770
4988
  dittoffi_result_dittoffi_query_result_ptr_t
4771
4989
  /* fn */ dittoffi_try_exec_statement (
@@ -4832,7 +5050,7 @@ dittoffi_result_Vec_char_ptr_t
4832
5050
  dittoffi_result_void_t
4833
5051
  /* fn */ dittoffi_try_live_query_start (
4834
5052
  CDitto_t const * ditto,
4835
- int64_t id);
5053
+ int64_t legacy_id);
4836
5054
 
4837
5055
  /** <No documentation available> */
4838
5056
  dittoffi_result_uint64_t
@@ -4921,27 +5139,16 @@ dittoffi_result_void_t
4921
5139
  */
4922
5140
  void
4923
5141
  /* fn */ mdns_advertising_state_changed (
4924
- TransportHandle_MdnsServerPlatformEvent_t const * handle,
5142
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4925
5143
  OnlineState_t state,
4926
5144
  TransportCondition_t condition);
4927
5145
 
4928
- /** \brief
4929
- * The SDK requests to drop its handle to the mDNS discovery transport
4930
- *
4931
- * At some point dropping this events channel will effectively shut down and
4932
- * remove the Transport. At time of writing, the Transport is still owned
4933
- * within Peer.
4934
- */
4935
- void
4936
- /* fn */ mdns_client_free_handle (
4937
- TransportHandle_MdnsClientPlatformEvent_t * handle);
4938
-
4939
5146
  /** \brief
4940
5147
  * The platform advises Rust that a peer has been identified.
4941
5148
  */
4942
5149
  void
4943
5150
  /* fn */ mdns_platform_peer_appeared (
4944
- TransportHandle_MdnsClientPlatformEvent_t const * handle,
5151
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4945
5152
  char const * announce_string);
4946
5153
 
4947
5154
  /** \brief
@@ -4949,7 +5156,7 @@ void
4949
5156
  */
4950
5157
  void
4951
5158
  /* fn */ mdns_platform_peer_disappeared (
4952
- TransportHandle_MdnsClientPlatformEvent_t const * handle,
5159
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4953
5160
  char const * announce_string);
4954
5161
 
4955
5162
  /** \brief
@@ -4958,26 +5165,16 @@ void
4958
5165
  */
4959
5166
  void
4960
5167
  /* fn */ mdns_scanning_state_changed (
4961
- TransportHandle_MdnsClientPlatformEvent_t const * handle,
5168
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4962
5169
  OnlineState_t state,
4963
5170
  TransportCondition_t condition);
4964
5171
 
4965
- /** \brief
4966
- * The SDK requests to drop its handle to the mDNS advertising service.
4967
- *
4968
- * Ideally this should remove the advertiser automatically.
4969
- * At time of writing now this must be done manually through Peer.
4970
- */
4971
- void
4972
- /* fn */ mdns_server_free_handle (
4973
- TransportHandle_MdnsServerPlatformEvent_t * handle);
4974
-
4975
5172
  /** \brief
4976
5173
  * The platform advises Rust that the TCP listener will need to be restarted.
4977
5174
  */
4978
5175
  void
4979
5176
  /* fn */ mdns_server_invalidate_listener (
4980
- TransportHandle_MdnsServerPlatformEvent_t const * handle);
5177
+ TransportHandle_MdnsPlatformEvent_t const * handle);
4981
5178
 
4982
5179
  /** \brief
4983
5180
  * The platform advises Rust that we failed to resolve a peer's hostname and
@@ -4985,7 +5182,7 @@ void
4985
5182
  */
4986
5183
  void
4987
5184
  /* fn */ mdns_service_did_not_resolve (
4988
- TransportHandle_MdnsClientPlatformEvent_t const * handle,
5185
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4989
5186
  char const * announce_string);
4990
5187
 
4991
5188
  /** \brief
@@ -4993,7 +5190,7 @@ void
4993
5190
  */
4994
5191
  void
4995
5192
  /* fn */ mdns_service_did_resolve (
4996
- TransportHandle_MdnsClientPlatformEvent_t const * handle,
5193
+ TransportHandle_MdnsPlatformEvent_t const * handle,
4997
5194
  char const * announce_string,
4998
5195
  char const * hostname,
4999
5196
  uint16_t port);