Live video on the AT Protocol

Rip out everything but the "iroh websocket"

...and rename some things

+214 -7544
+131 -4296
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.go
··· 6 import ( 7 "bytes" 8 "encoding/binary" 9 - "errors" 10 "fmt" 11 "io" 12 "math" 13 "runtime" 14 "runtime/cgo" 15 - "sync" 16 "sync/atomic" 17 - "time" 18 "unsafe" 19 ) 20 ··· 336 337 func init() { 338 339 - FfiConverterDataHandlerINSTANCE.register() 340 - FfiConverterGoSignerINSTANCE.register() 341 - FfiConverterManySegmentsToSignINSTANCE.register() 342 - FfiConverterManyStreamsINSTANCE.register() 343 - FfiConverterSegmentToSignINSTANCE.register() 344 - FfiConverterStreamINSTANCE.register() 345 uniffiCheckChecksums() 346 } 347 ··· 358 } 359 { 360 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 361 - return C.uniffi_iroh_streamplace_checksum_func_get_manifest_and_cert() 362 - }) 363 - if checksum != 36028 { 364 - // If this happens try cleaning and rebuilding your project 365 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_get_manifest_and_cert: UniFFI API checksum mismatch") 366 - } 367 - } 368 - { 369 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 370 - return C.uniffi_iroh_streamplace_checksum_func_get_manifests() 371 - }) 372 - if checksum != 2548 { 373 - // If this happens try cleaning and rebuilding your project 374 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_get_manifests: UniFFI API checksum mismatch") 375 - } 376 - } 377 - { 378 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 379 return C.uniffi_iroh_streamplace_checksum_func_init_logging() 380 }) 381 if checksum != 40911 { ··· 412 } 413 { 414 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 415 - return C.uniffi_iroh_streamplace_checksum_func_resign() 416 - }) 417 - if checksum != 34597 { 418 - // If this happens try cleaning and rebuilding your project 419 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_resign: UniFFI API checksum mismatch") 420 - } 421 - } 422 - { 423 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 424 - return C.uniffi_iroh_streamplace_checksum_func_sign() 425 - }) 426 - if checksum != 41179 { 427 - // If this happens try cleaning and rebuilding your project 428 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_sign: UniFFI API checksum mismatch") 429 - } 430 - } 431 - { 432 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 433 - return C.uniffi_iroh_streamplace_checksum_func_sign_with_ingredients() 434 - }) 435 - if checksum != 15411 { 436 - // If this happens try cleaning and rebuilding your project 437 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_sign_with_ingredients: UniFFI API checksum mismatch") 438 - } 439 - } 440 - { 441 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 442 - return C.uniffi_iroh_streamplace_checksum_func_subscribe_item_debug() 443 - }) 444 - if checksum != 8233 { 445 - // If this happens try cleaning and rebuilding your project 446 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_subscribe_item_debug: UniFFI API checksum mismatch") 447 - } 448 - } 449 - { 450 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 451 - return C.uniffi_iroh_streamplace_checksum_method_datahandler_handle_data() 452 - }) 453 - if checksum != 48772 { 454 - // If this happens try cleaning and rebuilding your project 455 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_datahandler_handle_data: UniFFI API checksum mismatch") 456 - } 457 - } 458 - { 459 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 460 - return C.uniffi_iroh_streamplace_checksum_method_db_iter_with_opts() 461 - }) 462 - if checksum != 3815 { 463 - // If this happens try cleaning and rebuilding your project 464 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_db_iter_with_opts: UniFFI API checksum mismatch") 465 - } 466 - } 467 - { 468 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 469 - return C.uniffi_iroh_streamplace_checksum_method_db_shutdown() 470 - }) 471 - if checksum != 9825 { 472 - // If this happens try cleaning and rebuilding your project 473 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_db_shutdown: UniFFI API checksum mismatch") 474 - } 475 - } 476 - { 477 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 478 - return C.uniffi_iroh_streamplace_checksum_method_db_subscribe() 479 - }) 480 - if checksum != 415 { 481 - // If this happens try cleaning and rebuilding your project 482 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_db_subscribe: UniFFI API checksum mismatch") 483 - } 484 - } 485 - { 486 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 487 - return C.uniffi_iroh_streamplace_checksum_method_db_subscribe_with_opts() 488 - }) 489 - if checksum != 17612 { 490 - // If this happens try cleaning and rebuilding your project 491 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_db_subscribe_with_opts: UniFFI API checksum mismatch") 492 - } 493 - } 494 - { 495 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 496 - return C.uniffi_iroh_streamplace_checksum_method_db_write() 497 - }) 498 - if checksum != 5247 { 499 - // If this happens try cleaning and rebuilding your project 500 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_db_write: UniFFI API checksum mismatch") 501 - } 502 - } 503 - { 504 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 505 - return C.uniffi_iroh_streamplace_checksum_method_filter_global() 506 - }) 507 - if checksum != 47323 { 508 - // If this happens try cleaning and rebuilding your project 509 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_global: UniFFI API checksum mismatch") 510 - } 511 - } 512 - { 513 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 514 - return C.uniffi_iroh_streamplace_checksum_method_filter_scope() 515 - }) 516 - if checksum != 23022 { 517 - // If this happens try cleaning and rebuilding your project 518 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_scope: UniFFI API checksum mismatch") 519 - } 520 - } 521 - { 522 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 523 - return C.uniffi_iroh_streamplace_checksum_method_filter_scopes() 524 - }) 525 - if checksum != 39037 { 526 - // If this happens try cleaning and rebuilding your project 527 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_scopes: UniFFI API checksum mismatch") 528 - } 529 - } 530 - { 531 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 532 - return C.uniffi_iroh_streamplace_checksum_method_filter_stream() 533 - }) 534 - if checksum != 37766 { 535 - // If this happens try cleaning and rebuilding your project 536 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_stream: UniFFI API checksum mismatch") 537 - } 538 - } 539 - { 540 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 541 - return C.uniffi_iroh_streamplace_checksum_method_filter_time_from() 542 - }) 543 - if checksum != 62275 { 544 - // If this happens try cleaning and rebuilding your project 545 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_time_from: UniFFI API checksum mismatch") 546 - } 547 - } 548 - { 549 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 550 - return C.uniffi_iroh_streamplace_checksum_method_filter_time_range() 551 - }) 552 - if checksum != 2045 { 553 - // If this happens try cleaning and rebuilding your project 554 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_time_range: UniFFI API checksum mismatch") 555 - } 556 - } 557 - { 558 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 559 - return C.uniffi_iroh_streamplace_checksum_method_filter_timestamps() 560 - }) 561 - if checksum != 27584 { 562 - // If this happens try cleaning and rebuilding your project 563 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_filter_timestamps: UniFFI API checksum mismatch") 564 - } 565 - } 566 - { 567 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 568 - return C.uniffi_iroh_streamplace_checksum_method_gosigner_sign() 569 - }) 570 - if checksum != 50597 { 571 - // If this happens try cleaning and rebuilding your project 572 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_gosigner_sign: UniFFI API checksum mismatch") 573 - } 574 - } 575 - { 576 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 577 - return C.uniffi_iroh_streamplace_checksum_method_manysegmentstosign_next() 578 - }) 579 - if checksum != 53885 { 580 - // If this happens try cleaning and rebuilding your project 581 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_manysegmentstosign_next: UniFFI API checksum mismatch") 582 - } 583 - } 584 - { 585 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 586 - return C.uniffi_iroh_streamplace_checksum_method_manystreams_next() 587 - }) 588 - if checksum != 50757 { 589 - // If this happens try cleaning and rebuilding your project 590 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_manystreams_next: UniFFI API checksum mismatch") 591 - } 592 - } 593 - { 594 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 595 - return C.uniffi_iroh_streamplace_checksum_method_node_add_tickets() 596 - }) 597 - if checksum != 8701 { 598 - // If this happens try cleaning and rebuilding your project 599 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_add_tickets: UniFFI API checksum mismatch") 600 - } 601 - } 602 - { 603 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 604 - return C.uniffi_iroh_streamplace_checksum_method_node_db() 605 - }) 606 - if checksum != 39096 { 607 - // If this happens try cleaning and rebuilding your project 608 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_db: UniFFI API checksum mismatch") 609 - } 610 - } 611 - { 612 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 613 - return C.uniffi_iroh_streamplace_checksum_method_node_join_peers() 614 - }) 615 - if checksum != 56647 { 616 - // If this happens try cleaning and rebuilding your project 617 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_join_peers: UniFFI API checksum mismatch") 618 - } 619 - } 620 - { 621 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 622 - return C.uniffi_iroh_streamplace_checksum_method_node_node_id() 623 - }) 624 - if checksum != 55009 { 625 - // If this happens try cleaning and rebuilding your project 626 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_node_id: UniFFI API checksum mismatch") 627 - } 628 - } 629 - { 630 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 631 - return C.uniffi_iroh_streamplace_checksum_method_node_node_scope() 632 - }) 633 - if checksum != 16912 { 634 - // If this happens try cleaning and rebuilding your project 635 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_node_scope: UniFFI API checksum mismatch") 636 - } 637 - } 638 - { 639 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 640 - return C.uniffi_iroh_streamplace_checksum_method_node_send_segment() 641 - }) 642 - if checksum != 18989 { 643 - // If this happens try cleaning and rebuilding your project 644 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_send_segment: UniFFI API checksum mismatch") 645 - } 646 - } 647 - { 648 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 649 - return C.uniffi_iroh_streamplace_checksum_method_node_shutdown() 650 - }) 651 - if checksum != 18129 { 652 - // If this happens try cleaning and rebuilding your project 653 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_shutdown: UniFFI API checksum mismatch") 654 - } 655 - } 656 - { 657 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 658 - return C.uniffi_iroh_streamplace_checksum_method_node_subscribe() 659 - }) 660 - if checksum != 17951 { 661 - // If this happens try cleaning and rebuilding your project 662 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_subscribe: UniFFI API checksum mismatch") 663 - } 664 - } 665 - { 666 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 667 - return C.uniffi_iroh_streamplace_checksum_method_node_ticket() 668 - }) 669 - if checksum != 37020 { 670 - // If this happens try cleaning and rebuilding your project 671 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_ticket: UniFFI API checksum mismatch") 672 - } 673 - } 674 - { 675 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 676 - return C.uniffi_iroh_streamplace_checksum_method_node_unsubscribe() 677 - }) 678 - if checksum != 35396 { 679 - // If this happens try cleaning and rebuilding your project 680 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_node_unsubscribe: UniFFI API checksum mismatch") 681 - } 682 - } 683 - { 684 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 685 return C.uniffi_iroh_streamplace_checksum_method_nodeaddr_direct_addresses() 686 }) 687 if checksum != 17536 { ··· 745 } 746 { 747 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 748 - return C.uniffi_iroh_streamplace_checksum_method_segmenttosign_unsigned_seg_stream() 749 - }) 750 - if checksum != 25252 { 751 - // If this happens try cleaning and rebuilding your project 752 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_segmenttosign_unsigned_seg_stream: UniFFI API checksum mismatch") 753 - } 754 - } 755 - { 756 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 757 - return C.uniffi_iroh_streamplace_checksum_method_segmenttosign_manifest_id() 758 - }) 759 - if checksum != 60736 { 760 - // If this happens try cleaning and rebuilding your project 761 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_segmenttosign_manifest_id: UniFFI API checksum mismatch") 762 - } 763 - } 764 - { 765 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 766 - return C.uniffi_iroh_streamplace_checksum_method_segmenttosign_cert() 767 - }) 768 - if checksum != 51060 { 769 - // If this happens try cleaning and rebuilding your project 770 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_segmenttosign_cert: UniFFI API checksum mismatch") 771 - } 772 - } 773 - { 774 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 775 - return C.uniffi_iroh_streamplace_checksum_method_segmenttosign_output_seg_stream() 776 - }) 777 - if checksum != 6113 { 778 - // If this happens try cleaning and rebuilding your project 779 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_segmenttosign_output_seg_stream: UniFFI API checksum mismatch") 780 - } 781 - } 782 - { 783 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 784 - return C.uniffi_iroh_streamplace_checksum_method_segmenttosign_close() 785 - }) 786 - if checksum != 39185 { 787 - // If this happens try cleaning and rebuilding your project 788 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_segmenttosign_close: UniFFI API checksum mismatch") 789 - } 790 - } 791 - { 792 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 793 return C.uniffi_iroh_streamplace_checksum_method_socket_accept() 794 }) 795 - if checksum != 12240 { 796 // If this happens try cleaning and rebuilding your project 797 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_accept: UniFFI API checksum mismatch") 798 } ··· 810 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 811 return C.uniffi_iroh_streamplace_checksum_method_socket_close() 812 }) 813 - if checksum != 32603 { 814 // If this happens try cleaning and rebuilding your project 815 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_close: UniFFI API checksum mismatch") 816 } ··· 819 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 820 return C.uniffi_iroh_streamplace_checksum_method_socket_connect() 821 }) 822 - if checksum != 63133 { 823 // If this happens try cleaning and rebuilding your project 824 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_connect: UniFFI API checksum mismatch") 825 } ··· 828 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 829 return C.uniffi_iroh_streamplace_checksum_method_socket_online() 830 }) 831 - if checksum != 52016 { 832 // If this happens try cleaning and rebuilding your project 833 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_online: UniFFI API checksum mismatch") 834 } ··· 837 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 838 return C.uniffi_iroh_streamplace_checksum_method_socket_ticket() 839 }) 840 - if checksum != 29083 { 841 // If this happens try cleaning and rebuilding your project 842 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_ticket: UniFFI API checksum mismatch") 843 } 844 } 845 { 846 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 847 - return C.uniffi_iroh_streamplace_checksum_method_stream_read_stream() 848 }) 849 - if checksum != 62815 { 850 // If this happens try cleaning and rebuilding your project 851 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_read_stream: UniFFI API checksum mismatch") 852 } 853 } 854 { 855 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 856 - return C.uniffi_iroh_streamplace_checksum_method_stream_seek_stream() 857 }) 858 - if checksum != 56397 { 859 // If this happens try cleaning and rebuilding your project 860 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_seek_stream: UniFFI API checksum mismatch") 861 } 862 } 863 { 864 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 865 - return C.uniffi_iroh_streamplace_checksum_method_stream_write_stream() 866 }) 867 - if checksum != 59847 { 868 // If this happens try cleaning and rebuilding your project 869 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_write_stream: UniFFI API checksum mismatch") 870 } 871 } 872 { 873 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 874 - return C.uniffi_iroh_streamplace_checksum_method_stream2_close() 875 }) 876 - if checksum != 7588 { 877 // If this happens try cleaning and rebuilding your project 878 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_close: UniFFI API checksum mismatch") 879 } 880 } 881 { 882 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 883 - return C.uniffi_iroh_streamplace_checksum_method_stream2_close_read() 884 }) 885 - if checksum != 15135 { 886 // If this happens try cleaning and rebuilding your project 887 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_close_read: UniFFI API checksum mismatch") 888 } 889 } 890 { 891 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 892 - return C.uniffi_iroh_streamplace_checksum_method_stream2_close_write() 893 - }) 894 - if checksum != 35288 { 895 - // If this happens try cleaning and rebuilding your project 896 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_close_write: UniFFI API checksum mismatch") 897 - } 898 - } 899 - { 900 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 901 - return C.uniffi_iroh_streamplace_checksum_method_stream2_closed() 902 - }) 903 - if checksum != 48312 { 904 - // If this happens try cleaning and rebuilding your project 905 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_closed: UniFFI API checksum mismatch") 906 - } 907 - } 908 - { 909 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 910 - return C.uniffi_iroh_streamplace_checksum_method_stream2_read() 911 }) 912 - if checksum != 55348 { 913 // If this happens try cleaning and rebuilding your project 914 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_read: UniFFI API checksum mismatch") 915 } 916 } 917 { 918 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 919 - return C.uniffi_iroh_streamplace_checksum_method_stream2_write() 920 }) 921 - if checksum != 35047 { 922 // If this happens try cleaning and rebuilding your project 923 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_write: UniFFI API checksum mismatch") 924 - } 925 - } 926 - { 927 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 928 - return C.uniffi_iroh_streamplace_checksum_method_stream2_write_all() 929 - }) 930 - if checksum != 29695 { 931 - // If this happens try cleaning and rebuilding your project 932 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream2_write_all: UniFFI API checksum mismatch") 933 - } 934 - } 935 - { 936 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 937 - return C.uniffi_iroh_streamplace_checksum_method_subscriberesponse_next_raw() 938 - }) 939 - if checksum != 55650 { 940 - // If this happens try cleaning and rebuilding your project 941 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_subscriberesponse_next_raw: UniFFI API checksum mismatch") 942 - } 943 - } 944 - { 945 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 946 - return C.uniffi_iroh_streamplace_checksum_method_writescope_put() 947 - }) 948 - if checksum != 50543 { 949 - // If this happens try cleaning and rebuilding your project 950 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_writescope_put: UniFFI API checksum mismatch") 951 - } 952 - } 953 - { 954 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 955 - return C.uniffi_iroh_streamplace_checksum_constructor_filter_new() 956 - }) 957 - if checksum != 5241 { 958 - // If this happens try cleaning and rebuilding your project 959 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_constructor_filter_new: UniFFI API checksum mismatch") 960 - } 961 - } 962 - { 963 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 964 - return C.uniffi_iroh_streamplace_checksum_constructor_node_forwarder() 965 - }) 966 - if checksum != 7334 { 967 - // If this happens try cleaning and rebuilding your project 968 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_constructor_node_forwarder: UniFFI API checksum mismatch") 969 - } 970 - } 971 - { 972 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 973 - return C.uniffi_iroh_streamplace_checksum_constructor_node_receiver() 974 - }) 975 - if checksum != 33844 { 976 - // If this happens try cleaning and rebuilding your project 977 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_constructor_node_receiver: UniFFI API checksum mismatch") 978 - } 979 - } 980 - { 981 - checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 982 - return C.uniffi_iroh_streamplace_checksum_constructor_node_sender() 983 - }) 984 - if checksum != 44785 { 985 - // If this happens try cleaning and rebuilding your project 986 - panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_constructor_node_sender: UniFFI API checksum mismatch") 987 } 988 } 989 { ··· 1072 1073 func (FfiDestroyerUint64) Destroy(_ uint64) {} 1074 1075 - type FfiConverterInt64 struct{} 1076 - 1077 - var FfiConverterInt64INSTANCE = FfiConverterInt64{} 1078 - 1079 - func (FfiConverterInt64) Lower(value int64) C.int64_t { 1080 - return C.int64_t(value) 1081 - } 1082 - 1083 - func (FfiConverterInt64) Write(writer io.Writer, value int64) { 1084 - writeInt64(writer, value) 1085 - } 1086 - 1087 - func (FfiConverterInt64) Lift(value C.int64_t) int64 { 1088 - return int64(value) 1089 - } 1090 - 1091 - func (FfiConverterInt64) Read(reader io.Reader) int64 { 1092 - return readInt64(reader) 1093 - } 1094 - 1095 - type FfiDestroyerInt64 struct{} 1096 - 1097 - func (FfiDestroyerInt64) Destroy(_ int64) {} 1098 - 1099 type FfiConverterBool struct{} 1100 1101 var FfiConverterBoolINSTANCE = FfiConverterBool{} ··· 1221 1222 func (FfiDestroyerBytes) Destroy(_ []byte) {} 1223 1224 - // FfiConverterDuration converts between uniffi duration and Go duration. 1225 - type FfiConverterDuration struct{} 1226 - 1227 - var FfiConverterDurationINSTANCE = FfiConverterDuration{} 1228 - 1229 - func (c FfiConverterDuration) Lift(rb RustBufferI) time.Duration { 1230 - return LiftFromRustBuffer[time.Duration](c, rb) 1231 - } 1232 - 1233 - func (c FfiConverterDuration) Read(reader io.Reader) time.Duration { 1234 - sec := readUint64(reader) 1235 - nsec := readUint32(reader) 1236 - return time.Duration(sec*1_000_000_000 + uint64(nsec)) 1237 - } 1238 - 1239 - func (c FfiConverterDuration) Lower(value time.Duration) C.RustBuffer { 1240 - return LowerIntoRustBuffer[time.Duration](c, value) 1241 - } 1242 - 1243 - func (c FfiConverterDuration) Write(writer io.Writer, value time.Duration) { 1244 - if value.Nanoseconds() < 0 { 1245 - // Rust does not support negative durations: 1246 - // https://www.reddit.com/r/rust/comments/ljl55u/why_rusts_duration_not_supporting_negative_values/ 1247 - // This panic is very bad, because it depends on user input, and in Go user input related 1248 - // error are supposed to be returned as errors, and not cause panics. However, with the 1249 - // current architecture, its not possible to return an error from here, so panic is used as 1250 - // the only other option to signal an error. 1251 - panic("negative duration is not allowed") 1252 - } 1253 - 1254 - writeUint64(writer, uint64(value)/1_000_000_000) 1255 - writeUint32(writer, uint32(uint64(value)%1_000_000_000)) 1256 - } 1257 - 1258 - type FfiDestroyerDuration struct{} 1259 - 1260 - func (FfiDestroyerDuration) Destroy(_ time.Duration) {} 1261 - 1262 // Below is an implementation of synchronization requirements outlined in the link. 1263 // https://github.com/mozilla/uniffi-rs/blob/0dc031132d9493ca812c3af6e7dd60ad2ea95bf0/uniffi_bindgen/src/bindings/kotlin/templates/ObjectRuntime.kt#L31 1264 ··· 1322 }) 1323 } 1324 1325 - // DataHandler trait that is exported to go for receiving data callbacks. 1326 - type DataHandler interface { 1327 - HandleData(from *PublicKey, topic string, data []byte) 1328 - } 1329 - 1330 - // DataHandler trait that is exported to go for receiving data callbacks. 1331 - type DataHandlerImpl struct { 1332 - ffiObject FfiObject 1333 - } 1334 - 1335 - func (_self *DataHandlerImpl) HandleData(from *PublicKey, topic string, data []byte) { 1336 - _pointer := _self.ffiObject.incrementPointer("DataHandler") 1337 - defer _self.ffiObject.decrementPointer() 1338 - uniffiRustCallAsync[error]( 1339 - nil, 1340 - // completeFn 1341 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 1342 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 1343 - return struct{}{} 1344 - }, 1345 - // liftFn 1346 - func(_ struct{}) struct{} { return struct{}{} }, 1347 - C.uniffi_iroh_streamplace_fn_method_datahandler_handle_data( 1348 - _pointer, FfiConverterPublicKeyINSTANCE.Lower(from), FfiConverterStringINSTANCE.Lower(topic), FfiConverterBytesINSTANCE.Lower(data)), 1349 - // pollFn 1350 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 1351 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 1352 - }, 1353 - // freeFn 1354 - func(handle C.uint64_t) { 1355 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 1356 - }, 1357 - ) 1358 - 1359 - } 1360 - func (object *DataHandlerImpl) Destroy() { 1361 - runtime.SetFinalizer(object, nil) 1362 - object.ffiObject.destroy() 1363 - } 1364 - 1365 - type FfiConverterDataHandler struct { 1366 - handleMap *concurrentHandleMap[DataHandler] 1367 - } 1368 - 1369 - var FfiConverterDataHandlerINSTANCE = FfiConverterDataHandler{ 1370 - handleMap: newConcurrentHandleMap[DataHandler](), 1371 - } 1372 - 1373 - func (c FfiConverterDataHandler) Lift(pointer unsafe.Pointer) DataHandler { 1374 - result := &DataHandlerImpl{ 1375 - newFfiObject( 1376 - pointer, 1377 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1378 - return C.uniffi_iroh_streamplace_fn_clone_datahandler(pointer, status) 1379 - }, 1380 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 1381 - C.uniffi_iroh_streamplace_fn_free_datahandler(pointer, status) 1382 - }, 1383 - ), 1384 - } 1385 - runtime.SetFinalizer(result, (*DataHandlerImpl).Destroy) 1386 - return result 1387 - } 1388 - 1389 - func (c FfiConverterDataHandler) Read(reader io.Reader) DataHandler { 1390 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 1391 - } 1392 - 1393 - func (c FfiConverterDataHandler) Lower(value DataHandler) unsafe.Pointer { 1394 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 1395 - // because the pointer will be decremented immediately after this function returns, 1396 - // and someone will be left holding onto a non-locked pointer. 1397 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 1398 - return pointer 1399 - 1400 - } 1401 - 1402 - func (c FfiConverterDataHandler) Write(writer io.Writer, value DataHandler) { 1403 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 1404 - } 1405 - 1406 - type FfiDestroyerDataHandler struct{} 1407 - 1408 - func (_ FfiDestroyerDataHandler) Destroy(value DataHandler) { 1409 - if val, ok := value.(*DataHandlerImpl); ok { 1410 - val.Destroy() 1411 - } else { 1412 - panic("Expected *DataHandlerImpl") 1413 - } 1414 - } 1415 - 1416 - type uniffiCallbackResult C.int8_t 1417 - 1418 - const ( 1419 - uniffiIdxCallbackFree uniffiCallbackResult = 0 1420 - uniffiCallbackResultSuccess uniffiCallbackResult = 0 1421 - uniffiCallbackResultError uniffiCallbackResult = 1 1422 - uniffiCallbackUnexpectedResultError uniffiCallbackResult = 2 1423 - uniffiCallbackCancelled uniffiCallbackResult = 3 1424 - ) 1425 - 1426 - type concurrentHandleMap[T any] struct { 1427 - handles map[uint64]T 1428 - currentHandle uint64 1429 - lock sync.RWMutex 1430 - } 1431 - 1432 - func newConcurrentHandleMap[T any]() *concurrentHandleMap[T] { 1433 - return &concurrentHandleMap[T]{ 1434 - handles: map[uint64]T{}, 1435 - } 1436 - } 1437 - 1438 - func (cm *concurrentHandleMap[T]) insert(obj T) uint64 { 1439 - cm.lock.Lock() 1440 - defer cm.lock.Unlock() 1441 - 1442 - cm.currentHandle = cm.currentHandle + 1 1443 - cm.handles[cm.currentHandle] = obj 1444 - return cm.currentHandle 1445 - } 1446 - 1447 - func (cm *concurrentHandleMap[T]) remove(handle uint64) { 1448 - cm.lock.Lock() 1449 - defer cm.lock.Unlock() 1450 - 1451 - delete(cm.handles, handle) 1452 - } 1453 - 1454 - func (cm *concurrentHandleMap[T]) tryGet(handle uint64) (T, bool) { 1455 - cm.lock.RLock() 1456 - defer cm.lock.RUnlock() 1457 - 1458 - val, ok := cm.handles[handle] 1459 - return val, ok 1460 - } 1461 - 1462 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0 1463 - func iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uniffiHandle C.uint64_t, from unsafe.Pointer, topic C.RustBuffer, data C.RustBuffer, uniffiFutureCallback C.UniffiForeignFutureCompleteVoid, uniffiCallbackData C.uint64_t, uniffiOutReturn *C.UniffiForeignFuture) { 1464 - handle := uint64(uniffiHandle) 1465 - uniffiObj, ok := FfiConverterDataHandlerINSTANCE.handleMap.tryGet(handle) 1466 - if !ok { 1467 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 1468 - } 1469 - 1470 - result := make(chan C.UniffiForeignFutureStructVoid, 1) 1471 - cancel := make(chan struct{}, 1) 1472 - guardHandle := cgo.NewHandle(cancel) 1473 - *uniffiOutReturn = C.UniffiForeignFuture{ 1474 - handle: C.uint64_t(guardHandle), 1475 - free: C.UniffiForeignFutureFree(C.iroh_streamplace_uniffiFreeGorutine), 1476 - } 1477 - 1478 - // Wait for compleation or cancel 1479 - go func() { 1480 - select { 1481 - case <-cancel: 1482 - case res := <-result: 1483 - C.call_UniffiForeignFutureCompleteVoid(uniffiFutureCallback, uniffiCallbackData, res) 1484 - } 1485 - }() 1486 - 1487 - // Eval callback asynchroniously 1488 - go func() { 1489 - asyncResult := &C.UniffiForeignFutureStructVoid{} 1490 - defer func() { 1491 - result <- *asyncResult 1492 - }() 1493 - 1494 - uniffiObj.HandleData( 1495 - FfiConverterPublicKeyINSTANCE.Lift(from), 1496 - FfiConverterStringINSTANCE.Lift(GoRustBuffer{ 1497 - inner: topic, 1498 - }), 1499 - FfiConverterBytesINSTANCE.Lift(GoRustBuffer{ 1500 - inner: data, 1501 - }), 1502 - ) 1503 - 1504 - }() 1505 - } 1506 - 1507 - var UniffiVTableCallbackInterfaceDataHandlerINSTANCE = C.UniffiVTableCallbackInterfaceDataHandler{ 1508 - handleData: (C.UniffiCallbackInterfaceDataHandlerMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0), 1509 - 1510 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree), 1511 - } 1512 - 1513 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree 1514 - func iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree(handle C.uint64_t) { 1515 - FfiConverterDataHandlerINSTANCE.handleMap.remove(uint64(handle)) 1516 - } 1517 - 1518 - func (c FfiConverterDataHandler) register() { 1519 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_datahandler(&UniffiVTableCallbackInterfaceDataHandlerINSTANCE) 1520 - } 1521 - 1522 - // Iroh-streamplace specific metadata database. 1523 - type DbInterface interface { 1524 - IterWithOpts(filter *Filter) ([]Entry, error) 1525 - // Shutdown the database client and all subscriptions. 1526 - Shutdown() error 1527 - Subscribe(filter *Filter) *SubscribeResponse 1528 - // Subscribe with options. 1529 - SubscribeWithOpts(opts SubscribeOpts) *SubscribeResponse 1530 - Write(secret []byte) (*WriteScope, error) 1531 - } 1532 - 1533 - // Iroh-streamplace specific metadata database. 1534 - type Db struct { 1535 - ffiObject FfiObject 1536 - } 1537 - 1538 - func (_self *Db) IterWithOpts(filter *Filter) ([]Entry, error) { 1539 - _pointer := _self.ffiObject.incrementPointer("*Db") 1540 - defer _self.ffiObject.decrementPointer() 1541 - res, err := uniffiRustCallAsync[SubscribeNextError]( 1542 - FfiConverterSubscribeNextErrorINSTANCE, 1543 - // completeFn 1544 - func(handle C.uint64_t, status *C.RustCallStatus) RustBufferI { 1545 - res := C.ffi_iroh_streamplace_rust_future_complete_rust_buffer(handle, status) 1546 - return GoRustBuffer{ 1547 - inner: res, 1548 - } 1549 - }, 1550 - // liftFn 1551 - func(ffi RustBufferI) []Entry { 1552 - return FfiConverterSequenceEntryINSTANCE.Lift(ffi) 1553 - }, 1554 - C.uniffi_iroh_streamplace_fn_method_db_iter_with_opts( 1555 - _pointer, FfiConverterFilterINSTANCE.Lower(filter)), 1556 - // pollFn 1557 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 1558 - C.ffi_iroh_streamplace_rust_future_poll_rust_buffer(handle, continuation, data) 1559 - }, 1560 - // freeFn 1561 - func(handle C.uint64_t) { 1562 - C.ffi_iroh_streamplace_rust_future_free_rust_buffer(handle) 1563 - }, 1564 - ) 1565 - 1566 - if err == nil { 1567 - return res, nil 1568 - } 1569 - 1570 - return res, err 1571 - } 1572 - 1573 - // Shutdown the database client and all subscriptions. 1574 - func (_self *Db) Shutdown() error { 1575 - _pointer := _self.ffiObject.incrementPointer("*Db") 1576 - defer _self.ffiObject.decrementPointer() 1577 - _, err := uniffiRustCallAsync[ShutdownError]( 1578 - FfiConverterShutdownErrorINSTANCE, 1579 - // completeFn 1580 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 1581 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 1582 - return struct{}{} 1583 - }, 1584 - // liftFn 1585 - func(_ struct{}) struct{} { return struct{}{} }, 1586 - C.uniffi_iroh_streamplace_fn_method_db_shutdown( 1587 - _pointer), 1588 - // pollFn 1589 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 1590 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 1591 - }, 1592 - // freeFn 1593 - func(handle C.uint64_t) { 1594 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 1595 - }, 1596 - ) 1597 - 1598 - if err == nil { 1599 - return nil 1600 - } 1601 - 1602 - return err 1603 - } 1604 - 1605 - func (_self *Db) Subscribe(filter *Filter) *SubscribeResponse { 1606 - _pointer := _self.ffiObject.incrementPointer("*Db") 1607 - defer _self.ffiObject.decrementPointer() 1608 - return FfiConverterSubscribeResponseINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1609 - return C.uniffi_iroh_streamplace_fn_method_db_subscribe( 1610 - _pointer, FfiConverterFilterINSTANCE.Lower(filter), _uniffiStatus) 1611 - })) 1612 - } 1613 - 1614 - // Subscribe with options. 1615 - func (_self *Db) SubscribeWithOpts(opts SubscribeOpts) *SubscribeResponse { 1616 - _pointer := _self.ffiObject.incrementPointer("*Db") 1617 - defer _self.ffiObject.decrementPointer() 1618 - return FfiConverterSubscribeResponseINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1619 - return C.uniffi_iroh_streamplace_fn_method_db_subscribe_with_opts( 1620 - _pointer, FfiConverterSubscribeOptsINSTANCE.Lower(opts), _uniffiStatus) 1621 - })) 1622 - } 1623 - 1624 - func (_self *Db) Write(secret []byte) (*WriteScope, error) { 1625 - _pointer := _self.ffiObject.incrementPointer("*Db") 1626 - defer _self.ffiObject.decrementPointer() 1627 - _uniffiRV, _uniffiErr := rustCallWithError[WriteError](FfiConverterWriteError{}, func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1628 - return C.uniffi_iroh_streamplace_fn_method_db_write( 1629 - _pointer, FfiConverterBytesINSTANCE.Lower(secret), _uniffiStatus) 1630 - }) 1631 - if _uniffiErr != nil { 1632 - var _uniffiDefaultValue *WriteScope 1633 - return _uniffiDefaultValue, _uniffiErr 1634 - } else { 1635 - return FfiConverterWriteScopeINSTANCE.Lift(_uniffiRV), nil 1636 - } 1637 - } 1638 - func (object *Db) Destroy() { 1639 - runtime.SetFinalizer(object, nil) 1640 - object.ffiObject.destroy() 1641 - } 1642 - 1643 - type FfiConverterDb struct{} 1644 - 1645 - var FfiConverterDbINSTANCE = FfiConverterDb{} 1646 - 1647 - func (c FfiConverterDb) Lift(pointer unsafe.Pointer) *Db { 1648 - result := &Db{ 1649 - newFfiObject( 1650 - pointer, 1651 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1652 - return C.uniffi_iroh_streamplace_fn_clone_db(pointer, status) 1653 - }, 1654 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 1655 - C.uniffi_iroh_streamplace_fn_free_db(pointer, status) 1656 - }, 1657 - ), 1658 - } 1659 - runtime.SetFinalizer(result, (*Db).Destroy) 1660 - return result 1661 - } 1662 - 1663 - func (c FfiConverterDb) Read(reader io.Reader) *Db { 1664 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 1665 - } 1666 - 1667 - func (c FfiConverterDb) Lower(value *Db) unsafe.Pointer { 1668 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 1669 - // because the pointer will be decremented immediately after this function returns, 1670 - // and someone will be left holding onto a non-locked pointer. 1671 - pointer := value.ffiObject.incrementPointer("*Db") 1672 - defer value.ffiObject.decrementPointer() 1673 - return pointer 1674 - 1675 - } 1676 - 1677 - func (c FfiConverterDb) Write(writer io.Writer, value *Db) { 1678 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 1679 - } 1680 - 1681 - type FfiDestroyerDb struct{} 1682 - 1683 - func (_ FfiDestroyerDb) Destroy(value *Db) { 1684 - value.Destroy() 1685 - } 1686 - 1687 - // A filter for subscriptions and iteration. 1688 - type FilterInterface interface { 1689 - // Restrict to the global namespace, no per stream data. 1690 - Global() *Filter 1691 - // Restrict to a single scope. 1692 - Scope(scope *PublicKey) *Filter 1693 - // Restrict to a set of scopes. 1694 - Scopes(scopes []*PublicKey) *Filter 1695 - // Restrict to one specific stream, no global data. 1696 - Stream(stream []byte) *Filter 1697 - // Restrict to a time range starting at min, unbounded at the top. 1698 - TimeFrom(min uint64) *Filter 1699 - // Restrict to a time range given in nanoseconds since unix epoch. 1700 - TimeRange(min uint64, max uint64) *Filter 1701 - // Restrict to a time range. 1702 - Timestamps(min TimeBound, max TimeBound) *Filter 1703 - } 1704 - 1705 - // A filter for subscriptions and iteration. 1706 - type Filter struct { 1707 - ffiObject FfiObject 1708 - } 1709 - 1710 - // Creates a new filter that matches everything. 1711 - func NewFilter() *Filter { 1712 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1713 - return C.uniffi_iroh_streamplace_fn_constructor_filter_new(_uniffiStatus) 1714 - })) 1715 - } 1716 - 1717 - // Restrict to the global namespace, no per stream data. 1718 - func (_self *Filter) Global() *Filter { 1719 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1720 - defer _self.ffiObject.decrementPointer() 1721 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1722 - return C.uniffi_iroh_streamplace_fn_method_filter_global( 1723 - _pointer, _uniffiStatus) 1724 - })) 1725 - } 1726 - 1727 - // Restrict to a single scope. 1728 - func (_self *Filter) Scope(scope *PublicKey) *Filter { 1729 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1730 - defer _self.ffiObject.decrementPointer() 1731 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1732 - return C.uniffi_iroh_streamplace_fn_method_filter_scope( 1733 - _pointer, FfiConverterPublicKeyINSTANCE.Lower(scope), _uniffiStatus) 1734 - })) 1735 - } 1736 - 1737 - // Restrict to a set of scopes. 1738 - func (_self *Filter) Scopes(scopes []*PublicKey) *Filter { 1739 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1740 - defer _self.ffiObject.decrementPointer() 1741 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1742 - return C.uniffi_iroh_streamplace_fn_method_filter_scopes( 1743 - _pointer, FfiConverterSequencePublicKeyINSTANCE.Lower(scopes), _uniffiStatus) 1744 - })) 1745 - } 1746 - 1747 - // Restrict to one specific stream, no global data. 1748 - func (_self *Filter) Stream(stream []byte) *Filter { 1749 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1750 - defer _self.ffiObject.decrementPointer() 1751 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1752 - return C.uniffi_iroh_streamplace_fn_method_filter_stream( 1753 - _pointer, FfiConverterBytesINSTANCE.Lower(stream), _uniffiStatus) 1754 - })) 1755 - } 1756 - 1757 - // Restrict to a time range starting at min, unbounded at the top. 1758 - func (_self *Filter) TimeFrom(min uint64) *Filter { 1759 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1760 - defer _self.ffiObject.decrementPointer() 1761 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1762 - return C.uniffi_iroh_streamplace_fn_method_filter_time_from( 1763 - _pointer, FfiConverterUint64INSTANCE.Lower(min), _uniffiStatus) 1764 - })) 1765 - } 1766 - 1767 - // Restrict to a time range given in nanoseconds since unix epoch. 1768 - func (_self *Filter) TimeRange(min uint64, max uint64) *Filter { 1769 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1770 - defer _self.ffiObject.decrementPointer() 1771 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1772 - return C.uniffi_iroh_streamplace_fn_method_filter_time_range( 1773 - _pointer, FfiConverterUint64INSTANCE.Lower(min), FfiConverterUint64INSTANCE.Lower(max), _uniffiStatus) 1774 - })) 1775 - } 1776 - 1777 - // Restrict to a time range. 1778 - func (_self *Filter) Timestamps(min TimeBound, max TimeBound) *Filter { 1779 - _pointer := _self.ffiObject.incrementPointer("*Filter") 1780 - defer _self.ffiObject.decrementPointer() 1781 - return FfiConverterFilterINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 1782 - return C.uniffi_iroh_streamplace_fn_method_filter_timestamps( 1783 - _pointer, FfiConverterTimeBoundINSTANCE.Lower(min), FfiConverterTimeBoundINSTANCE.Lower(max), _uniffiStatus) 1784 - })) 1785 - } 1786 - func (object *Filter) Destroy() { 1787 - runtime.SetFinalizer(object, nil) 1788 - object.ffiObject.destroy() 1789 - } 1790 - 1791 - type FfiConverterFilter struct{} 1792 - 1793 - var FfiConverterFilterINSTANCE = FfiConverterFilter{} 1794 - 1795 - func (c FfiConverterFilter) Lift(pointer unsafe.Pointer) *Filter { 1796 - result := &Filter{ 1797 - newFfiObject( 1798 - pointer, 1799 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1800 - return C.uniffi_iroh_streamplace_fn_clone_filter(pointer, status) 1801 - }, 1802 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 1803 - C.uniffi_iroh_streamplace_fn_free_filter(pointer, status) 1804 - }, 1805 - ), 1806 - } 1807 - runtime.SetFinalizer(result, (*Filter).Destroy) 1808 - return result 1809 - } 1810 - 1811 - func (c FfiConverterFilter) Read(reader io.Reader) *Filter { 1812 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 1813 - } 1814 - 1815 - func (c FfiConverterFilter) Lower(value *Filter) unsafe.Pointer { 1816 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 1817 - // because the pointer will be decremented immediately after this function returns, 1818 - // and someone will be left holding onto a non-locked pointer. 1819 - pointer := value.ffiObject.incrementPointer("*Filter") 1820 - defer value.ffiObject.decrementPointer() 1821 - return pointer 1822 - 1823 - } 1824 - 1825 - func (c FfiConverterFilter) Write(writer io.Writer, value *Filter) { 1826 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 1827 - } 1828 - 1829 - type FfiDestroyerFilter struct{} 1830 - 1831 - func (_ FfiDestroyerFilter) Destroy(value *Filter) { 1832 - value.Destroy() 1833 - } 1834 - 1835 - type GoSigner interface { 1836 - Sign(data []byte) ([]byte, error) 1837 - } 1838 - type GoSignerImpl struct { 1839 - ffiObject FfiObject 1840 - } 1841 - 1842 - func (_self *GoSignerImpl) Sign(data []byte) ([]byte, error) { 1843 - _pointer := _self.ffiObject.incrementPointer("GoSigner") 1844 - defer _self.ffiObject.decrementPointer() 1845 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { 1846 - return GoRustBuffer{ 1847 - inner: C.uniffi_iroh_streamplace_fn_method_gosigner_sign( 1848 - _pointer, FfiConverterBytesINSTANCE.Lower(data), _uniffiStatus), 1849 - } 1850 - }) 1851 - if _uniffiErr != nil { 1852 - var _uniffiDefaultValue []byte 1853 - return _uniffiDefaultValue, _uniffiErr 1854 - } else { 1855 - return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil 1856 - } 1857 - } 1858 - func (object *GoSignerImpl) Destroy() { 1859 - runtime.SetFinalizer(object, nil) 1860 - object.ffiObject.destroy() 1861 - } 1862 - 1863 - type FfiConverterGoSigner struct { 1864 - handleMap *concurrentHandleMap[GoSigner] 1865 - } 1866 - 1867 - var FfiConverterGoSignerINSTANCE = FfiConverterGoSigner{ 1868 - handleMap: newConcurrentHandleMap[GoSigner](), 1869 - } 1870 - 1871 - func (c FfiConverterGoSigner) Lift(pointer unsafe.Pointer) GoSigner { 1872 - result := &GoSignerImpl{ 1873 - newFfiObject( 1874 - pointer, 1875 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1876 - return C.uniffi_iroh_streamplace_fn_clone_gosigner(pointer, status) 1877 - }, 1878 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 1879 - C.uniffi_iroh_streamplace_fn_free_gosigner(pointer, status) 1880 - }, 1881 - ), 1882 - } 1883 - runtime.SetFinalizer(result, (*GoSignerImpl).Destroy) 1884 - return result 1885 - } 1886 - 1887 - func (c FfiConverterGoSigner) Read(reader io.Reader) GoSigner { 1888 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 1889 - } 1890 - 1891 - func (c FfiConverterGoSigner) Lower(value GoSigner) unsafe.Pointer { 1892 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 1893 - // because the pointer will be decremented immediately after this function returns, 1894 - // and someone will be left holding onto a non-locked pointer. 1895 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 1896 - return pointer 1897 - 1898 - } 1899 - 1900 - func (c FfiConverterGoSigner) Write(writer io.Writer, value GoSigner) { 1901 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 1902 - } 1903 - 1904 - type FfiDestroyerGoSigner struct{} 1905 - 1906 - func (_ FfiDestroyerGoSigner) Destroy(value GoSigner) { 1907 - if val, ok := value.(*GoSignerImpl); ok { 1908 - val.Destroy() 1909 - } else { 1910 - panic("Expected *GoSignerImpl") 1911 - } 1912 - } 1913 - 1914 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerMethod0 1915 - func iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerMethod0(uniffiHandle C.uint64_t, data C.RustBuffer, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 1916 - handle := uint64(uniffiHandle) 1917 - uniffiObj, ok := FfiConverterGoSignerINSTANCE.handleMap.tryGet(handle) 1918 - if !ok { 1919 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 1920 - } 1921 - 1922 - res, err := 1923 - uniffiObj.Sign( 1924 - FfiConverterBytesINSTANCE.Lift(GoRustBuffer{ 1925 - inner: data, 1926 - }), 1927 - ) 1928 - 1929 - if err != nil { 1930 - var actualError *SpError 1931 - if errors.As(err, &actualError) { 1932 - *callStatus = C.RustCallStatus{ 1933 - code: C.int8_t(uniffiCallbackResultError), 1934 - errorBuf: FfiConverterSpErrorINSTANCE.Lower(actualError), 1935 - } 1936 - } else { 1937 - *callStatus = C.RustCallStatus{ 1938 - code: C.int8_t(uniffiCallbackUnexpectedResultError), 1939 - } 1940 - } 1941 - return 1942 - } 1943 - 1944 - *uniffiOutReturn = FfiConverterBytesINSTANCE.Lower(res) 1945 - } 1946 - 1947 - var UniffiVTableCallbackInterfaceGoSignerINSTANCE = C.UniffiVTableCallbackInterfaceGoSigner{ 1948 - sign: (C.UniffiCallbackInterfaceGoSignerMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerMethod0), 1949 - 1950 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerFree), 1951 - } 1952 - 1953 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerFree 1954 - func iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerFree(handle C.uint64_t) { 1955 - FfiConverterGoSignerINSTANCE.handleMap.remove(uint64(handle)) 1956 - } 1957 - 1958 - func (c FfiConverterGoSigner) register() { 1959 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_gosigner(&UniffiVTableCallbackInterfaceGoSignerINSTANCE) 1960 - } 1961 - 1962 - type ManySegmentsToSign interface { 1963 - Next() *SegmentToSign 1964 - } 1965 - type ManySegmentsToSignImpl struct { 1966 - ffiObject FfiObject 1967 - } 1968 - 1969 - func (_self *ManySegmentsToSignImpl) Next() *SegmentToSign { 1970 - _pointer := _self.ffiObject.incrementPointer("ManySegmentsToSign") 1971 - defer _self.ffiObject.decrementPointer() 1972 - return FfiConverterOptionalSegmentToSignINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 1973 - return GoRustBuffer{ 1974 - inner: C.uniffi_iroh_streamplace_fn_method_manysegmentstosign_next( 1975 - _pointer, _uniffiStatus), 1976 - } 1977 - })) 1978 - } 1979 - func (object *ManySegmentsToSignImpl) Destroy() { 1980 - runtime.SetFinalizer(object, nil) 1981 - object.ffiObject.destroy() 1982 - } 1983 - 1984 - type FfiConverterManySegmentsToSign struct { 1985 - handleMap *concurrentHandleMap[ManySegmentsToSign] 1986 - } 1987 - 1988 - var FfiConverterManySegmentsToSignINSTANCE = FfiConverterManySegmentsToSign{ 1989 - handleMap: newConcurrentHandleMap[ManySegmentsToSign](), 1990 - } 1991 - 1992 - func (c FfiConverterManySegmentsToSign) Lift(pointer unsafe.Pointer) ManySegmentsToSign { 1993 - result := &ManySegmentsToSignImpl{ 1994 - newFfiObject( 1995 - pointer, 1996 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1997 - return C.uniffi_iroh_streamplace_fn_clone_manysegmentstosign(pointer, status) 1998 - }, 1999 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 2000 - C.uniffi_iroh_streamplace_fn_free_manysegmentstosign(pointer, status) 2001 - }, 2002 - ), 2003 - } 2004 - runtime.SetFinalizer(result, (*ManySegmentsToSignImpl).Destroy) 2005 - return result 2006 - } 2007 - 2008 - func (c FfiConverterManySegmentsToSign) Read(reader io.Reader) ManySegmentsToSign { 2009 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 2010 - } 2011 - 2012 - func (c FfiConverterManySegmentsToSign) Lower(value ManySegmentsToSign) unsafe.Pointer { 2013 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 2014 - // because the pointer will be decremented immediately after this function returns, 2015 - // and someone will be left holding onto a non-locked pointer. 2016 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 2017 - return pointer 2018 - 2019 - } 2020 - 2021 - func (c FfiConverterManySegmentsToSign) Write(writer io.Writer, value ManySegmentsToSign) { 2022 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 2023 - } 2024 - 2025 - type FfiDestroyerManySegmentsToSign struct{} 2026 - 2027 - func (_ FfiDestroyerManySegmentsToSign) Destroy(value ManySegmentsToSign) { 2028 - if val, ok := value.(*ManySegmentsToSignImpl); ok { 2029 - val.Destroy() 2030 - } else { 2031 - panic("Expected *ManySegmentsToSignImpl") 2032 - } 2033 - } 2034 - 2035 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignMethod0 2036 - func iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignMethod0(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 2037 - handle := uint64(uniffiHandle) 2038 - uniffiObj, ok := FfiConverterManySegmentsToSignINSTANCE.handleMap.tryGet(handle) 2039 - if !ok { 2040 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 2041 - } 2042 - 2043 - res := 2044 - uniffiObj.Next() 2045 - 2046 - *uniffiOutReturn = FfiConverterOptionalSegmentToSignINSTANCE.Lower(res) 2047 - } 2048 - 2049 - var UniffiVTableCallbackInterfaceManySegmentsToSignINSTANCE = C.UniffiVTableCallbackInterfaceManySegmentsToSign{ 2050 - next: (C.UniffiCallbackInterfaceManySegmentsToSignMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignMethod0), 2051 - 2052 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignFree), 2053 - } 2054 - 2055 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignFree 2056 - func iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignFree(handle C.uint64_t) { 2057 - FfiConverterManySegmentsToSignINSTANCE.handleMap.remove(uint64(handle)) 2058 - } 2059 - 2060 - func (c FfiConverterManySegmentsToSign) register() { 2061 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_manysegmentstosign(&UniffiVTableCallbackInterfaceManySegmentsToSignINSTANCE) 2062 - } 2063 - 2064 - type ManyStreams interface { 2065 - // Get the next stream from the many streams 2066 - Next() *Stream 2067 - } 2068 - type ManyStreamsImpl struct { 2069 - ffiObject FfiObject 2070 - } 2071 - 2072 - // Get the next stream from the many streams 2073 - func (_self *ManyStreamsImpl) Next() *Stream { 2074 - _pointer := _self.ffiObject.incrementPointer("ManyStreams") 2075 - defer _self.ffiObject.decrementPointer() 2076 - return FfiConverterOptionalStreamINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 2077 - return GoRustBuffer{ 2078 - inner: C.uniffi_iroh_streamplace_fn_method_manystreams_next( 2079 - _pointer, _uniffiStatus), 2080 - } 2081 - })) 2082 - } 2083 - func (object *ManyStreamsImpl) Destroy() { 2084 - runtime.SetFinalizer(object, nil) 2085 - object.ffiObject.destroy() 2086 - } 2087 - 2088 - type FfiConverterManyStreams struct { 2089 - handleMap *concurrentHandleMap[ManyStreams] 2090 - } 2091 - 2092 - var FfiConverterManyStreamsINSTANCE = FfiConverterManyStreams{ 2093 - handleMap: newConcurrentHandleMap[ManyStreams](), 2094 - } 2095 - 2096 - func (c FfiConverterManyStreams) Lift(pointer unsafe.Pointer) ManyStreams { 2097 - result := &ManyStreamsImpl{ 2098 - newFfiObject( 2099 - pointer, 2100 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 2101 - return C.uniffi_iroh_streamplace_fn_clone_manystreams(pointer, status) 2102 - }, 2103 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 2104 - C.uniffi_iroh_streamplace_fn_free_manystreams(pointer, status) 2105 - }, 2106 - ), 2107 - } 2108 - runtime.SetFinalizer(result, (*ManyStreamsImpl).Destroy) 2109 - return result 2110 - } 2111 - 2112 - func (c FfiConverterManyStreams) Read(reader io.Reader) ManyStreams { 2113 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 2114 - } 2115 - 2116 - func (c FfiConverterManyStreams) Lower(value ManyStreams) unsafe.Pointer { 2117 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 2118 - // because the pointer will be decremented immediately after this function returns, 2119 - // and someone will be left holding onto a non-locked pointer. 2120 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 2121 - return pointer 2122 - 2123 - } 2124 - 2125 - func (c FfiConverterManyStreams) Write(writer io.Writer, value ManyStreams) { 2126 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 2127 - } 2128 - 2129 - type FfiDestroyerManyStreams struct{} 2130 - 2131 - func (_ FfiDestroyerManyStreams) Destroy(value ManyStreams) { 2132 - if val, ok := value.(*ManyStreamsImpl); ok { 2133 - val.Destroy() 2134 - } else { 2135 - panic("Expected *ManyStreamsImpl") 2136 - } 2137 - } 2138 - 2139 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsMethod0 2140 - func iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsMethod0(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 2141 - handle := uint64(uniffiHandle) 2142 - uniffiObj, ok := FfiConverterManyStreamsINSTANCE.handleMap.tryGet(handle) 2143 - if !ok { 2144 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 2145 - } 2146 - 2147 - res := 2148 - uniffiObj.Next() 2149 - 2150 - *uniffiOutReturn = FfiConverterOptionalStreamINSTANCE.Lower(res) 2151 - } 2152 - 2153 - var UniffiVTableCallbackInterfaceManyStreamsINSTANCE = C.UniffiVTableCallbackInterfaceManyStreams{ 2154 - next: (C.UniffiCallbackInterfaceManyStreamsMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsMethod0), 2155 - 2156 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsFree), 2157 - } 2158 - 2159 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsFree 2160 - func iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsFree(handle C.uint64_t) { 2161 - FfiConverterManyStreamsINSTANCE.handleMap.remove(uint64(handle)) 2162 - } 2163 - 2164 - func (c FfiConverterManyStreams) register() { 2165 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_manystreams(&UniffiVTableCallbackInterfaceManyStreamsINSTANCE) 2166 - } 2167 - 2168 - // Iroh-streamplace node that can send, forward or receive stream segments. 2169 - type NodeInterface interface { 2170 - // Add tickets for remote peers 2171 - AddTickets(peers []string) error 2172 - // Get a handle to the db to watch for changes locally or globally. 2173 - Db() *Db 2174 - // Join peers by their node tickets. 2175 - JoinPeers(peers []string) error 2176 - // Get this node's node ID. 2177 - NodeId() (*PublicKey, error) 2178 - // Get a handle to the write scope for this node. 2179 - // 2180 - // This is equivalent to calling `db.write(...)` with the secret key used to create the node. 2181 - NodeScope() *WriteScope 2182 - // Send a segment to all subscribers of the given stream. 2183 - SendSegment(key string, data []byte) error 2184 - // Shutdown the node, including the streaming system and the metadata db. 2185 - Shutdown() error 2186 - // Subscribe to updates for a given stream from a remote node. 2187 - Subscribe(key string, remoteId *PublicKey) error 2188 - // Get this node's ticket. 2189 - Ticket() (string, error) 2190 - // Unsubscribe from updates for a given stream from a remote node. 2191 - Unsubscribe(key string, remoteId *PublicKey) error 2192 - } 2193 - 2194 - // Iroh-streamplace node that can send, forward or receive stream segments. 2195 - type Node struct { 2196 - ffiObject FfiObject 2197 - } 2198 - 2199 - func NodeForwarder(config Config) (*Node, error) { 2200 - res, err := uniffiRustCallAsync[CreateError]( 2201 - FfiConverterCreateErrorINSTANCE, 2202 - // completeFn 2203 - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { 2204 - res := C.ffi_iroh_streamplace_rust_future_complete_pointer(handle, status) 2205 - return res 2206 - }, 2207 - // liftFn 2208 - func(ffi unsafe.Pointer) *Node { 2209 - return FfiConverterNodeINSTANCE.Lift(ffi) 2210 - }, 2211 - C.uniffi_iroh_streamplace_fn_constructor_node_forwarder(FfiConverterConfigINSTANCE.Lower(config)), 2212 - // pollFn 2213 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2214 - C.ffi_iroh_streamplace_rust_future_poll_pointer(handle, continuation, data) 2215 - }, 2216 - // freeFn 2217 - func(handle C.uint64_t) { 2218 - C.ffi_iroh_streamplace_rust_future_free_pointer(handle) 2219 - }, 2220 - ) 2221 - 2222 - if err == nil { 2223 - return res, nil 2224 - } 2225 - 2226 - return res, err 2227 - } 2228 - 2229 - func NodeReceiver(config Config, handler DataHandler) (*Node, error) { 2230 - res, err := uniffiRustCallAsync[CreateError]( 2231 - FfiConverterCreateErrorINSTANCE, 2232 - // completeFn 2233 - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { 2234 - res := C.ffi_iroh_streamplace_rust_future_complete_pointer(handle, status) 2235 - return res 2236 - }, 2237 - // liftFn 2238 - func(ffi unsafe.Pointer) *Node { 2239 - return FfiConverterNodeINSTANCE.Lift(ffi) 2240 - }, 2241 - C.uniffi_iroh_streamplace_fn_constructor_node_receiver(FfiConverterConfigINSTANCE.Lower(config), FfiConverterDataHandlerINSTANCE.Lower(handler)), 2242 - // pollFn 2243 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2244 - C.ffi_iroh_streamplace_rust_future_poll_pointer(handle, continuation, data) 2245 - }, 2246 - // freeFn 2247 - func(handle C.uint64_t) { 2248 - C.ffi_iroh_streamplace_rust_future_free_pointer(handle) 2249 - }, 2250 - ) 2251 - 2252 - if err == nil { 2253 - return res, nil 2254 - } 2255 - 2256 - return res, err 2257 - } 2258 - 2259 - // Create a new streamplace client node. 2260 - func NodeSender(config Config) (*Node, error) { 2261 - res, err := uniffiRustCallAsync[CreateError]( 2262 - FfiConverterCreateErrorINSTANCE, 2263 - // completeFn 2264 - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { 2265 - res := C.ffi_iroh_streamplace_rust_future_complete_pointer(handle, status) 2266 - return res 2267 - }, 2268 - // liftFn 2269 - func(ffi unsafe.Pointer) *Node { 2270 - return FfiConverterNodeINSTANCE.Lift(ffi) 2271 - }, 2272 - C.uniffi_iroh_streamplace_fn_constructor_node_sender(FfiConverterConfigINSTANCE.Lower(config)), 2273 - // pollFn 2274 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2275 - C.ffi_iroh_streamplace_rust_future_poll_pointer(handle, continuation, data) 2276 - }, 2277 - // freeFn 2278 - func(handle C.uint64_t) { 2279 - C.ffi_iroh_streamplace_rust_future_free_pointer(handle) 2280 - }, 2281 - ) 2282 - 2283 - if err == nil { 2284 - return res, nil 2285 - } 2286 - 2287 - return res, err 2288 - } 2289 - 2290 - // Add tickets for remote peers 2291 - func (_self *Node) AddTickets(peers []string) error { 2292 - _pointer := _self.ffiObject.incrementPointer("*Node") 2293 - defer _self.ffiObject.decrementPointer() 2294 - _, err := uniffiRustCallAsync[JoinPeersError]( 2295 - FfiConverterJoinPeersErrorINSTANCE, 2296 - // completeFn 2297 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2298 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2299 - return struct{}{} 2300 - }, 2301 - // liftFn 2302 - func(_ struct{}) struct{} { return struct{}{} }, 2303 - C.uniffi_iroh_streamplace_fn_method_node_add_tickets( 2304 - _pointer, FfiConverterSequenceStringINSTANCE.Lower(peers)), 2305 - // pollFn 2306 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2307 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2308 - }, 2309 - // freeFn 2310 - func(handle C.uint64_t) { 2311 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2312 - }, 2313 - ) 2314 - 2315 - if err == nil { 2316 - return nil 2317 - } 2318 - 2319 - return err 2320 - } 2321 - 2322 - // Get a handle to the db to watch for changes locally or globally. 2323 - func (_self *Node) Db() *Db { 2324 - _pointer := _self.ffiObject.incrementPointer("*Node") 2325 - defer _self.ffiObject.decrementPointer() 2326 - return FfiConverterDbINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 2327 - return C.uniffi_iroh_streamplace_fn_method_node_db( 2328 - _pointer, _uniffiStatus) 2329 - })) 2330 - } 2331 - 2332 - // Join peers by their node tickets. 2333 - func (_self *Node) JoinPeers(peers []string) error { 2334 - _pointer := _self.ffiObject.incrementPointer("*Node") 2335 - defer _self.ffiObject.decrementPointer() 2336 - _, err := uniffiRustCallAsync[JoinPeersError]( 2337 - FfiConverterJoinPeersErrorINSTANCE, 2338 - // completeFn 2339 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2340 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2341 - return struct{}{} 2342 - }, 2343 - // liftFn 2344 - func(_ struct{}) struct{} { return struct{}{} }, 2345 - C.uniffi_iroh_streamplace_fn_method_node_join_peers( 2346 - _pointer, FfiConverterSequenceStringINSTANCE.Lower(peers)), 2347 - // pollFn 2348 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2349 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2350 - }, 2351 - // freeFn 2352 - func(handle C.uint64_t) { 2353 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2354 - }, 2355 - ) 2356 - 2357 - if err == nil { 2358 - return nil 2359 - } 2360 - 2361 - return err 2362 - } 2363 - 2364 - // Get this node's node ID. 2365 - func (_self *Node) NodeId() (*PublicKey, error) { 2366 - _pointer := _self.ffiObject.incrementPointer("*Node") 2367 - defer _self.ffiObject.decrementPointer() 2368 - res, err := uniffiRustCallAsync[PutError]( 2369 - FfiConverterPutErrorINSTANCE, 2370 - // completeFn 2371 - func(handle C.uint64_t, status *C.RustCallStatus) unsafe.Pointer { 2372 - res := C.ffi_iroh_streamplace_rust_future_complete_pointer(handle, status) 2373 - return res 2374 - }, 2375 - // liftFn 2376 - func(ffi unsafe.Pointer) *PublicKey { 2377 - return FfiConverterPublicKeyINSTANCE.Lift(ffi) 2378 - }, 2379 - C.uniffi_iroh_streamplace_fn_method_node_node_id( 2380 - _pointer), 2381 - // pollFn 2382 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2383 - C.ffi_iroh_streamplace_rust_future_poll_pointer(handle, continuation, data) 2384 - }, 2385 - // freeFn 2386 - func(handle C.uint64_t) { 2387 - C.ffi_iroh_streamplace_rust_future_free_pointer(handle) 2388 - }, 2389 - ) 2390 - 2391 - if err == nil { 2392 - return res, nil 2393 - } 2394 - 2395 - return res, err 2396 - } 2397 - 2398 - // Get a handle to the write scope for this node. 2399 - // 2400 - // This is equivalent to calling `db.write(...)` with the secret key used to create the node. 2401 - func (_self *Node) NodeScope() *WriteScope { 2402 - _pointer := _self.ffiObject.incrementPointer("*Node") 2403 - defer _self.ffiObject.decrementPointer() 2404 - return FfiConverterWriteScopeINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 2405 - return C.uniffi_iroh_streamplace_fn_method_node_node_scope( 2406 - _pointer, _uniffiStatus) 2407 - })) 2408 - } 2409 - 2410 - // Send a segment to all subscribers of the given stream. 2411 - func (_self *Node) SendSegment(key string, data []byte) error { 2412 - _pointer := _self.ffiObject.incrementPointer("*Node") 2413 - defer _self.ffiObject.decrementPointer() 2414 - _, err := uniffiRustCallAsync[PutError]( 2415 - FfiConverterPutErrorINSTANCE, 2416 - // completeFn 2417 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2418 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2419 - return struct{}{} 2420 - }, 2421 - // liftFn 2422 - func(_ struct{}) struct{} { return struct{}{} }, 2423 - C.uniffi_iroh_streamplace_fn_method_node_send_segment( 2424 - _pointer, FfiConverterStringINSTANCE.Lower(key), FfiConverterBytesINSTANCE.Lower(data)), 2425 - // pollFn 2426 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2427 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2428 - }, 2429 - // freeFn 2430 - func(handle C.uint64_t) { 2431 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2432 - }, 2433 - ) 2434 - 2435 - if err == nil { 2436 - return nil 2437 - } 2438 - 2439 - return err 2440 - } 2441 - 2442 - // Shutdown the node, including the streaming system and the metadata db. 2443 - func (_self *Node) Shutdown() error { 2444 - _pointer := _self.ffiObject.incrementPointer("*Node") 2445 - defer _self.ffiObject.decrementPointer() 2446 - _, err := uniffiRustCallAsync[ShutdownError]( 2447 - FfiConverterShutdownErrorINSTANCE, 2448 - // completeFn 2449 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2450 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2451 - return struct{}{} 2452 - }, 2453 - // liftFn 2454 - func(_ struct{}) struct{} { return struct{}{} }, 2455 - C.uniffi_iroh_streamplace_fn_method_node_shutdown( 2456 - _pointer), 2457 - // pollFn 2458 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2459 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2460 - }, 2461 - // freeFn 2462 - func(handle C.uint64_t) { 2463 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2464 - }, 2465 - ) 2466 - 2467 - if err == nil { 2468 - return nil 2469 - } 2470 - 2471 - return err 2472 - } 2473 - 2474 - // Subscribe to updates for a given stream from a remote node. 2475 - func (_self *Node) Subscribe(key string, remoteId *PublicKey) error { 2476 - _pointer := _self.ffiObject.incrementPointer("*Node") 2477 - defer _self.ffiObject.decrementPointer() 2478 - _, err := uniffiRustCallAsync[PutError]( 2479 - FfiConverterPutErrorINSTANCE, 2480 - // completeFn 2481 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2482 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2483 - return struct{}{} 2484 - }, 2485 - // liftFn 2486 - func(_ struct{}) struct{} { return struct{}{} }, 2487 - C.uniffi_iroh_streamplace_fn_method_node_subscribe( 2488 - _pointer, FfiConverterStringINSTANCE.Lower(key), FfiConverterPublicKeyINSTANCE.Lower(remoteId)), 2489 - // pollFn 2490 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2491 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2492 - }, 2493 - // freeFn 2494 - func(handle C.uint64_t) { 2495 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2496 - }, 2497 - ) 2498 - 2499 - if err == nil { 2500 - return nil 2501 - } 2502 - 2503 - return err 2504 - } 2505 - 2506 - // Get this node's ticket. 2507 - func (_self *Node) Ticket() (string, error) { 2508 - _pointer := _self.ffiObject.incrementPointer("*Node") 2509 - defer _self.ffiObject.decrementPointer() 2510 - res, err := uniffiRustCallAsync[PutError]( 2511 - FfiConverterPutErrorINSTANCE, 2512 - // completeFn 2513 - func(handle C.uint64_t, status *C.RustCallStatus) RustBufferI { 2514 - res := C.ffi_iroh_streamplace_rust_future_complete_rust_buffer(handle, status) 2515 - return GoRustBuffer{ 2516 - inner: res, 2517 - } 2518 - }, 2519 - // liftFn 2520 - func(ffi RustBufferI) string { 2521 - return FfiConverterStringINSTANCE.Lift(ffi) 2522 - }, 2523 - C.uniffi_iroh_streamplace_fn_method_node_ticket( 2524 - _pointer), 2525 - // pollFn 2526 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2527 - C.ffi_iroh_streamplace_rust_future_poll_rust_buffer(handle, continuation, data) 2528 - }, 2529 - // freeFn 2530 - func(handle C.uint64_t) { 2531 - C.ffi_iroh_streamplace_rust_future_free_rust_buffer(handle) 2532 - }, 2533 - ) 2534 - 2535 - if err == nil { 2536 - return res, nil 2537 - } 2538 - 2539 - return res, err 2540 - } 2541 - 2542 - // Unsubscribe from updates for a given stream from a remote node. 2543 - func (_self *Node) Unsubscribe(key string, remoteId *PublicKey) error { 2544 - _pointer := _self.ffiObject.incrementPointer("*Node") 2545 - defer _self.ffiObject.decrementPointer() 2546 - _, err := uniffiRustCallAsync[PutError]( 2547 - FfiConverterPutErrorINSTANCE, 2548 - // completeFn 2549 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 2550 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 2551 - return struct{}{} 2552 - }, 2553 - // liftFn 2554 - func(_ struct{}) struct{} { return struct{}{} }, 2555 - C.uniffi_iroh_streamplace_fn_method_node_unsubscribe( 2556 - _pointer, FfiConverterStringINSTANCE.Lower(key), FfiConverterPublicKeyINSTANCE.Lower(remoteId)), 2557 - // pollFn 2558 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 2559 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 2560 - }, 2561 - // freeFn 2562 - func(handle C.uint64_t) { 2563 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 2564 - }, 2565 - ) 2566 - 2567 - if err == nil { 2568 - return nil 2569 - } 2570 - 2571 - return err 2572 - } 2573 - func (object *Node) Destroy() { 2574 - runtime.SetFinalizer(object, nil) 2575 - object.ffiObject.destroy() 2576 - } 2577 - 2578 - type FfiConverterNode struct{} 2579 - 2580 - var FfiConverterNodeINSTANCE = FfiConverterNode{} 2581 - 2582 - func (c FfiConverterNode) Lift(pointer unsafe.Pointer) *Node { 2583 - result := &Node{ 2584 - newFfiObject( 2585 - pointer, 2586 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 2587 - return C.uniffi_iroh_streamplace_fn_clone_node(pointer, status) 2588 - }, 2589 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 2590 - C.uniffi_iroh_streamplace_fn_free_node(pointer, status) 2591 - }, 2592 - ), 2593 - } 2594 - runtime.SetFinalizer(result, (*Node).Destroy) 2595 - return result 2596 - } 2597 - 2598 - func (c FfiConverterNode) Read(reader io.Reader) *Node { 2599 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 2600 - } 2601 - 2602 - func (c FfiConverterNode) Lower(value *Node) unsafe.Pointer { 2603 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 2604 - // because the pointer will be decremented immediately after this function returns, 2605 - // and someone will be left holding onto a non-locked pointer. 2606 - pointer := value.ffiObject.incrementPointer("*Node") 2607 - defer value.ffiObject.decrementPointer() 2608 - return pointer 2609 - 2610 - } 2611 - 2612 - func (c FfiConverterNode) Write(writer io.Writer, value *Node) { 2613 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 2614 - } 2615 - 2616 - type FfiDestroyerNode struct{} 2617 - 2618 - func (_ FfiDestroyerNode) Destroy(value *Node) { 2619 - value.Destroy() 2620 - } 2621 - 2622 // A peer and it's addressing information. 2623 type NodeAddrInterface interface { 2624 // Get the direct addresses of this peer. ··· 2876 value.Destroy() 2877 } 2878 2879 - type SegmentToSign interface { 2880 - UnsignedSegStream() Stream 2881 - ManifestId() string 2882 - Cert() []byte 2883 - OutputSegStream() Stream 2884 - Close() 2885 - } 2886 - type SegmentToSignImpl struct { 2887 - ffiObject FfiObject 2888 - } 2889 - 2890 - func (_self *SegmentToSignImpl) UnsignedSegStream() Stream { 2891 - _pointer := _self.ffiObject.incrementPointer("SegmentToSign") 2892 - defer _self.ffiObject.decrementPointer() 2893 - return FfiConverterStreamINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 2894 - return C.uniffi_iroh_streamplace_fn_method_segmenttosign_unsigned_seg_stream( 2895 - _pointer, _uniffiStatus) 2896 - })) 2897 - } 2898 - 2899 - func (_self *SegmentToSignImpl) ManifestId() string { 2900 - _pointer := _self.ffiObject.incrementPointer("SegmentToSign") 2901 - defer _self.ffiObject.decrementPointer() 2902 - return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 2903 - return GoRustBuffer{ 2904 - inner: C.uniffi_iroh_streamplace_fn_method_segmenttosign_manifest_id( 2905 - _pointer, _uniffiStatus), 2906 - } 2907 - })) 2908 - } 2909 - 2910 - func (_self *SegmentToSignImpl) Cert() []byte { 2911 - _pointer := _self.ffiObject.incrementPointer("SegmentToSign") 2912 - defer _self.ffiObject.decrementPointer() 2913 - return FfiConverterBytesINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 2914 - return GoRustBuffer{ 2915 - inner: C.uniffi_iroh_streamplace_fn_method_segmenttosign_cert( 2916 - _pointer, _uniffiStatus), 2917 - } 2918 - })) 2919 - } 2920 - 2921 - func (_self *SegmentToSignImpl) OutputSegStream() Stream { 2922 - _pointer := _self.ffiObject.incrementPointer("SegmentToSign") 2923 - defer _self.ffiObject.decrementPointer() 2924 - return FfiConverterStreamINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) unsafe.Pointer { 2925 - return C.uniffi_iroh_streamplace_fn_method_segmenttosign_output_seg_stream( 2926 - _pointer, _uniffiStatus) 2927 - })) 2928 - } 2929 - 2930 - func (_self *SegmentToSignImpl) Close() { 2931 - _pointer := _self.ffiObject.incrementPointer("SegmentToSign") 2932 - defer _self.ffiObject.decrementPointer() 2933 - rustCall(func(_uniffiStatus *C.RustCallStatus) bool { 2934 - C.uniffi_iroh_streamplace_fn_method_segmenttosign_close( 2935 - _pointer, _uniffiStatus) 2936 - return false 2937 - }) 2938 - } 2939 - func (object *SegmentToSignImpl) Destroy() { 2940 - runtime.SetFinalizer(object, nil) 2941 - object.ffiObject.destroy() 2942 - } 2943 - 2944 - type FfiConverterSegmentToSign struct { 2945 - handleMap *concurrentHandleMap[SegmentToSign] 2946 - } 2947 - 2948 - var FfiConverterSegmentToSignINSTANCE = FfiConverterSegmentToSign{ 2949 - handleMap: newConcurrentHandleMap[SegmentToSign](), 2950 - } 2951 - 2952 - func (c FfiConverterSegmentToSign) Lift(pointer unsafe.Pointer) SegmentToSign { 2953 - result := &SegmentToSignImpl{ 2954 - newFfiObject( 2955 - pointer, 2956 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 2957 - return C.uniffi_iroh_streamplace_fn_clone_segmenttosign(pointer, status) 2958 - }, 2959 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 2960 - C.uniffi_iroh_streamplace_fn_free_segmenttosign(pointer, status) 2961 - }, 2962 - ), 2963 - } 2964 - runtime.SetFinalizer(result, (*SegmentToSignImpl).Destroy) 2965 - return result 2966 - } 2967 - 2968 - func (c FfiConverterSegmentToSign) Read(reader io.Reader) SegmentToSign { 2969 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 2970 - } 2971 - 2972 - func (c FfiConverterSegmentToSign) Lower(value SegmentToSign) unsafe.Pointer { 2973 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 2974 - // because the pointer will be decremented immediately after this function returns, 2975 - // and someone will be left holding onto a non-locked pointer. 2976 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 2977 - return pointer 2978 - 2979 - } 2980 - 2981 - func (c FfiConverterSegmentToSign) Write(writer io.Writer, value SegmentToSign) { 2982 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 2983 - } 2984 - 2985 - type FfiDestroyerSegmentToSign struct{} 2986 - 2987 - func (_ FfiDestroyerSegmentToSign) Destroy(value SegmentToSign) { 2988 - if val, ok := value.(*SegmentToSignImpl); ok { 2989 - val.Destroy() 2990 - } else { 2991 - panic("Expected *SegmentToSignImpl") 2992 - } 2993 - } 2994 - 2995 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod0 2996 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod0(uniffiHandle C.uint64_t, uniffiOutReturn *unsafe.Pointer, callStatus *C.RustCallStatus) { 2997 - handle := uint64(uniffiHandle) 2998 - uniffiObj, ok := FfiConverterSegmentToSignINSTANCE.handleMap.tryGet(handle) 2999 - if !ok { 3000 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3001 - } 3002 - 3003 - res := 3004 - uniffiObj.UnsignedSegStream() 3005 - 3006 - *uniffiOutReturn = FfiConverterStreamINSTANCE.Lower(res) 3007 - } 3008 - 3009 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod1 3010 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod1(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 3011 - handle := uint64(uniffiHandle) 3012 - uniffiObj, ok := FfiConverterSegmentToSignINSTANCE.handleMap.tryGet(handle) 3013 - if !ok { 3014 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3015 - } 3016 - 3017 - res := 3018 - uniffiObj.ManifestId() 3019 - 3020 - *uniffiOutReturn = FfiConverterStringINSTANCE.Lower(res) 3021 - } 3022 - 3023 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod2 3024 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod2(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 3025 - handle := uint64(uniffiHandle) 3026 - uniffiObj, ok := FfiConverterSegmentToSignINSTANCE.handleMap.tryGet(handle) 3027 - if !ok { 3028 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3029 - } 3030 - 3031 - res := 3032 - uniffiObj.Cert() 3033 - 3034 - *uniffiOutReturn = FfiConverterBytesINSTANCE.Lower(res) 3035 - } 3036 - 3037 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod3 3038 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod3(uniffiHandle C.uint64_t, uniffiOutReturn *unsafe.Pointer, callStatus *C.RustCallStatus) { 3039 - handle := uint64(uniffiHandle) 3040 - uniffiObj, ok := FfiConverterSegmentToSignINSTANCE.handleMap.tryGet(handle) 3041 - if !ok { 3042 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3043 - } 3044 - 3045 - res := 3046 - uniffiObj.OutputSegStream() 3047 - 3048 - *uniffiOutReturn = FfiConverterStreamINSTANCE.Lower(res) 3049 - } 3050 - 3051 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod4 3052 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod4(uniffiHandle C.uint64_t, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { 3053 - handle := uint64(uniffiHandle) 3054 - uniffiObj, ok := FfiConverterSegmentToSignINSTANCE.handleMap.tryGet(handle) 3055 - if !ok { 3056 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3057 - } 3058 - 3059 - uniffiObj.Close() 3060 - 3061 - } 3062 - 3063 - var UniffiVTableCallbackInterfaceSegmentToSignINSTANCE = C.UniffiVTableCallbackInterfaceSegmentToSign{ 3064 - unsignedSegStream: (C.UniffiCallbackInterfaceSegmentToSignMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod0), 3065 - manifestId: (C.UniffiCallbackInterfaceSegmentToSignMethod1)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod1), 3066 - cert: (C.UniffiCallbackInterfaceSegmentToSignMethod2)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod2), 3067 - outputSegStream: (C.UniffiCallbackInterfaceSegmentToSignMethod3)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod3), 3068 - close: (C.UniffiCallbackInterfaceSegmentToSignMethod4)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod4), 3069 - 3070 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignFree), 3071 - } 3072 - 3073 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignFree 3074 - func iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignFree(handle C.uint64_t) { 3075 - FfiConverterSegmentToSignINSTANCE.handleMap.remove(uint64(handle)) 3076 - } 3077 - 3078 - func (c FfiConverterSegmentToSign) register() { 3079 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_segmenttosign(&UniffiVTableCallbackInterfaceSegmentToSignINSTANCE) 3080 - } 3081 - 3082 // A wrapper for an iroh endpoint that works basically as a socket for streams. 3083 type SocketInterface interface { 3084 - // Accept an incoming connection and return a [`Stream2`]. 3085 - Accept() (*Stream2, error) 3086 // Get the ALPN for this socket. 3087 Alpn() []byte 3088 Close() 3089 - // Connect to a peer at the given [`NodeAddr`] and return a [`Stream2`]. 3090 - Connect(addr *NodeAddr) (*Stream2, error) 3091 Online() 3092 Ticket() string 3093 } 3094 ··· 3128 return res, err 3129 } 3130 3131 - // Accept an incoming connection and return a [`Stream2`]. 3132 - func (_self *Socket) Accept() (*Stream2, error) { 3133 _pointer := _self.ffiObject.incrementPointer("*Socket") 3134 defer _self.ffiObject.decrementPointer() 3135 res, err := uniffiRustCallAsync[AcceptError]( ··· 3140 return res 3141 }, 3142 // liftFn 3143 - func(ffi unsafe.Pointer) *Stream2 { 3144 - return FfiConverterStream2INSTANCE.Lift(ffi) 3145 }, 3146 C.uniffi_iroh_streamplace_fn_method_socket_accept( 3147 _pointer), ··· 3174 })) 3175 } 3176 3177 func (_self *Socket) Close() { 3178 _pointer := _self.ffiObject.incrementPointer("*Socket") 3179 defer _self.ffiObject.decrementPointer() ··· 3200 3201 } 3202 3203 - // Connect to a peer at the given [`NodeAddr`] and return a [`Stream2`]. 3204 - func (_self *Socket) Connect(addr *NodeAddr) (*Stream2, error) { 3205 _pointer := _self.ffiObject.incrementPointer("*Socket") 3206 defer _self.ffiObject.decrementPointer() 3207 res, err := uniffiRustCallAsync[ConnectError]( ··· 3212 return res 3213 }, 3214 // liftFn 3215 - func(ffi unsafe.Pointer) *Stream2 { 3216 - return FfiConverterStream2INSTANCE.Lift(ffi) 3217 }, 3218 C.uniffi_iroh_streamplace_fn_method_socket_connect( 3219 _pointer, FfiConverterNodeAddrINSTANCE.Lower(addr)), ··· 3234 return res, err 3235 } 3236 3237 func (_self *Socket) Online() { 3238 _pointer := _self.ffiObject.incrementPointer("*Socket") 3239 defer _self.ffiObject.decrementPointer() ··· 3260 3261 } 3262 3263 func (_self *Socket) Ticket() string { 3264 _pointer := _self.ffiObject.incrementPointer("*Socket") 3265 defer _self.ffiObject.decrementPointer() ··· 3319 value.Destroy() 3320 } 3321 3322 - // This allows for a callback stream over the Uniffi interface. 3323 - // Implement these stream functions in the foreign language 3324 - // and this will provide Rust Stream trait implementations 3325 - // This is necessary since the Rust traits cannot be implemented directly 3326 - // as uniffi callbacks 3327 - type Stream interface { 3328 - // Read a stream of bytes from the stream 3329 - ReadStream(length uint64) ([]byte, error) 3330 - // Seek to a position in the stream 3331 - SeekStream(pos int64, mode uint64) (uint64, error) 3332 - // Write a stream of bytes to the stream 3333 - WriteStream(data []byte) (uint64, error) 3334 - } 3335 - 3336 - // This allows for a callback stream over the Uniffi interface. 3337 - // Implement these stream functions in the foreign language 3338 - // and this will provide Rust Stream trait implementations 3339 - // This is necessary since the Rust traits cannot be implemented directly 3340 - // as uniffi callbacks 3341 - type StreamImpl struct { 3342 - ffiObject FfiObject 3343 - } 3344 - 3345 - // Read a stream of bytes from the stream 3346 - func (_self *StreamImpl) ReadStream(length uint64) ([]byte, error) { 3347 - _pointer := _self.ffiObject.incrementPointer("Stream") 3348 - defer _self.ffiObject.decrementPointer() 3349 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { 3350 - return GoRustBuffer{ 3351 - inner: C.uniffi_iroh_streamplace_fn_method_stream_read_stream( 3352 - _pointer, FfiConverterUint64INSTANCE.Lower(length), _uniffiStatus), 3353 - } 3354 - }) 3355 - if _uniffiErr != nil { 3356 - var _uniffiDefaultValue []byte 3357 - return _uniffiDefaultValue, _uniffiErr 3358 - } else { 3359 - return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil 3360 - } 3361 - } 3362 - 3363 - // Seek to a position in the stream 3364 - func (_self *StreamImpl) SeekStream(pos int64, mode uint64) (uint64, error) { 3365 - _pointer := _self.ffiObject.incrementPointer("Stream") 3366 - defer _self.ffiObject.decrementPointer() 3367 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { 3368 - return C.uniffi_iroh_streamplace_fn_method_stream_seek_stream( 3369 - _pointer, FfiConverterInt64INSTANCE.Lower(pos), FfiConverterUint64INSTANCE.Lower(mode), _uniffiStatus) 3370 - }) 3371 - if _uniffiErr != nil { 3372 - var _uniffiDefaultValue uint64 3373 - return _uniffiDefaultValue, _uniffiErr 3374 - } else { 3375 - return FfiConverterUint64INSTANCE.Lift(_uniffiRV), nil 3376 - } 3377 - } 3378 - 3379 - // Write a stream of bytes to the stream 3380 - func (_self *StreamImpl) WriteStream(data []byte) (uint64, error) { 3381 - _pointer := _self.ffiObject.incrementPointer("Stream") 3382 - defer _self.ffiObject.decrementPointer() 3383 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { 3384 - return C.uniffi_iroh_streamplace_fn_method_stream_write_stream( 3385 - _pointer, FfiConverterBytesINSTANCE.Lower(data), _uniffiStatus) 3386 - }) 3387 - if _uniffiErr != nil { 3388 - var _uniffiDefaultValue uint64 3389 - return _uniffiDefaultValue, _uniffiErr 3390 - } else { 3391 - return FfiConverterUint64INSTANCE.Lift(_uniffiRV), nil 3392 - } 3393 - } 3394 - func (object *StreamImpl) Destroy() { 3395 - runtime.SetFinalizer(object, nil) 3396 - object.ffiObject.destroy() 3397 - } 3398 - 3399 - type FfiConverterStream struct { 3400 - handleMap *concurrentHandleMap[Stream] 3401 - } 3402 - 3403 - var FfiConverterStreamINSTANCE = FfiConverterStream{ 3404 - handleMap: newConcurrentHandleMap[Stream](), 3405 - } 3406 - 3407 - func (c FfiConverterStream) Lift(pointer unsafe.Pointer) Stream { 3408 - result := &StreamImpl{ 3409 - newFfiObject( 3410 - pointer, 3411 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 3412 - return C.uniffi_iroh_streamplace_fn_clone_stream(pointer, status) 3413 - }, 3414 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 3415 - C.uniffi_iroh_streamplace_fn_free_stream(pointer, status) 3416 - }, 3417 - ), 3418 - } 3419 - runtime.SetFinalizer(result, (*StreamImpl).Destroy) 3420 - return result 3421 - } 3422 - 3423 - func (c FfiConverterStream) Read(reader io.Reader) Stream { 3424 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 3425 - } 3426 - 3427 - func (c FfiConverterStream) Lower(value Stream) unsafe.Pointer { 3428 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 3429 - // because the pointer will be decremented immediately after this function returns, 3430 - // and someone will be left holding onto a non-locked pointer. 3431 - pointer := unsafe.Pointer(uintptr(c.handleMap.insert(value))) 3432 - return pointer 3433 - 3434 - } 3435 - 3436 - func (c FfiConverterStream) Write(writer io.Writer, value Stream) { 3437 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 3438 - } 3439 - 3440 - type FfiDestroyerStream struct{} 3441 - 3442 - func (_ FfiDestroyerStream) Destroy(value Stream) { 3443 - if val, ok := value.(*StreamImpl); ok { 3444 - val.Destroy() 3445 - } else { 3446 - panic("Expected *StreamImpl") 3447 - } 3448 - } 3449 - 3450 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod0 3451 - func iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod0(uniffiHandle C.uint64_t, length C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { 3452 - handle := uint64(uniffiHandle) 3453 - uniffiObj, ok := FfiConverterStreamINSTANCE.handleMap.tryGet(handle) 3454 - if !ok { 3455 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3456 - } 3457 - 3458 - res, err := 3459 - uniffiObj.ReadStream( 3460 - FfiConverterUint64INSTANCE.Lift(length), 3461 - ) 3462 - 3463 - if err != nil { 3464 - var actualError *SpError 3465 - if errors.As(err, &actualError) { 3466 - *callStatus = C.RustCallStatus{ 3467 - code: C.int8_t(uniffiCallbackResultError), 3468 - errorBuf: FfiConverterSpErrorINSTANCE.Lower(actualError), 3469 - } 3470 - } else { 3471 - *callStatus = C.RustCallStatus{ 3472 - code: C.int8_t(uniffiCallbackUnexpectedResultError), 3473 - } 3474 - } 3475 - return 3476 - } 3477 - 3478 - *uniffiOutReturn = FfiConverterBytesINSTANCE.Lower(res) 3479 - } 3480 - 3481 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod1 3482 - func iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod1(uniffiHandle C.uint64_t, pos C.int64_t, mode C.uint64_t, uniffiOutReturn *C.uint64_t, callStatus *C.RustCallStatus) { 3483 - handle := uint64(uniffiHandle) 3484 - uniffiObj, ok := FfiConverterStreamINSTANCE.handleMap.tryGet(handle) 3485 - if !ok { 3486 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3487 - } 3488 - 3489 - res, err := 3490 - uniffiObj.SeekStream( 3491 - FfiConverterInt64INSTANCE.Lift(pos), 3492 - FfiConverterUint64INSTANCE.Lift(mode), 3493 - ) 3494 - 3495 - if err != nil { 3496 - var actualError *SpError 3497 - if errors.As(err, &actualError) { 3498 - *callStatus = C.RustCallStatus{ 3499 - code: C.int8_t(uniffiCallbackResultError), 3500 - errorBuf: FfiConverterSpErrorINSTANCE.Lower(actualError), 3501 - } 3502 - } else { 3503 - *callStatus = C.RustCallStatus{ 3504 - code: C.int8_t(uniffiCallbackUnexpectedResultError), 3505 - } 3506 - } 3507 - return 3508 - } 3509 - 3510 - *uniffiOutReturn = FfiConverterUint64INSTANCE.Lower(res) 3511 - } 3512 - 3513 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod2 3514 - func iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod2(uniffiHandle C.uint64_t, data C.RustBuffer, uniffiOutReturn *C.uint64_t, callStatus *C.RustCallStatus) { 3515 - handle := uint64(uniffiHandle) 3516 - uniffiObj, ok := FfiConverterStreamINSTANCE.handleMap.tryGet(handle) 3517 - if !ok { 3518 - panic(fmt.Errorf("no callback in handle map: %d", handle)) 3519 - } 3520 - 3521 - res, err := 3522 - uniffiObj.WriteStream( 3523 - FfiConverterBytesINSTANCE.Lift(GoRustBuffer{ 3524 - inner: data, 3525 - }), 3526 - ) 3527 - 3528 - if err != nil { 3529 - var actualError *SpError 3530 - if errors.As(err, &actualError) { 3531 - *callStatus = C.RustCallStatus{ 3532 - code: C.int8_t(uniffiCallbackResultError), 3533 - errorBuf: FfiConverterSpErrorINSTANCE.Lower(actualError), 3534 - } 3535 - } else { 3536 - *callStatus = C.RustCallStatus{ 3537 - code: C.int8_t(uniffiCallbackUnexpectedResultError), 3538 - } 3539 - } 3540 - return 3541 - } 3542 - 3543 - *uniffiOutReturn = FfiConverterUint64INSTANCE.Lower(res) 3544 - } 3545 - 3546 - var UniffiVTableCallbackInterfaceStreamINSTANCE = C.UniffiVTableCallbackInterfaceStream{ 3547 - readStream: (C.UniffiCallbackInterfaceStreamMethod0)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod0), 3548 - seekStream: (C.UniffiCallbackInterfaceStreamMethod1)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod1), 3549 - writeStream: (C.UniffiCallbackInterfaceStreamMethod2)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod2), 3550 - 3551 - uniffiFree: (C.UniffiCallbackInterfaceFree)(C.iroh_streamplace_cgo_dispatchCallbackInterfaceStreamFree), 3552 - } 3553 - 3554 - //export iroh_streamplace_cgo_dispatchCallbackInterfaceStreamFree 3555 - func iroh_streamplace_cgo_dispatchCallbackInterfaceStreamFree(handle C.uint64_t) { 3556 - FfiConverterStreamINSTANCE.handleMap.remove(uint64(handle)) 3557 - } 3558 - 3559 - func (c FfiConverterStream) register() { 3560 - C.uniffi_iroh_streamplace_fn_init_callback_vtable_stream(&UniffiVTableCallbackInterfaceStreamINSTANCE) 3561 - } 3562 - 3563 - type Stream2Interface interface { 3564 Close() 3565 CloseRead() error 3566 CloseWrite() error 3567 Closed() 3568 Read(n uint64) ([]byte, error) 3569 Write(buf []byte) (uint32, error) 3570 WriteAll(buf []byte) error 3571 } 3572 - type Stream2 struct { 3573 ffiObject FfiObject 3574 } 3575 3576 - func (_self *Stream2) Close() { 3577 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3578 defer _self.ffiObject.decrementPointer() 3579 rustCall(func(_uniffiStatus *C.RustCallStatus) bool { 3580 - C.uniffi_iroh_streamplace_fn_method_stream2_close( 3581 _pointer, _uniffiStatus) 3582 return false 3583 }) 3584 } 3585 3586 - func (_self *Stream2) CloseRead() error { 3587 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3588 defer _self.ffiObject.decrementPointer() 3589 _, err := uniffiRustCallAsync[ReadError]( 3590 FfiConverterReadErrorINSTANCE, ··· 3595 }, 3596 // liftFn 3597 func(_ struct{}) struct{} { return struct{}{} }, 3598 - C.uniffi_iroh_streamplace_fn_method_stream2_close_read( 3599 _pointer), 3600 // pollFn 3601 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3614 return err 3615 } 3616 3617 - func (_self *Stream2) CloseWrite() error { 3618 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3619 defer _self.ffiObject.decrementPointer() 3620 _, err := uniffiRustCallAsync[WriteError2]( 3621 FfiConverterWriteError2INSTANCE, ··· 3626 }, 3627 // liftFn 3628 func(_ struct{}) struct{} { return struct{}{} }, 3629 - C.uniffi_iroh_streamplace_fn_method_stream2_close_write( 3630 _pointer), 3631 // pollFn 3632 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3645 return err 3646 } 3647 3648 - func (_self *Stream2) Closed() { 3649 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3650 defer _self.ffiObject.decrementPointer() 3651 uniffiRustCallAsync[error]( 3652 nil, ··· 3657 }, 3658 // liftFn 3659 func(_ struct{}) struct{} { return struct{}{} }, 3660 - C.uniffi_iroh_streamplace_fn_method_stream2_closed( 3661 _pointer), 3662 // pollFn 3663 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3671 3672 } 3673 3674 - func (_self *Stream2) Read(n uint64) ([]byte, error) { 3675 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3676 defer _self.ffiObject.decrementPointer() 3677 res, err := uniffiRustCallAsync[ReadError]( 3678 FfiConverterReadErrorINSTANCE, ··· 3687 func(ffi RustBufferI) []byte { 3688 return FfiConverterBytesINSTANCE.Lift(ffi) 3689 }, 3690 - C.uniffi_iroh_streamplace_fn_method_stream2_read( 3691 _pointer, FfiConverterUint64INSTANCE.Lower(n)), 3692 // pollFn 3693 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3706 return res, err 3707 } 3708 3709 - func (_self *Stream2) Write(buf []byte) (uint32, error) { 3710 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3711 defer _self.ffiObject.decrementPointer() 3712 res, err := uniffiRustCallAsync[WriteError2]( 3713 FfiConverterWriteError2INSTANCE, ··· 3720 func(ffi C.uint32_t) uint32 { 3721 return FfiConverterUint32INSTANCE.Lift(ffi) 3722 }, 3723 - C.uniffi_iroh_streamplace_fn_method_stream2_write( 3724 _pointer, FfiConverterBytesINSTANCE.Lower(buf)), 3725 // pollFn 3726 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3739 return res, err 3740 } 3741 3742 - func (_self *Stream2) WriteAll(buf []byte) error { 3743 - _pointer := _self.ffiObject.incrementPointer("*Stream2") 3744 defer _self.ffiObject.decrementPointer() 3745 _, err := uniffiRustCallAsync[WriteError2]( 3746 FfiConverterWriteError2INSTANCE, ··· 3751 }, 3752 // liftFn 3753 func(_ struct{}) struct{} { return struct{}{} }, 3754 - C.uniffi_iroh_streamplace_fn_method_stream2_write_all( 3755 _pointer, FfiConverterBytesINSTANCE.Lower(buf)), 3756 // pollFn 3757 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 3769 3770 return err 3771 } 3772 - func (object *Stream2) Destroy() { 3773 - runtime.SetFinalizer(object, nil) 3774 - object.ffiObject.destroy() 3775 - } 3776 - 3777 - type FfiConverterStream2 struct{} 3778 - 3779 - var FfiConverterStream2INSTANCE = FfiConverterStream2{} 3780 - 3781 - func (c FfiConverterStream2) Lift(pointer unsafe.Pointer) *Stream2 { 3782 - result := &Stream2{ 3783 - newFfiObject( 3784 - pointer, 3785 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 3786 - return C.uniffi_iroh_streamplace_fn_clone_stream2(pointer, status) 3787 - }, 3788 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 3789 - C.uniffi_iroh_streamplace_fn_free_stream2(pointer, status) 3790 - }, 3791 - ), 3792 - } 3793 - runtime.SetFinalizer(result, (*Stream2).Destroy) 3794 - return result 3795 - } 3796 - 3797 - func (c FfiConverterStream2) Read(reader io.Reader) *Stream2 { 3798 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 3799 - } 3800 - 3801 - func (c FfiConverterStream2) Lower(value *Stream2) unsafe.Pointer { 3802 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 3803 - // because the pointer will be decremented immediately after this function returns, 3804 - // and someone will be left holding onto a non-locked pointer. 3805 - pointer := value.ffiObject.incrementPointer("*Stream2") 3806 - defer value.ffiObject.decrementPointer() 3807 - return pointer 3808 - 3809 - } 3810 - 3811 - func (c FfiConverterStream2) Write(writer io.Writer, value *Stream2) { 3812 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 3813 - } 3814 - 3815 - type FfiDestroyerStream2 struct{} 3816 - 3817 - func (_ FfiDestroyerStream2) Destroy(value *Stream2) { 3818 - value.Destroy() 3819 - } 3820 - 3821 - // A response to a subscribe request. 3822 - // 3823 - // This can be used as a stream of [`SubscribeItem`]s. 3824 - type SubscribeResponseInterface interface { 3825 - NextRaw() (*SubscribeItem, error) 3826 - } 3827 - 3828 - // A response to a subscribe request. 3829 - // 3830 - // This can be used as a stream of [`SubscribeItem`]s. 3831 - type SubscribeResponse struct { 3832 - ffiObject FfiObject 3833 - } 3834 - 3835 - func (_self *SubscribeResponse) NextRaw() (*SubscribeItem, error) { 3836 - _pointer := _self.ffiObject.incrementPointer("*SubscribeResponse") 3837 - defer _self.ffiObject.decrementPointer() 3838 - res, err := uniffiRustCallAsync[SubscribeNextError]( 3839 - FfiConverterSubscribeNextErrorINSTANCE, 3840 - // completeFn 3841 - func(handle C.uint64_t, status *C.RustCallStatus) RustBufferI { 3842 - res := C.ffi_iroh_streamplace_rust_future_complete_rust_buffer(handle, status) 3843 - return GoRustBuffer{ 3844 - inner: res, 3845 - } 3846 - }, 3847 - // liftFn 3848 - func(ffi RustBufferI) *SubscribeItem { 3849 - return FfiConverterOptionalSubscribeItemINSTANCE.Lift(ffi) 3850 - }, 3851 - C.uniffi_iroh_streamplace_fn_method_subscriberesponse_next_raw( 3852 - _pointer), 3853 - // pollFn 3854 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 3855 - C.ffi_iroh_streamplace_rust_future_poll_rust_buffer(handle, continuation, data) 3856 - }, 3857 - // freeFn 3858 - func(handle C.uint64_t) { 3859 - C.ffi_iroh_streamplace_rust_future_free_rust_buffer(handle) 3860 - }, 3861 - ) 3862 - 3863 - if err == nil { 3864 - return res, nil 3865 - } 3866 - 3867 - return res, err 3868 - } 3869 - 3870 - func (_self *SubscribeResponse) DebugString() string { 3871 - _pointer := _self.ffiObject.incrementPointer("*SubscribeResponse") 3872 - defer _self.ffiObject.decrementPointer() 3873 - return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 3874 - return GoRustBuffer{ 3875 - inner: C.uniffi_iroh_streamplace_fn_method_subscriberesponse_uniffi_trait_debug( 3876 - _pointer, _uniffiStatus), 3877 - } 3878 - })) 3879 - } 3880 - 3881 - func (object *SubscribeResponse) Destroy() { 3882 runtime.SetFinalizer(object, nil) 3883 object.ffiObject.destroy() 3884 } 3885 3886 - type FfiConverterSubscribeResponse struct{} 3887 3888 - var FfiConverterSubscribeResponseINSTANCE = FfiConverterSubscribeResponse{} 3889 3890 - func (c FfiConverterSubscribeResponse) Lift(pointer unsafe.Pointer) *SubscribeResponse { 3891 - result := &SubscribeResponse{ 3892 newFfiObject( 3893 pointer, 3894 func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 3895 - return C.uniffi_iroh_streamplace_fn_clone_subscriberesponse(pointer, status) 3896 }, 3897 func(pointer unsafe.Pointer, status *C.RustCallStatus) { 3898 - C.uniffi_iroh_streamplace_fn_free_subscriberesponse(pointer, status) 3899 }, 3900 ), 3901 } 3902 - runtime.SetFinalizer(result, (*SubscribeResponse).Destroy) 3903 return result 3904 } 3905 3906 - func (c FfiConverterSubscribeResponse) Read(reader io.Reader) *SubscribeResponse { 3907 return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 3908 } 3909 3910 - func (c FfiConverterSubscribeResponse) Lower(value *SubscribeResponse) unsafe.Pointer { 3911 // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 3912 // because the pointer will be decremented immediately after this function returns, 3913 // and someone will be left holding onto a non-locked pointer. 3914 - pointer := value.ffiObject.incrementPointer("*SubscribeResponse") 3915 defer value.ffiObject.decrementPointer() 3916 return pointer 3917 3918 } 3919 3920 - func (c FfiConverterSubscribeResponse) Write(writer io.Writer, value *SubscribeResponse) { 3921 writeUint64(writer, uint64(uintptr(c.Lower(value)))) 3922 } 3923 3924 - type FfiDestroyerSubscribeResponse struct{} 3925 3926 - func (_ FfiDestroyerSubscribeResponse) Destroy(value *SubscribeResponse) { 3927 - value.Destroy() 3928 - } 3929 - 3930 - // A write scope that can be used to put values into the database. 3931 - // 3932 - // The default write scope is available from the [`Node::node_scope`] method. 3933 - type WriteScopeInterface interface { 3934 - Put(stream *[]byte, key []byte, value []byte) error 3935 - } 3936 - 3937 - // A write scope that can be used to put values into the database. 3938 - // 3939 - // The default write scope is available from the [`Node::node_scope`] method. 3940 - type WriteScope struct { 3941 - ffiObject FfiObject 3942 - } 3943 - 3944 - func (_self *WriteScope) Put(stream *[]byte, key []byte, value []byte) error { 3945 - _pointer := _self.ffiObject.incrementPointer("*WriteScope") 3946 - defer _self.ffiObject.decrementPointer() 3947 - _, err := uniffiRustCallAsync[PutError]( 3948 - FfiConverterPutErrorINSTANCE, 3949 - // completeFn 3950 - func(handle C.uint64_t, status *C.RustCallStatus) struct{} { 3951 - C.ffi_iroh_streamplace_rust_future_complete_void(handle, status) 3952 - return struct{}{} 3953 - }, 3954 - // liftFn 3955 - func(_ struct{}) struct{} { return struct{}{} }, 3956 - C.uniffi_iroh_streamplace_fn_method_writescope_put( 3957 - _pointer, FfiConverterOptionalBytesINSTANCE.Lower(stream), FfiConverterBytesINSTANCE.Lower(key), FfiConverterBytesINSTANCE.Lower(value)), 3958 - // pollFn 3959 - func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { 3960 - C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data) 3961 - }, 3962 - // freeFn 3963 - func(handle C.uint64_t) { 3964 - C.ffi_iroh_streamplace_rust_future_free_void(handle) 3965 - }, 3966 - ) 3967 - 3968 - if err == nil { 3969 - return nil 3970 - } 3971 - 3972 - return err 3973 - } 3974 - func (object *WriteScope) Destroy() { 3975 - runtime.SetFinalizer(object, nil) 3976 - object.ffiObject.destroy() 3977 - } 3978 - 3979 - type FfiConverterWriteScope struct{} 3980 - 3981 - var FfiConverterWriteScopeINSTANCE = FfiConverterWriteScope{} 3982 - 3983 - func (c FfiConverterWriteScope) Lift(pointer unsafe.Pointer) *WriteScope { 3984 - result := &WriteScope{ 3985 - newFfiObject( 3986 - pointer, 3987 - func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 3988 - return C.uniffi_iroh_streamplace_fn_clone_writescope(pointer, status) 3989 - }, 3990 - func(pointer unsafe.Pointer, status *C.RustCallStatus) { 3991 - C.uniffi_iroh_streamplace_fn_free_writescope(pointer, status) 3992 - }, 3993 - ), 3994 - } 3995 - runtime.SetFinalizer(result, (*WriteScope).Destroy) 3996 - return result 3997 - } 3998 - 3999 - func (c FfiConverterWriteScope) Read(reader io.Reader) *WriteScope { 4000 - return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 4001 - } 4002 - 4003 - func (c FfiConverterWriteScope) Lower(value *WriteScope) unsafe.Pointer { 4004 - // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 4005 - // because the pointer will be decremented immediately after this function returns, 4006 - // and someone will be left holding onto a non-locked pointer. 4007 - pointer := value.ffiObject.incrementPointer("*WriteScope") 4008 - defer value.ffiObject.decrementPointer() 4009 - return pointer 4010 - 4011 - } 4012 - 4013 - func (c FfiConverterWriteScope) Write(writer io.Writer, value *WriteScope) { 4014 - writeUint64(writer, uint64(uintptr(c.Lower(value)))) 4015 - } 4016 - 4017 - type FfiDestroyerWriteScope struct{} 4018 - 4019 - func (_ FfiDestroyerWriteScope) Destroy(value *WriteScope) { 4020 - value.Destroy() 4021 - } 4022 - 4023 - // Configuration for an iroh-streamplace node. 4024 - type Config struct { 4025 - // An Ed25519 secret key as a 32 byte array. 4026 - Key []byte 4027 - // The gossip topic to use. Must be 32 bytes. 4028 - // 4029 - // You can use e.g. a BLAKE3 hash of a topic string here. This can be used 4030 - // as a cheap way to have a shared secret - nodes that do not know the topic 4031 - // cannot connect to the swarm. 4032 - Topic []byte 4033 - // Maximum duration to wait for sending a stream piece to a peer. 4034 - MaxSendDuration time.Duration 4035 - // Disable using relays, for tests. 4036 - DisableRelay bool 4037 - } 4038 - 4039 - func (r *Config) Destroy() { 4040 - FfiDestroyerBytes{}.Destroy(r.Key) 4041 - FfiDestroyerBytes{}.Destroy(r.Topic) 4042 - FfiDestroyerDuration{}.Destroy(r.MaxSendDuration) 4043 - FfiDestroyerBool{}.Destroy(r.DisableRelay) 4044 - } 4045 - 4046 - type FfiConverterConfig struct{} 4047 - 4048 - var FfiConverterConfigINSTANCE = FfiConverterConfig{} 4049 - 4050 - func (c FfiConverterConfig) Lift(rb RustBufferI) Config { 4051 - return LiftFromRustBuffer[Config](c, rb) 4052 - } 4053 - 4054 - func (c FfiConverterConfig) Read(reader io.Reader) Config { 4055 - return Config{ 4056 - FfiConverterBytesINSTANCE.Read(reader), 4057 - FfiConverterBytesINSTANCE.Read(reader), 4058 - FfiConverterDurationINSTANCE.Read(reader), 4059 - FfiConverterBoolINSTANCE.Read(reader), 4060 - } 4061 - } 4062 - 4063 - func (c FfiConverterConfig) Lower(value Config) C.RustBuffer { 4064 - return LowerIntoRustBuffer[Config](c, value) 4065 - } 4066 - 4067 - func (c FfiConverterConfig) Write(writer io.Writer, value Config) { 4068 - FfiConverterBytesINSTANCE.Write(writer, value.Key) 4069 - FfiConverterBytesINSTANCE.Write(writer, value.Topic) 4070 - FfiConverterDurationINSTANCE.Write(writer, value.MaxSendDuration) 4071 - FfiConverterBoolINSTANCE.Write(writer, value.DisableRelay) 4072 - } 4073 - 4074 - type FfiDestroyerConfig struct{} 4075 - 4076 - func (_ FfiDestroyerConfig) Destroy(value Config) { 4077 - value.Destroy() 4078 - } 4079 - 4080 - // An entry returned from the database. 4081 - type Entry struct { 4082 - Scope *PublicKey 4083 - Stream *[]byte 4084 - Key []byte 4085 - Value []byte 4086 - Timestamp uint64 4087 - } 4088 - 4089 - func (r *Entry) Destroy() { 4090 - FfiDestroyerPublicKey{}.Destroy(r.Scope) 4091 - FfiDestroyerOptionalBytes{}.Destroy(r.Stream) 4092 - FfiDestroyerBytes{}.Destroy(r.Key) 4093 - FfiDestroyerBytes{}.Destroy(r.Value) 4094 - FfiDestroyerUint64{}.Destroy(r.Timestamp) 4095 - } 4096 - 4097 - type FfiConverterEntry struct{} 4098 - 4099 - var FfiConverterEntryINSTANCE = FfiConverterEntry{} 4100 - 4101 - func (c FfiConverterEntry) Lift(rb RustBufferI) Entry { 4102 - return LiftFromRustBuffer[Entry](c, rb) 4103 - } 4104 - 4105 - func (c FfiConverterEntry) Read(reader io.Reader) Entry { 4106 - return Entry{ 4107 - FfiConverterPublicKeyINSTANCE.Read(reader), 4108 - FfiConverterOptionalBytesINSTANCE.Read(reader), 4109 - FfiConverterBytesINSTANCE.Read(reader), 4110 - FfiConverterBytesINSTANCE.Read(reader), 4111 - FfiConverterUint64INSTANCE.Read(reader), 4112 - } 4113 - } 4114 - 4115 - func (c FfiConverterEntry) Lower(value Entry) C.RustBuffer { 4116 - return LowerIntoRustBuffer[Entry](c, value) 4117 - } 4118 - 4119 - func (c FfiConverterEntry) Write(writer io.Writer, value Entry) { 4120 - FfiConverterPublicKeyINSTANCE.Write(writer, value.Scope) 4121 - FfiConverterOptionalBytesINSTANCE.Write(writer, value.Stream) 4122 - FfiConverterBytesINSTANCE.Write(writer, value.Key) 4123 - FfiConverterBytesINSTANCE.Write(writer, value.Value) 4124 - FfiConverterUint64INSTANCE.Write(writer, value.Timestamp) 4125 - } 4126 - 4127 - type FfiDestroyerEntry struct{} 4128 - 4129 - func (_ FfiDestroyerEntry) Destroy(value Entry) { 4130 value.Destroy() 4131 } 4132 4133 // Configuration for creating a [`Socket`]. 4134 type SocketConfig struct { 4135 Secret []byte 4136 - Alpn []byte 4137 } 4138 4139 func (r *SocketConfig) Destroy() { ··· 4171 value.Destroy() 4172 } 4173 4174 - // Options for subscribing. 4175 - // 4176 - // `filter` specifies what to subscribe to. 4177 - // `mode` specifies whether to get current items, new items, or both. 4178 - type SubscribeOpts struct { 4179 - Filter *Filter 4180 - Mode SubscribeMode 4181 - } 4182 - 4183 - func (r *SubscribeOpts) Destroy() { 4184 - FfiDestroyerFilter{}.Destroy(r.Filter) 4185 - FfiDestroyerSubscribeMode{}.Destroy(r.Mode) 4186 - } 4187 - 4188 - type FfiConverterSubscribeOpts struct{} 4189 - 4190 - var FfiConverterSubscribeOptsINSTANCE = FfiConverterSubscribeOpts{} 4191 - 4192 - func (c FfiConverterSubscribeOpts) Lift(rb RustBufferI) SubscribeOpts { 4193 - return LiftFromRustBuffer[SubscribeOpts](c, rb) 4194 - } 4195 - 4196 - func (c FfiConverterSubscribeOpts) Read(reader io.Reader) SubscribeOpts { 4197 - return SubscribeOpts{ 4198 - FfiConverterFilterINSTANCE.Read(reader), 4199 - FfiConverterSubscribeModeINSTANCE.Read(reader), 4200 - } 4201 - } 4202 - 4203 - func (c FfiConverterSubscribeOpts) Lower(value SubscribeOpts) C.RustBuffer { 4204 - return LowerIntoRustBuffer[SubscribeOpts](c, value) 4205 - } 4206 - 4207 - func (c FfiConverterSubscribeOpts) Write(writer io.Writer, value SubscribeOpts) { 4208 - FfiConverterFilterINSTANCE.Write(writer, value.Filter) 4209 - FfiConverterSubscribeModeINSTANCE.Write(writer, value.Mode) 4210 - } 4211 - 4212 - type FfiDestroyerSubscribeOpts struct{} 4213 - 4214 - func (_ FfiDestroyerSubscribeOpts) Destroy(value SubscribeOpts) { 4215 - value.Destroy() 4216 - } 4217 - 4218 type AcceptError struct { 4219 err error 4220 } ··· 4399 } 4400 } 4401 4402 - // Error creating a new database node. 4403 - type CreateError struct { 4404 - err error 4405 - } 4406 - 4407 - // Convience method to turn *CreateError into error 4408 - // Avoiding treating nil pointer as non nil error interface 4409 - func (err *CreateError) AsError() error { 4410 - if err == nil { 4411 - return nil 4412 - } else { 4413 - return err 4414 - } 4415 - } 4416 - 4417 - func (err CreateError) Error() string { 4418 - return fmt.Sprintf("CreateError: %s", err.err.Error()) 4419 - } 4420 - 4421 - func (err CreateError) Unwrap() error { 4422 - return err.err 4423 - } 4424 - 4425 - // Err* are used for checking error type with `errors.Is` 4426 - var ErrCreateErrorPrivateKey = fmt.Errorf("CreateErrorPrivateKey") 4427 - var ErrCreateErrorTopic = fmt.Errorf("CreateErrorTopic") 4428 - var ErrCreateErrorBind = fmt.Errorf("CreateErrorBind") 4429 - var ErrCreateErrorSubscribe = fmt.Errorf("CreateErrorSubscribe") 4430 - 4431 - // Variant structs 4432 - // The provided private key is invalid (not 32 bytes). 4433 - type CreateErrorPrivateKey struct { 4434 - Size uint64 4435 - } 4436 - 4437 - // The provided private key is invalid (not 32 bytes). 4438 - func NewCreateErrorPrivateKey( 4439 - size uint64, 4440 - ) *CreateError { 4441 - return &CreateError{err: &CreateErrorPrivateKey{ 4442 - Size: size}} 4443 - } 4444 - 4445 - func (e CreateErrorPrivateKey) destroy() { 4446 - FfiDestroyerUint64{}.Destroy(e.Size) 4447 - } 4448 - 4449 - func (err CreateErrorPrivateKey) Error() string { 4450 - return fmt.Sprint("PrivateKey", 4451 - ": ", 4452 - 4453 - "Size=", 4454 - err.Size, 4455 - ) 4456 - } 4457 - 4458 - func (self CreateErrorPrivateKey) Is(target error) bool { 4459 - return target == ErrCreateErrorPrivateKey 4460 - } 4461 - 4462 - // The provided gossip topic is invalid (not 32 bytes). 4463 - type CreateErrorTopic struct { 4464 - Size uint64 4465 - } 4466 - 4467 - // The provided gossip topic is invalid (not 32 bytes). 4468 - func NewCreateErrorTopic( 4469 - size uint64, 4470 - ) *CreateError { 4471 - return &CreateError{err: &CreateErrorTopic{ 4472 - Size: size}} 4473 - } 4474 - 4475 - func (e CreateErrorTopic) destroy() { 4476 - FfiDestroyerUint64{}.Destroy(e.Size) 4477 - } 4478 - 4479 - func (err CreateErrorTopic) Error() string { 4480 - return fmt.Sprint("Topic", 4481 - ": ", 4482 - 4483 - "Size=", 4484 - err.Size, 4485 - ) 4486 - } 4487 - 4488 - func (self CreateErrorTopic) Is(target error) bool { 4489 - return target == ErrCreateErrorTopic 4490 - } 4491 - 4492 - // Failed to bind the iroh endpoint. 4493 - type CreateErrorBind struct { 4494 - Message string 4495 - } 4496 - 4497 - // Failed to bind the iroh endpoint. 4498 - func NewCreateErrorBind( 4499 - message string, 4500 - ) *CreateError { 4501 - return &CreateError{err: &CreateErrorBind{ 4502 - Message: message}} 4503 - } 4504 - 4505 - func (e CreateErrorBind) destroy() { 4506 - FfiDestroyerString{}.Destroy(e.Message) 4507 - } 4508 - 4509 - func (err CreateErrorBind) Error() string { 4510 - return fmt.Sprint("Bind", 4511 - ": ", 4512 - 4513 - "Message=", 4514 - err.Message, 4515 - ) 4516 - } 4517 - 4518 - func (self CreateErrorBind) Is(target error) bool { 4519 - return target == ErrCreateErrorBind 4520 - } 4521 - 4522 - // Failed to subscribe to the gossip topic. 4523 - type CreateErrorSubscribe struct { 4524 - Message string 4525 - } 4526 - 4527 - // Failed to subscribe to the gossip topic. 4528 - func NewCreateErrorSubscribe( 4529 - message string, 4530 - ) *CreateError { 4531 - return &CreateError{err: &CreateErrorSubscribe{ 4532 - Message: message}} 4533 - } 4534 - 4535 - func (e CreateErrorSubscribe) destroy() { 4536 - FfiDestroyerString{}.Destroy(e.Message) 4537 - } 4538 - 4539 - func (err CreateErrorSubscribe) Error() string { 4540 - return fmt.Sprint("Subscribe", 4541 - ": ", 4542 - 4543 - "Message=", 4544 - err.Message, 4545 - ) 4546 - } 4547 - 4548 - func (self CreateErrorSubscribe) Is(target error) bool { 4549 - return target == ErrCreateErrorSubscribe 4550 - } 4551 - 4552 - type FfiConverterCreateError struct{} 4553 - 4554 - var FfiConverterCreateErrorINSTANCE = FfiConverterCreateError{} 4555 - 4556 - func (c FfiConverterCreateError) Lift(eb RustBufferI) *CreateError { 4557 - return LiftFromRustBuffer[*CreateError](c, eb) 4558 - } 4559 - 4560 - func (c FfiConverterCreateError) Lower(value *CreateError) C.RustBuffer { 4561 - return LowerIntoRustBuffer[*CreateError](c, value) 4562 - } 4563 - 4564 - func (c FfiConverterCreateError) Read(reader io.Reader) *CreateError { 4565 - errorID := readUint32(reader) 4566 - 4567 - switch errorID { 4568 - case 1: 4569 - return &CreateError{&CreateErrorPrivateKey{ 4570 - Size: FfiConverterUint64INSTANCE.Read(reader), 4571 - }} 4572 - case 2: 4573 - return &CreateError{&CreateErrorTopic{ 4574 - Size: FfiConverterUint64INSTANCE.Read(reader), 4575 - }} 4576 - case 3: 4577 - return &CreateError{&CreateErrorBind{ 4578 - Message: FfiConverterStringINSTANCE.Read(reader), 4579 - }} 4580 - case 4: 4581 - return &CreateError{&CreateErrorSubscribe{ 4582 - Message: FfiConverterStringINSTANCE.Read(reader), 4583 - }} 4584 - default: 4585 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterCreateError.Read()", errorID)) 4586 - } 4587 - } 4588 - 4589 - func (c FfiConverterCreateError) Write(writer io.Writer, value *CreateError) { 4590 - switch variantValue := value.err.(type) { 4591 - case *CreateErrorPrivateKey: 4592 - writeInt32(writer, 1) 4593 - FfiConverterUint64INSTANCE.Write(writer, variantValue.Size) 4594 - case *CreateErrorTopic: 4595 - writeInt32(writer, 2) 4596 - FfiConverterUint64INSTANCE.Write(writer, variantValue.Size) 4597 - case *CreateErrorBind: 4598 - writeInt32(writer, 3) 4599 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 4600 - case *CreateErrorSubscribe: 4601 - writeInt32(writer, 4) 4602 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 4603 - default: 4604 - _ = variantValue 4605 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterCreateError.Write", value)) 4606 - } 4607 - } 4608 - 4609 - type FfiDestroyerCreateError struct{} 4610 - 4611 - func (_ FfiDestroyerCreateError) Destroy(value *CreateError) { 4612 - switch variantValue := value.err.(type) { 4613 - case CreateErrorPrivateKey: 4614 - variantValue.destroy() 4615 - case CreateErrorTopic: 4616 - variantValue.destroy() 4617 - case CreateErrorBind: 4618 - variantValue.destroy() 4619 - case CreateErrorSubscribe: 4620 - variantValue.destroy() 4621 - default: 4622 - _ = variantValue 4623 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerCreateError.Destroy", value)) 4624 - } 4625 - } 4626 - 4627 - // Error joining peers. 4628 - type JoinPeersError struct { 4629 - err error 4630 - } 4631 - 4632 - // Convience method to turn *JoinPeersError into error 4633 - // Avoiding treating nil pointer as non nil error interface 4634 - func (err *JoinPeersError) AsError() error { 4635 - if err == nil { 4636 - return nil 4637 - } else { 4638 - return err 4639 - } 4640 - } 4641 - 4642 - func (err JoinPeersError) Error() string { 4643 - return fmt.Sprintf("JoinPeersError: %s", err.err.Error()) 4644 - } 4645 - 4646 - func (err JoinPeersError) Unwrap() error { 4647 - return err.err 4648 - } 4649 - 4650 - // Err* are used for checking error type with `errors.Is` 4651 - var ErrJoinPeersErrorTicket = fmt.Errorf("JoinPeersErrorTicket") 4652 - var ErrJoinPeersErrorIrpc = fmt.Errorf("JoinPeersErrorIrpc") 4653 - 4654 - // Variant structs 4655 - // Failed to parse a provided iroh node ticket. 4656 - type JoinPeersErrorTicket struct { 4657 - Message string 4658 - } 4659 - 4660 - // Failed to parse a provided iroh node ticket. 4661 - func NewJoinPeersErrorTicket( 4662 - message string, 4663 - ) *JoinPeersError { 4664 - return &JoinPeersError{err: &JoinPeersErrorTicket{ 4665 - Message: message}} 4666 - } 4667 - 4668 - func (e JoinPeersErrorTicket) destroy() { 4669 - FfiDestroyerString{}.Destroy(e.Message) 4670 - } 4671 - 4672 - func (err JoinPeersErrorTicket) Error() string { 4673 - return fmt.Sprint("Ticket", 4674 - ": ", 4675 - 4676 - "Message=", 4677 - err.Message, 4678 - ) 4679 - } 4680 - 4681 - func (self JoinPeersErrorTicket) Is(target error) bool { 4682 - return target == ErrJoinPeersErrorTicket 4683 - } 4684 - 4685 - // Error during the join peers operation. 4686 - type JoinPeersErrorIrpc struct { 4687 - Message string 4688 - } 4689 - 4690 - // Error during the join peers operation. 4691 - func NewJoinPeersErrorIrpc( 4692 - message string, 4693 - ) *JoinPeersError { 4694 - return &JoinPeersError{err: &JoinPeersErrorIrpc{ 4695 - Message: message}} 4696 - } 4697 - 4698 - func (e JoinPeersErrorIrpc) destroy() { 4699 - FfiDestroyerString{}.Destroy(e.Message) 4700 - } 4701 - 4702 - func (err JoinPeersErrorIrpc) Error() string { 4703 - return fmt.Sprint("Irpc", 4704 - ": ", 4705 - 4706 - "Message=", 4707 - err.Message, 4708 - ) 4709 - } 4710 - 4711 - func (self JoinPeersErrorIrpc) Is(target error) bool { 4712 - return target == ErrJoinPeersErrorIrpc 4713 - } 4714 - 4715 - type FfiConverterJoinPeersError struct{} 4716 - 4717 - var FfiConverterJoinPeersErrorINSTANCE = FfiConverterJoinPeersError{} 4718 - 4719 - func (c FfiConverterJoinPeersError) Lift(eb RustBufferI) *JoinPeersError { 4720 - return LiftFromRustBuffer[*JoinPeersError](c, eb) 4721 - } 4722 - 4723 - func (c FfiConverterJoinPeersError) Lower(value *JoinPeersError) C.RustBuffer { 4724 - return LowerIntoRustBuffer[*JoinPeersError](c, value) 4725 - } 4726 - 4727 - func (c FfiConverterJoinPeersError) Read(reader io.Reader) *JoinPeersError { 4728 - errorID := readUint32(reader) 4729 - 4730 - switch errorID { 4731 - case 1: 4732 - return &JoinPeersError{&JoinPeersErrorTicket{ 4733 - Message: FfiConverterStringINSTANCE.Read(reader), 4734 - }} 4735 - case 2: 4736 - return &JoinPeersError{&JoinPeersErrorIrpc{ 4737 - Message: FfiConverterStringINSTANCE.Read(reader), 4738 - }} 4739 - default: 4740 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterJoinPeersError.Read()", errorID)) 4741 - } 4742 - } 4743 - 4744 - func (c FfiConverterJoinPeersError) Write(writer io.Writer, value *JoinPeersError) { 4745 - switch variantValue := value.err.(type) { 4746 - case *JoinPeersErrorTicket: 4747 - writeInt32(writer, 1) 4748 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 4749 - case *JoinPeersErrorIrpc: 4750 - writeInt32(writer, 2) 4751 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 4752 - default: 4753 - _ = variantValue 4754 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterJoinPeersError.Write", value)) 4755 - } 4756 - } 4757 - 4758 - type FfiDestroyerJoinPeersError struct{} 4759 - 4760 - func (_ FfiDestroyerJoinPeersError) Destroy(value *JoinPeersError) { 4761 - switch variantValue := value.err.(type) { 4762 - case JoinPeersErrorTicket: 4763 - variantValue.destroy() 4764 - case JoinPeersErrorIrpc: 4765 - variantValue.destroy() 4766 - default: 4767 - _ = variantValue 4768 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerJoinPeersError.Destroy", value)) 4769 - } 4770 - } 4771 - 4772 // Error when converting from ffi NodeAddr to iroh::NodeAddr 4773 type NodeAddrError struct { 4774 err error ··· 4888 } 4889 } 4890 4891 - // Error joining peers. 4892 - type ParseError struct { 4893 - err error 4894 - } 4895 - 4896 - // Convience method to turn *ParseError into error 4897 - // Avoiding treating nil pointer as non nil error interface 4898 - func (err *ParseError) AsError() error { 4899 - if err == nil { 4900 - return nil 4901 - } else { 4902 - return err 4903 - } 4904 - } 4905 - 4906 - func (err ParseError) Error() string { 4907 - return fmt.Sprintf("ParseError: %s", err.err.Error()) 4908 - } 4909 - 4910 - func (err ParseError) Unwrap() error { 4911 - return err.err 4912 - } 4913 - 4914 - // Err* are used for checking error type with `errors.Is` 4915 - var ErrParseErrorTicket = fmt.Errorf("ParseErrorTicket") 4916 - 4917 - // Variant structs 4918 - // Failed to parse a provided iroh node ticket. 4919 - type ParseErrorTicket struct { 4920 - Message string 4921 - } 4922 - 4923 - // Failed to parse a provided iroh node ticket. 4924 - func NewParseErrorTicket( 4925 - message string, 4926 - ) *ParseError { 4927 - return &ParseError{err: &ParseErrorTicket{ 4928 - Message: message}} 4929 - } 4930 - 4931 - func (e ParseErrorTicket) destroy() { 4932 - FfiDestroyerString{}.Destroy(e.Message) 4933 - } 4934 - 4935 - func (err ParseErrorTicket) Error() string { 4936 - return fmt.Sprint("Ticket", 4937 - ": ", 4938 - 4939 - "Message=", 4940 - err.Message, 4941 - ) 4942 - } 4943 - 4944 - func (self ParseErrorTicket) Is(target error) bool { 4945 - return target == ErrParseErrorTicket 4946 - } 4947 - 4948 - type FfiConverterParseError struct{} 4949 - 4950 - var FfiConverterParseErrorINSTANCE = FfiConverterParseError{} 4951 - 4952 - func (c FfiConverterParseError) Lift(eb RustBufferI) *ParseError { 4953 - return LiftFromRustBuffer[*ParseError](c, eb) 4954 - } 4955 - 4956 - func (c FfiConverterParseError) Lower(value *ParseError) C.RustBuffer { 4957 - return LowerIntoRustBuffer[*ParseError](c, value) 4958 - } 4959 - 4960 - func (c FfiConverterParseError) Read(reader io.Reader) *ParseError { 4961 - errorID := readUint32(reader) 4962 - 4963 - switch errorID { 4964 - case 1: 4965 - return &ParseError{&ParseErrorTicket{ 4966 - Message: FfiConverterStringINSTANCE.Read(reader), 4967 - }} 4968 - default: 4969 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterParseError.Read()", errorID)) 4970 - } 4971 - } 4972 - 4973 - func (c FfiConverterParseError) Write(writer io.Writer, value *ParseError) { 4974 - switch variantValue := value.err.(type) { 4975 - case *ParseErrorTicket: 4976 - writeInt32(writer, 1) 4977 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 4978 - default: 4979 - _ = variantValue 4980 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterParseError.Write", value)) 4981 - } 4982 - } 4983 - 4984 - type FfiDestroyerParseError struct{} 4985 - 4986 - func (_ FfiDestroyerParseError) Destroy(value *ParseError) { 4987 - switch variantValue := value.err.(type) { 4988 - case ParseErrorTicket: 4989 - variantValue.destroy() 4990 - default: 4991 - _ = variantValue 4992 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerParseError.Destroy", value)) 4993 - } 4994 - } 4995 - 4996 type PublicKeyError struct { 4997 err error 4998 } ··· 5133 } 5134 } 5135 5136 - // Error putting a value into the database. 5137 - type PutError struct { 5138 - err error 5139 - } 5140 - 5141 - // Convience method to turn *PutError into error 5142 - // Avoiding treating nil pointer as non nil error interface 5143 - func (err *PutError) AsError() error { 5144 - if err == nil { 5145 - return nil 5146 - } else { 5147 - return err 5148 - } 5149 - } 5150 - 5151 - func (err PutError) Error() string { 5152 - return fmt.Sprintf("PutError: %s", err.err.Error()) 5153 - } 5154 - 5155 - func (err PutError) Unwrap() error { 5156 - return err.err 5157 - } 5158 - 5159 - // Err* are used for checking error type with `errors.Is` 5160 - var ErrPutErrorIrpc = fmt.Errorf("PutErrorIrpc") 5161 - 5162 - // Variant structs 5163 - // Error during the put operation. 5164 - type PutErrorIrpc struct { 5165 - Message string 5166 - } 5167 - 5168 - // Error during the put operation. 5169 - func NewPutErrorIrpc( 5170 - message string, 5171 - ) *PutError { 5172 - return &PutError{err: &PutErrorIrpc{ 5173 - Message: message}} 5174 - } 5175 - 5176 - func (e PutErrorIrpc) destroy() { 5177 - FfiDestroyerString{}.Destroy(e.Message) 5178 - } 5179 - 5180 - func (err PutErrorIrpc) Error() string { 5181 - return fmt.Sprint("Irpc", 5182 - ": ", 5183 - 5184 - "Message=", 5185 - err.Message, 5186 - ) 5187 - } 5188 - 5189 - func (self PutErrorIrpc) Is(target error) bool { 5190 - return target == ErrPutErrorIrpc 5191 - } 5192 - 5193 - type FfiConverterPutError struct{} 5194 - 5195 - var FfiConverterPutErrorINSTANCE = FfiConverterPutError{} 5196 - 5197 - func (c FfiConverterPutError) Lift(eb RustBufferI) *PutError { 5198 - return LiftFromRustBuffer[*PutError](c, eb) 5199 - } 5200 - 5201 - func (c FfiConverterPutError) Lower(value *PutError) C.RustBuffer { 5202 - return LowerIntoRustBuffer[*PutError](c, value) 5203 - } 5204 - 5205 - func (c FfiConverterPutError) Read(reader io.Reader) *PutError { 5206 - errorID := readUint32(reader) 5207 - 5208 - switch errorID { 5209 - case 1: 5210 - return &PutError{&PutErrorIrpc{ 5211 - Message: FfiConverterStringINSTANCE.Read(reader), 5212 - }} 5213 - default: 5214 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterPutError.Read()", errorID)) 5215 - } 5216 - } 5217 - 5218 - func (c FfiConverterPutError) Write(writer io.Writer, value *PutError) { 5219 - switch variantValue := value.err.(type) { 5220 - case *PutErrorIrpc: 5221 - writeInt32(writer, 1) 5222 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 5223 - default: 5224 - _ = variantValue 5225 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterPutError.Write", value)) 5226 - } 5227 - } 5228 - 5229 - type FfiDestroyerPutError struct{} 5230 - 5231 - func (_ FfiDestroyerPutError) Destroy(value *PutError) { 5232 - switch variantValue := value.err.(type) { 5233 - case PutErrorIrpc: 5234 - variantValue.destroy() 5235 - default: 5236 - _ = variantValue 5237 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerPutError.Destroy", value)) 5238 - } 5239 - } 5240 - 5241 type ReadError struct { 5242 err error 5243 } ··· 5330 } 5331 } 5332 5333 - type SpError struct { 5334 - err error 5335 - } 5336 - 5337 - // Convience method to turn *SpError into error 5338 - // Avoiding treating nil pointer as non nil error interface 5339 - func (err *SpError) AsError() error { 5340 - if err == nil { 5341 - return nil 5342 - } else { 5343 - return err 5344 - } 5345 - } 5346 - 5347 - func (err SpError) Error() string { 5348 - return fmt.Sprintf("SpError: %s", err.err.Error()) 5349 - } 5350 - 5351 - func (err SpError) Unwrap() error { 5352 - return err.err 5353 - } 5354 - 5355 - // Err* are used for checking error type with `errors.Is` 5356 - var ErrSpErrorNoCertificateChainFound = fmt.Errorf("SpErrorNoCertificateChainFound") 5357 - var ErrSpErrorC2paError = fmt.Errorf("SpErrorC2paError") 5358 - var ErrSpErrorIoError = fmt.Errorf("SpErrorIoError") 5359 - 5360 - // Variant structs 5361 - type SpErrorNoCertificateChainFound struct { 5362 - message string 5363 - } 5364 - 5365 - func NewSpErrorNoCertificateChainFound() *SpError { 5366 - return &SpError{err: &SpErrorNoCertificateChainFound{}} 5367 - } 5368 - 5369 - func (e SpErrorNoCertificateChainFound) destroy() { 5370 - } 5371 - 5372 - func (err SpErrorNoCertificateChainFound) Error() string { 5373 - return fmt.Sprintf("NoCertificateChainFound: %s", err.message) 5374 - } 5375 - 5376 - func (self SpErrorNoCertificateChainFound) Is(target error) bool { 5377 - return target == ErrSpErrorNoCertificateChainFound 5378 - } 5379 - 5380 - type SpErrorC2paError struct { 5381 - message string 5382 - } 5383 - 5384 - func NewSpErrorC2paError() *SpError { 5385 - return &SpError{err: &SpErrorC2paError{}} 5386 - } 5387 - 5388 - func (e SpErrorC2paError) destroy() { 5389 - } 5390 - 5391 - func (err SpErrorC2paError) Error() string { 5392 - return fmt.Sprintf("C2paError: %s", err.message) 5393 - } 5394 - 5395 - func (self SpErrorC2paError) Is(target error) bool { 5396 - return target == ErrSpErrorC2paError 5397 - } 5398 - 5399 - type SpErrorIoError struct { 5400 - message string 5401 - } 5402 - 5403 - func NewSpErrorIoError() *SpError { 5404 - return &SpError{err: &SpErrorIoError{}} 5405 - } 5406 - 5407 - func (e SpErrorIoError) destroy() { 5408 - } 5409 - 5410 - func (err SpErrorIoError) Error() string { 5411 - return fmt.Sprintf("IoError: %s", err.message) 5412 - } 5413 - 5414 - func (self SpErrorIoError) Is(target error) bool { 5415 - return target == ErrSpErrorIoError 5416 - } 5417 - 5418 - type FfiConverterSpError struct{} 5419 - 5420 - var FfiConverterSpErrorINSTANCE = FfiConverterSpError{} 5421 - 5422 - func (c FfiConverterSpError) Lift(eb RustBufferI) *SpError { 5423 - return LiftFromRustBuffer[*SpError](c, eb) 5424 - } 5425 - 5426 - func (c FfiConverterSpError) Lower(value *SpError) C.RustBuffer { 5427 - return LowerIntoRustBuffer[*SpError](c, value) 5428 - } 5429 - 5430 - func (c FfiConverterSpError) Read(reader io.Reader) *SpError { 5431 - errorID := readUint32(reader) 5432 - 5433 - message := FfiConverterStringINSTANCE.Read(reader) 5434 - switch errorID { 5435 - case 1: 5436 - return &SpError{&SpErrorNoCertificateChainFound{message}} 5437 - case 2: 5438 - return &SpError{&SpErrorC2paError{message}} 5439 - case 3: 5440 - return &SpError{&SpErrorIoError{message}} 5441 - default: 5442 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterSpError.Read()", errorID)) 5443 - } 5444 - 5445 - } 5446 - 5447 - func (c FfiConverterSpError) Write(writer io.Writer, value *SpError) { 5448 - switch variantValue := value.err.(type) { 5449 - case *SpErrorNoCertificateChainFound: 5450 - writeInt32(writer, 1) 5451 - case *SpErrorC2paError: 5452 - writeInt32(writer, 2) 5453 - case *SpErrorIoError: 5454 - writeInt32(writer, 3) 5455 - default: 5456 - _ = variantValue 5457 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterSpError.Write", value)) 5458 - } 5459 - } 5460 - 5461 - type FfiDestroyerSpError struct{} 5462 - 5463 - func (_ FfiDestroyerSpError) Destroy(value *SpError) { 5464 - switch variantValue := value.err.(type) { 5465 - case SpErrorNoCertificateChainFound: 5466 - variantValue.destroy() 5467 - case SpErrorC2paError: 5468 - variantValue.destroy() 5469 - case SpErrorIoError: 5470 - variantValue.destroy() 5471 - default: 5472 - _ = variantValue 5473 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerSpError.Destroy", value)) 5474 - } 5475 - } 5476 - 5477 - // Error shutting down the database. 5478 - // 5479 - // This can occur if the db is already shut down or if there is an internal error. 5480 - type ShutdownError struct { 5481 - err error 5482 - } 5483 - 5484 - // Convience method to turn *ShutdownError into error 5485 - // Avoiding treating nil pointer as non nil error interface 5486 - func (err *ShutdownError) AsError() error { 5487 - if err == nil { 5488 - return nil 5489 - } else { 5490 - return err 5491 - } 5492 - } 5493 - 5494 - func (err ShutdownError) Error() string { 5495 - return fmt.Sprintf("ShutdownError: %s", err.err.Error()) 5496 - } 5497 - 5498 - func (err ShutdownError) Unwrap() error { 5499 - return err.err 5500 - } 5501 - 5502 - // Err* are used for checking error type with `errors.Is` 5503 - var ErrShutdownErrorIrpc = fmt.Errorf("ShutdownErrorIrpc") 5504 - 5505 - // Variant structs 5506 - // Error during the shutdown operation. 5507 - type ShutdownErrorIrpc struct { 5508 - Message string 5509 - } 5510 - 5511 - // Error during the shutdown operation. 5512 - func NewShutdownErrorIrpc( 5513 - message string, 5514 - ) *ShutdownError { 5515 - return &ShutdownError{err: &ShutdownErrorIrpc{ 5516 - Message: message}} 5517 - } 5518 - 5519 - func (e ShutdownErrorIrpc) destroy() { 5520 - FfiDestroyerString{}.Destroy(e.Message) 5521 - } 5522 - 5523 - func (err ShutdownErrorIrpc) Error() string { 5524 - return fmt.Sprint("Irpc", 5525 - ": ", 5526 - 5527 - "Message=", 5528 - err.Message, 5529 - ) 5530 - } 5531 - 5532 - func (self ShutdownErrorIrpc) Is(target error) bool { 5533 - return target == ErrShutdownErrorIrpc 5534 - } 5535 - 5536 - type FfiConverterShutdownError struct{} 5537 - 5538 - var FfiConverterShutdownErrorINSTANCE = FfiConverterShutdownError{} 5539 - 5540 - func (c FfiConverterShutdownError) Lift(eb RustBufferI) *ShutdownError { 5541 - return LiftFromRustBuffer[*ShutdownError](c, eb) 5542 - } 5543 - 5544 - func (c FfiConverterShutdownError) Lower(value *ShutdownError) C.RustBuffer { 5545 - return LowerIntoRustBuffer[*ShutdownError](c, value) 5546 - } 5547 - 5548 - func (c FfiConverterShutdownError) Read(reader io.Reader) *ShutdownError { 5549 - errorID := readUint32(reader) 5550 - 5551 - switch errorID { 5552 - case 1: 5553 - return &ShutdownError{&ShutdownErrorIrpc{ 5554 - Message: FfiConverterStringINSTANCE.Read(reader), 5555 - }} 5556 - default: 5557 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterShutdownError.Read()", errorID)) 5558 - } 5559 - } 5560 - 5561 - func (c FfiConverterShutdownError) Write(writer io.Writer, value *ShutdownError) { 5562 - switch variantValue := value.err.(type) { 5563 - case *ShutdownErrorIrpc: 5564 - writeInt32(writer, 1) 5565 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 5566 - default: 5567 - _ = variantValue 5568 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterShutdownError.Write", value)) 5569 - } 5570 - } 5571 - 5572 - type FfiDestroyerShutdownError struct{} 5573 - 5574 - func (_ FfiDestroyerShutdownError) Destroy(value *ShutdownError) { 5575 - switch variantValue := value.err.(type) { 5576 - case ShutdownErrorIrpc: 5577 - variantValue.destroy() 5578 - default: 5579 - _ = variantValue 5580 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerShutdownError.Destroy", value)) 5581 - } 5582 - } 5583 - 5584 type SocketNewError struct { 5585 err error 5586 } ··· 5673 } 5674 } 5675 5676 - type StreamFilter interface { 5677 - Destroy() 5678 - } 5679 - type StreamFilterAll struct { 5680 - } 5681 - 5682 - func (e StreamFilterAll) Destroy() { 5683 - } 5684 - 5685 - type StreamFilterGlobal struct { 5686 - } 5687 - 5688 - func (e StreamFilterGlobal) Destroy() { 5689 - } 5690 - 5691 - type StreamFilterStream struct { 5692 - Field0 []byte 5693 - } 5694 - 5695 - func (e StreamFilterStream) Destroy() { 5696 - FfiDestroyerBytes{}.Destroy(e.Field0) 5697 - } 5698 - 5699 - type FfiConverterStreamFilter struct{} 5700 - 5701 - var FfiConverterStreamFilterINSTANCE = FfiConverterStreamFilter{} 5702 - 5703 - func (c FfiConverterStreamFilter) Lift(rb RustBufferI) StreamFilter { 5704 - return LiftFromRustBuffer[StreamFilter](c, rb) 5705 - } 5706 - 5707 - func (c FfiConverterStreamFilter) Lower(value StreamFilter) C.RustBuffer { 5708 - return LowerIntoRustBuffer[StreamFilter](c, value) 5709 - } 5710 - func (FfiConverterStreamFilter) Read(reader io.Reader) StreamFilter { 5711 - id := readInt32(reader) 5712 - switch id { 5713 - case 1: 5714 - return StreamFilterAll{} 5715 - case 2: 5716 - return StreamFilterGlobal{} 5717 - case 3: 5718 - return StreamFilterStream{ 5719 - FfiConverterBytesINSTANCE.Read(reader), 5720 - } 5721 - default: 5722 - panic(fmt.Sprintf("invalid enum value %v in FfiConverterStreamFilter.Read()", id)) 5723 - } 5724 - } 5725 - 5726 - func (FfiConverterStreamFilter) Write(writer io.Writer, value StreamFilter) { 5727 - switch variant_value := value.(type) { 5728 - case StreamFilterAll: 5729 - writeInt32(writer, 1) 5730 - case StreamFilterGlobal: 5731 - writeInt32(writer, 2) 5732 - case StreamFilterStream: 5733 - writeInt32(writer, 3) 5734 - FfiConverterBytesINSTANCE.Write(writer, variant_value.Field0) 5735 - default: 5736 - _ = variant_value 5737 - panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterStreamFilter.Write", value)) 5738 - } 5739 - } 5740 - 5741 - type FfiDestroyerStreamFilter struct{} 5742 - 5743 - func (_ FfiDestroyerStreamFilter) Destroy(value StreamFilter) { 5744 - value.Destroy() 5745 - } 5746 - 5747 - // An item returned from a subscription. 5748 - type SubscribeItem interface { 5749 - Destroy() 5750 - } 5751 - type SubscribeItemEntry struct { 5752 - Scope *PublicKey 5753 - Stream *[]byte 5754 - Key []byte 5755 - Value []byte 5756 - Timestamp uint64 5757 - } 5758 - 5759 - func (e SubscribeItemEntry) Destroy() { 5760 - FfiDestroyerPublicKey{}.Destroy(e.Scope) 5761 - FfiDestroyerOptionalBytes{}.Destroy(e.Stream) 5762 - FfiDestroyerBytes{}.Destroy(e.Key) 5763 - FfiDestroyerBytes{}.Destroy(e.Value) 5764 - FfiDestroyerUint64{}.Destroy(e.Timestamp) 5765 - } 5766 - 5767 - type SubscribeItemCurrentDone struct { 5768 - } 5769 - 5770 - func (e SubscribeItemCurrentDone) Destroy() { 5771 - } 5772 - 5773 - type SubscribeItemExpired struct { 5774 - Scope *PublicKey 5775 - Stream *[]byte 5776 - Key []byte 5777 - Timestamp uint64 5778 - } 5779 - 5780 - func (e SubscribeItemExpired) Destroy() { 5781 - FfiDestroyerPublicKey{}.Destroy(e.Scope) 5782 - FfiDestroyerOptionalBytes{}.Destroy(e.Stream) 5783 - FfiDestroyerBytes{}.Destroy(e.Key) 5784 - FfiDestroyerUint64{}.Destroy(e.Timestamp) 5785 - } 5786 - 5787 - type SubscribeItemOther struct { 5788 - } 5789 - 5790 - func (e SubscribeItemOther) Destroy() { 5791 - } 5792 - 5793 - type FfiConverterSubscribeItem struct{} 5794 - 5795 - var FfiConverterSubscribeItemINSTANCE = FfiConverterSubscribeItem{} 5796 - 5797 - func (c FfiConverterSubscribeItem) Lift(rb RustBufferI) SubscribeItem { 5798 - return LiftFromRustBuffer[SubscribeItem](c, rb) 5799 - } 5800 - 5801 - func (c FfiConverterSubscribeItem) Lower(value SubscribeItem) C.RustBuffer { 5802 - return LowerIntoRustBuffer[SubscribeItem](c, value) 5803 - } 5804 - func (FfiConverterSubscribeItem) Read(reader io.Reader) SubscribeItem { 5805 - id := readInt32(reader) 5806 - switch id { 5807 - case 1: 5808 - return SubscribeItemEntry{ 5809 - FfiConverterPublicKeyINSTANCE.Read(reader), 5810 - FfiConverterOptionalBytesINSTANCE.Read(reader), 5811 - FfiConverterBytesINSTANCE.Read(reader), 5812 - FfiConverterBytesINSTANCE.Read(reader), 5813 - FfiConverterUint64INSTANCE.Read(reader), 5814 - } 5815 - case 2: 5816 - return SubscribeItemCurrentDone{} 5817 - case 3: 5818 - return SubscribeItemExpired{ 5819 - FfiConverterPublicKeyINSTANCE.Read(reader), 5820 - FfiConverterOptionalBytesINSTANCE.Read(reader), 5821 - FfiConverterBytesINSTANCE.Read(reader), 5822 - FfiConverterUint64INSTANCE.Read(reader), 5823 - } 5824 - case 4: 5825 - return SubscribeItemOther{} 5826 - default: 5827 - panic(fmt.Sprintf("invalid enum value %v in FfiConverterSubscribeItem.Read()", id)) 5828 - } 5829 - } 5830 - 5831 - func (FfiConverterSubscribeItem) Write(writer io.Writer, value SubscribeItem) { 5832 - switch variant_value := value.(type) { 5833 - case SubscribeItemEntry: 5834 - writeInt32(writer, 1) 5835 - FfiConverterPublicKeyINSTANCE.Write(writer, variant_value.Scope) 5836 - FfiConverterOptionalBytesINSTANCE.Write(writer, variant_value.Stream) 5837 - FfiConverterBytesINSTANCE.Write(writer, variant_value.Key) 5838 - FfiConverterBytesINSTANCE.Write(writer, variant_value.Value) 5839 - FfiConverterUint64INSTANCE.Write(writer, variant_value.Timestamp) 5840 - case SubscribeItemCurrentDone: 5841 - writeInt32(writer, 2) 5842 - case SubscribeItemExpired: 5843 - writeInt32(writer, 3) 5844 - FfiConverterPublicKeyINSTANCE.Write(writer, variant_value.Scope) 5845 - FfiConverterOptionalBytesINSTANCE.Write(writer, variant_value.Stream) 5846 - FfiConverterBytesINSTANCE.Write(writer, variant_value.Key) 5847 - FfiConverterUint64INSTANCE.Write(writer, variant_value.Timestamp) 5848 - case SubscribeItemOther: 5849 - writeInt32(writer, 4) 5850 - default: 5851 - _ = variant_value 5852 - panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterSubscribeItem.Write", value)) 5853 - } 5854 - } 5855 - 5856 - type FfiDestroyerSubscribeItem struct{} 5857 - 5858 - func (_ FfiDestroyerSubscribeItem) Destroy(value SubscribeItem) { 5859 - value.Destroy() 5860 - } 5861 - 5862 - // Subscription mode for key-value subscriptions. 5863 - type SubscribeMode uint 5864 - 5865 - const ( 5866 - SubscribeModeCurrent SubscribeMode = 1 5867 - SubscribeModeFuture SubscribeMode = 2 5868 - SubscribeModeBoth SubscribeMode = 3 5869 - ) 5870 - 5871 - type FfiConverterSubscribeMode struct{} 5872 - 5873 - var FfiConverterSubscribeModeINSTANCE = FfiConverterSubscribeMode{} 5874 - 5875 - func (c FfiConverterSubscribeMode) Lift(rb RustBufferI) SubscribeMode { 5876 - return LiftFromRustBuffer[SubscribeMode](c, rb) 5877 - } 5878 - 5879 - func (c FfiConverterSubscribeMode) Lower(value SubscribeMode) C.RustBuffer { 5880 - return LowerIntoRustBuffer[SubscribeMode](c, value) 5881 - } 5882 - func (FfiConverterSubscribeMode) Read(reader io.Reader) SubscribeMode { 5883 - id := readInt32(reader) 5884 - return SubscribeMode(id) 5885 - } 5886 - 5887 - func (FfiConverterSubscribeMode) Write(writer io.Writer, value SubscribeMode) { 5888 - writeInt32(writer, int32(value)) 5889 - } 5890 - 5891 - type FfiDestroyerSubscribeMode struct{} 5892 - 5893 - func (_ FfiDestroyerSubscribeMode) Destroy(value SubscribeMode) { 5894 - } 5895 - 5896 - // Error getting the next item from a subscription. 5897 - type SubscribeNextError struct { 5898 - err error 5899 - } 5900 - 5901 - // Convience method to turn *SubscribeNextError into error 5902 - // Avoiding treating nil pointer as non nil error interface 5903 - func (err *SubscribeNextError) AsError() error { 5904 - if err == nil { 5905 - return nil 5906 - } else { 5907 - return err 5908 - } 5909 - } 5910 - 5911 - func (err SubscribeNextError) Error() string { 5912 - return fmt.Sprintf("SubscribeNextError: %s", err.err.Error()) 5913 - } 5914 - 5915 - func (err SubscribeNextError) Unwrap() error { 5916 - return err.err 5917 - } 5918 - 5919 - // Err* are used for checking error type with `errors.Is` 5920 - var ErrSubscribeNextErrorIrpc = fmt.Errorf("SubscribeNextErrorIrpc") 5921 - 5922 - // Variant structs 5923 - // Error during the subscribe next operation. 5924 - type SubscribeNextErrorIrpc struct { 5925 - Message string 5926 - } 5927 - 5928 - // Error during the subscribe next operation. 5929 - func NewSubscribeNextErrorIrpc( 5930 - message string, 5931 - ) *SubscribeNextError { 5932 - return &SubscribeNextError{err: &SubscribeNextErrorIrpc{ 5933 - Message: message}} 5934 - } 5935 - 5936 - func (e SubscribeNextErrorIrpc) destroy() { 5937 - FfiDestroyerString{}.Destroy(e.Message) 5938 - } 5939 - 5940 - func (err SubscribeNextErrorIrpc) Error() string { 5941 - return fmt.Sprint("Irpc", 5942 - ": ", 5943 - 5944 - "Message=", 5945 - err.Message, 5946 - ) 5947 - } 5948 - 5949 - func (self SubscribeNextErrorIrpc) Is(target error) bool { 5950 - return target == ErrSubscribeNextErrorIrpc 5951 - } 5952 - 5953 - type FfiConverterSubscribeNextError struct{} 5954 - 5955 - var FfiConverterSubscribeNextErrorINSTANCE = FfiConverterSubscribeNextError{} 5956 - 5957 - func (c FfiConverterSubscribeNextError) Lift(eb RustBufferI) *SubscribeNextError { 5958 - return LiftFromRustBuffer[*SubscribeNextError](c, eb) 5959 - } 5960 - 5961 - func (c FfiConverterSubscribeNextError) Lower(value *SubscribeNextError) C.RustBuffer { 5962 - return LowerIntoRustBuffer[*SubscribeNextError](c, value) 5963 - } 5964 - 5965 - func (c FfiConverterSubscribeNextError) Read(reader io.Reader) *SubscribeNextError { 5966 - errorID := readUint32(reader) 5967 - 5968 - switch errorID { 5969 - case 1: 5970 - return &SubscribeNextError{&SubscribeNextErrorIrpc{ 5971 - Message: FfiConverterStringINSTANCE.Read(reader), 5972 - }} 5973 - default: 5974 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterSubscribeNextError.Read()", errorID)) 5975 - } 5976 - } 5977 - 5978 - func (c FfiConverterSubscribeNextError) Write(writer io.Writer, value *SubscribeNextError) { 5979 - switch variantValue := value.err.(type) { 5980 - case *SubscribeNextErrorIrpc: 5981 - writeInt32(writer, 1) 5982 - FfiConverterStringINSTANCE.Write(writer, variantValue.Message) 5983 - default: 5984 - _ = variantValue 5985 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterSubscribeNextError.Write", value)) 5986 - } 5987 - } 5988 - 5989 - type FfiDestroyerSubscribeNextError struct{} 5990 - 5991 - func (_ FfiDestroyerSubscribeNextError) Destroy(value *SubscribeNextError) { 5992 - switch variantValue := value.err.(type) { 5993 - case SubscribeNextErrorIrpc: 5994 - variantValue.destroy() 5995 - default: 5996 - _ = variantValue 5997 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerSubscribeNextError.Destroy", value)) 5998 - } 5999 - } 6000 - 6001 // Error when converting from ffi NodeAddr to iroh::NodeAddr 6002 type TicketError struct { 6003 err error ··· 6091 } 6092 } 6093 6094 - // A bound on time for filtering. 6095 - type TimeBound interface { 6096 - Destroy() 6097 - } 6098 - type TimeBoundUnbounded struct { 6099 - } 6100 - 6101 - func (e TimeBoundUnbounded) Destroy() { 6102 - } 6103 - 6104 - type TimeBoundIncluded struct { 6105 - Field0 uint64 6106 - } 6107 - 6108 - func (e TimeBoundIncluded) Destroy() { 6109 - FfiDestroyerUint64{}.Destroy(e.Field0) 6110 - } 6111 - 6112 - type TimeBoundExcluded struct { 6113 - Field0 uint64 6114 - } 6115 - 6116 - func (e TimeBoundExcluded) Destroy() { 6117 - FfiDestroyerUint64{}.Destroy(e.Field0) 6118 - } 6119 - 6120 - type FfiConverterTimeBound struct{} 6121 - 6122 - var FfiConverterTimeBoundINSTANCE = FfiConverterTimeBound{} 6123 - 6124 - func (c FfiConverterTimeBound) Lift(rb RustBufferI) TimeBound { 6125 - return LiftFromRustBuffer[TimeBound](c, rb) 6126 - } 6127 - 6128 - func (c FfiConverterTimeBound) Lower(value TimeBound) C.RustBuffer { 6129 - return LowerIntoRustBuffer[TimeBound](c, value) 6130 - } 6131 - func (FfiConverterTimeBound) Read(reader io.Reader) TimeBound { 6132 - id := readInt32(reader) 6133 - switch id { 6134 - case 1: 6135 - return TimeBoundUnbounded{} 6136 - case 2: 6137 - return TimeBoundIncluded{ 6138 - FfiConverterUint64INSTANCE.Read(reader), 6139 - } 6140 - case 3: 6141 - return TimeBoundExcluded{ 6142 - FfiConverterUint64INSTANCE.Read(reader), 6143 - } 6144 - default: 6145 - panic(fmt.Sprintf("invalid enum value %v in FfiConverterTimeBound.Read()", id)) 6146 - } 6147 - } 6148 - 6149 - func (FfiConverterTimeBound) Write(writer io.Writer, value TimeBound) { 6150 - switch variant_value := value.(type) { 6151 - case TimeBoundUnbounded: 6152 - writeInt32(writer, 1) 6153 - case TimeBoundIncluded: 6154 - writeInt32(writer, 2) 6155 - FfiConverterUint64INSTANCE.Write(writer, variant_value.Field0) 6156 - case TimeBoundExcluded: 6157 - writeInt32(writer, 3) 6158 - FfiConverterUint64INSTANCE.Write(writer, variant_value.Field0) 6159 - default: 6160 - _ = variant_value 6161 - panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterTimeBound.Write", value)) 6162 - } 6163 - } 6164 - 6165 - type FfiDestroyerTimeBound struct{} 6166 - 6167 - func (_ FfiDestroyerTimeBound) Destroy(value TimeBound) { 6168 - value.Destroy() 6169 - } 6170 - 6171 - // Error getting the next item from a subscription. 6172 - type WriteError struct { 6173 - err error 6174 - } 6175 - 6176 - // Convience method to turn *WriteError into error 6177 - // Avoiding treating nil pointer as non nil error interface 6178 - func (err *WriteError) AsError() error { 6179 - if err == nil { 6180 - return nil 6181 - } else { 6182 - return err 6183 - } 6184 - } 6185 - 6186 - func (err WriteError) Error() string { 6187 - return fmt.Sprintf("WriteError: %s", err.err.Error()) 6188 - } 6189 - 6190 - func (err WriteError) Unwrap() error { 6191 - return err.err 6192 - } 6193 - 6194 - // Err* are used for checking error type with `errors.Is` 6195 - var ErrWriteErrorPrivateKeySize = fmt.Errorf("WriteErrorPrivateKeySize") 6196 - 6197 - // Variant structs 6198 - // The provided private key is invalid (not 32 bytes). 6199 - type WriteErrorPrivateKeySize struct { 6200 - Size uint64 6201 - } 6202 - 6203 - // The provided private key is invalid (not 32 bytes). 6204 - func NewWriteErrorPrivateKeySize( 6205 - size uint64, 6206 - ) *WriteError { 6207 - return &WriteError{err: &WriteErrorPrivateKeySize{ 6208 - Size: size}} 6209 - } 6210 - 6211 - func (e WriteErrorPrivateKeySize) destroy() { 6212 - FfiDestroyerUint64{}.Destroy(e.Size) 6213 - } 6214 - 6215 - func (err WriteErrorPrivateKeySize) Error() string { 6216 - return fmt.Sprint("PrivateKeySize", 6217 - ": ", 6218 - 6219 - "Size=", 6220 - err.Size, 6221 - ) 6222 - } 6223 - 6224 - func (self WriteErrorPrivateKeySize) Is(target error) bool { 6225 - return target == ErrWriteErrorPrivateKeySize 6226 - } 6227 - 6228 - type FfiConverterWriteError struct{} 6229 - 6230 - var FfiConverterWriteErrorINSTANCE = FfiConverterWriteError{} 6231 - 6232 - func (c FfiConverterWriteError) Lift(eb RustBufferI) *WriteError { 6233 - return LiftFromRustBuffer[*WriteError](c, eb) 6234 - } 6235 - 6236 - func (c FfiConverterWriteError) Lower(value *WriteError) C.RustBuffer { 6237 - return LowerIntoRustBuffer[*WriteError](c, value) 6238 - } 6239 - 6240 - func (c FfiConverterWriteError) Read(reader io.Reader) *WriteError { 6241 - errorID := readUint32(reader) 6242 - 6243 - switch errorID { 6244 - case 1: 6245 - return &WriteError{&WriteErrorPrivateKeySize{ 6246 - Size: FfiConverterUint64INSTANCE.Read(reader), 6247 - }} 6248 - default: 6249 - panic(fmt.Sprintf("Unknown error code %d in FfiConverterWriteError.Read()", errorID)) 6250 - } 6251 - } 6252 - 6253 - func (c FfiConverterWriteError) Write(writer io.Writer, value *WriteError) { 6254 - switch variantValue := value.err.(type) { 6255 - case *WriteErrorPrivateKeySize: 6256 - writeInt32(writer, 1) 6257 - FfiConverterUint64INSTANCE.Write(writer, variantValue.Size) 6258 - default: 6259 - _ = variantValue 6260 - panic(fmt.Sprintf("invalid error value `%v` in FfiConverterWriteError.Write", value)) 6261 - } 6262 - } 6263 - 6264 - type FfiDestroyerWriteError struct{} 6265 - 6266 - func (_ FfiDestroyerWriteError) Destroy(value *WriteError) { 6267 - switch variantValue := value.err.(type) { 6268 - case WriteErrorPrivateKeySize: 6269 - variantValue.destroy() 6270 - default: 6271 - _ = variantValue 6272 - panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerWriteError.Destroy", value)) 6273 - } 6274 - } 6275 - 6276 type WriteError2 struct { 6277 err error 6278 } ··· 6402 } 6403 } 6404 6405 - type FfiConverterOptionalBytes struct{} 6406 - 6407 - var FfiConverterOptionalBytesINSTANCE = FfiConverterOptionalBytes{} 6408 - 6409 - func (c FfiConverterOptionalBytes) Lift(rb RustBufferI) *[]byte { 6410 - return LiftFromRustBuffer[*[]byte](c, rb) 6411 - } 6412 - 6413 - func (_ FfiConverterOptionalBytes) Read(reader io.Reader) *[]byte { 6414 - if readInt8(reader) == 0 { 6415 - return nil 6416 - } 6417 - temp := FfiConverterBytesINSTANCE.Read(reader) 6418 - return &temp 6419 - } 6420 - 6421 - func (c FfiConverterOptionalBytes) Lower(value *[]byte) C.RustBuffer { 6422 - return LowerIntoRustBuffer[*[]byte](c, value) 6423 - } 6424 - 6425 - func (_ FfiConverterOptionalBytes) Write(writer io.Writer, value *[]byte) { 6426 - if value == nil { 6427 - writeInt8(writer, 0) 6428 - } else { 6429 - writeInt8(writer, 1) 6430 - FfiConverterBytesINSTANCE.Write(writer, *value) 6431 - } 6432 - } 6433 - 6434 - type FfiDestroyerOptionalBytes struct{} 6435 - 6436 - func (_ FfiDestroyerOptionalBytes) Destroy(value *[]byte) { 6437 - if value != nil { 6438 - FfiDestroyerBytes{}.Destroy(*value) 6439 - } 6440 - } 6441 - 6442 - type FfiConverterOptionalSegmentToSign struct{} 6443 - 6444 - var FfiConverterOptionalSegmentToSignINSTANCE = FfiConverterOptionalSegmentToSign{} 6445 - 6446 - func (c FfiConverterOptionalSegmentToSign) Lift(rb RustBufferI) *SegmentToSign { 6447 - return LiftFromRustBuffer[*SegmentToSign](c, rb) 6448 - } 6449 - 6450 - func (_ FfiConverterOptionalSegmentToSign) Read(reader io.Reader) *SegmentToSign { 6451 - if readInt8(reader) == 0 { 6452 - return nil 6453 - } 6454 - temp := FfiConverterSegmentToSignINSTANCE.Read(reader) 6455 - return &temp 6456 - } 6457 - 6458 - func (c FfiConverterOptionalSegmentToSign) Lower(value *SegmentToSign) C.RustBuffer { 6459 - return LowerIntoRustBuffer[*SegmentToSign](c, value) 6460 - } 6461 - 6462 - func (_ FfiConverterOptionalSegmentToSign) Write(writer io.Writer, value *SegmentToSign) { 6463 - if value == nil { 6464 - writeInt8(writer, 0) 6465 - } else { 6466 - writeInt8(writer, 1) 6467 - FfiConverterSegmentToSignINSTANCE.Write(writer, *value) 6468 - } 6469 - } 6470 - 6471 - type FfiDestroyerOptionalSegmentToSign struct{} 6472 - 6473 - func (_ FfiDestroyerOptionalSegmentToSign) Destroy(value *SegmentToSign) { 6474 - if value != nil { 6475 - FfiDestroyerSegmentToSign{}.Destroy(*value) 6476 - } 6477 - } 6478 - 6479 - type FfiConverterOptionalStream struct{} 6480 - 6481 - var FfiConverterOptionalStreamINSTANCE = FfiConverterOptionalStream{} 6482 - 6483 - func (c FfiConverterOptionalStream) Lift(rb RustBufferI) *Stream { 6484 - return LiftFromRustBuffer[*Stream](c, rb) 6485 - } 6486 - 6487 - func (_ FfiConverterOptionalStream) Read(reader io.Reader) *Stream { 6488 - if readInt8(reader) == 0 { 6489 - return nil 6490 - } 6491 - temp := FfiConverterStreamINSTANCE.Read(reader) 6492 - return &temp 6493 - } 6494 - 6495 - func (c FfiConverterOptionalStream) Lower(value *Stream) C.RustBuffer { 6496 - return LowerIntoRustBuffer[*Stream](c, value) 6497 - } 6498 - 6499 - func (_ FfiConverterOptionalStream) Write(writer io.Writer, value *Stream) { 6500 - if value == nil { 6501 - writeInt8(writer, 0) 6502 - } else { 6503 - writeInt8(writer, 1) 6504 - FfiConverterStreamINSTANCE.Write(writer, *value) 6505 - } 6506 - } 6507 - 6508 - type FfiDestroyerOptionalStream struct{} 6509 - 6510 - func (_ FfiDestroyerOptionalStream) Destroy(value *Stream) { 6511 - if value != nil { 6512 - FfiDestroyerStream{}.Destroy(*value) 6513 - } 6514 - } 6515 - 6516 - type FfiConverterOptionalSubscribeItem struct{} 6517 - 6518 - var FfiConverterOptionalSubscribeItemINSTANCE = FfiConverterOptionalSubscribeItem{} 6519 - 6520 - func (c FfiConverterOptionalSubscribeItem) Lift(rb RustBufferI) *SubscribeItem { 6521 - return LiftFromRustBuffer[*SubscribeItem](c, rb) 6522 - } 6523 - 6524 - func (_ FfiConverterOptionalSubscribeItem) Read(reader io.Reader) *SubscribeItem { 6525 - if readInt8(reader) == 0 { 6526 - return nil 6527 - } 6528 - temp := FfiConverterSubscribeItemINSTANCE.Read(reader) 6529 - return &temp 6530 - } 6531 - 6532 - func (c FfiConverterOptionalSubscribeItem) Lower(value *SubscribeItem) C.RustBuffer { 6533 - return LowerIntoRustBuffer[*SubscribeItem](c, value) 6534 - } 6535 - 6536 - func (_ FfiConverterOptionalSubscribeItem) Write(writer io.Writer, value *SubscribeItem) { 6537 - if value == nil { 6538 - writeInt8(writer, 0) 6539 - } else { 6540 - writeInt8(writer, 1) 6541 - FfiConverterSubscribeItemINSTANCE.Write(writer, *value) 6542 - } 6543 - } 6544 - 6545 - type FfiDestroyerOptionalSubscribeItem struct{} 6546 - 6547 - func (_ FfiDestroyerOptionalSubscribeItem) Destroy(value *SubscribeItem) { 6548 - if value != nil { 6549 - FfiDestroyerSubscribeItem{}.Destroy(*value) 6550 - } 6551 - } 6552 - 6553 type FfiConverterSequenceString struct{} 6554 6555 var FfiConverterSequenceStringINSTANCE = FfiConverterSequenceString{} ··· 6593 } 6594 } 6595 6596 - type FfiConverterSequencePublicKey struct{} 6597 - 6598 - var FfiConverterSequencePublicKeyINSTANCE = FfiConverterSequencePublicKey{} 6599 - 6600 - func (c FfiConverterSequencePublicKey) Lift(rb RustBufferI) []*PublicKey { 6601 - return LiftFromRustBuffer[[]*PublicKey](c, rb) 6602 - } 6603 - 6604 - func (c FfiConverterSequencePublicKey) Read(reader io.Reader) []*PublicKey { 6605 - length := readInt32(reader) 6606 - if length == 0 { 6607 - return nil 6608 - } 6609 - result := make([]*PublicKey, 0, length) 6610 - for i := int32(0); i < length; i++ { 6611 - result = append(result, FfiConverterPublicKeyINSTANCE.Read(reader)) 6612 - } 6613 - return result 6614 - } 6615 - 6616 - func (c FfiConverterSequencePublicKey) Lower(value []*PublicKey) C.RustBuffer { 6617 - return LowerIntoRustBuffer[[]*PublicKey](c, value) 6618 - } 6619 - 6620 - func (c FfiConverterSequencePublicKey) Write(writer io.Writer, value []*PublicKey) { 6621 - if len(value) > math.MaxInt32 { 6622 - panic("[]*PublicKey is too large to fit into Int32") 6623 - } 6624 - 6625 - writeInt32(writer, int32(len(value))) 6626 - for _, item := range value { 6627 - FfiConverterPublicKeyINSTANCE.Write(writer, item) 6628 - } 6629 - } 6630 - 6631 - type FfiDestroyerSequencePublicKey struct{} 6632 - 6633 - func (FfiDestroyerSequencePublicKey) Destroy(sequence []*PublicKey) { 6634 - for _, value := range sequence { 6635 - FfiDestroyerPublicKey{}.Destroy(value) 6636 - } 6637 - } 6638 - 6639 - type FfiConverterSequenceEntry struct{} 6640 - 6641 - var FfiConverterSequenceEntryINSTANCE = FfiConverterSequenceEntry{} 6642 - 6643 - func (c FfiConverterSequenceEntry) Lift(rb RustBufferI) []Entry { 6644 - return LiftFromRustBuffer[[]Entry](c, rb) 6645 - } 6646 - 6647 - func (c FfiConverterSequenceEntry) Read(reader io.Reader) []Entry { 6648 - length := readInt32(reader) 6649 - if length == 0 { 6650 - return nil 6651 - } 6652 - result := make([]Entry, 0, length) 6653 - for i := int32(0); i < length; i++ { 6654 - result = append(result, FfiConverterEntryINSTANCE.Read(reader)) 6655 - } 6656 - return result 6657 - } 6658 - 6659 - func (c FfiConverterSequenceEntry) Lower(value []Entry) C.RustBuffer { 6660 - return LowerIntoRustBuffer[[]Entry](c, value) 6661 - } 6662 - 6663 - func (c FfiConverterSequenceEntry) Write(writer io.Writer, value []Entry) { 6664 - if len(value) > math.MaxInt32 { 6665 - panic("[]Entry is too large to fit into Int32") 6666 - } 6667 - 6668 - writeInt32(writer, int32(len(value))) 6669 - for _, item := range value { 6670 - FfiConverterEntryINSTANCE.Write(writer, item) 6671 - } 6672 - } 6673 - 6674 - type FfiDestroyerSequenceEntry struct{} 6675 - 6676 - func (FfiDestroyerSequenceEntry) Destroy(sequence []Entry) { 6677 - for _, value := range sequence { 6678 - FfiDestroyerEntry{}.Destroy(value) 6679 - } 6680 - } 6681 - 6682 const ( 6683 uniffiRustFuturePollReady int8 = 0 6684 uniffiRustFuturePollMaybeReady int8 = 1 ··· 6742 guard <- struct{}{} 6743 } 6744 6745 - func GetManifestAndCert(data Stream) (string, error) { 6746 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { 6747 - return GoRustBuffer{ 6748 - inner: C.uniffi_iroh_streamplace_fn_func_get_manifest_and_cert(FfiConverterStreamINSTANCE.Lower(data), _uniffiStatus), 6749 - } 6750 - }) 6751 - if _uniffiErr != nil { 6752 - var _uniffiDefaultValue string 6753 - return _uniffiDefaultValue, _uniffiErr 6754 - } else { 6755 - return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil 6756 - } 6757 - } 6758 - 6759 - func GetManifests(data Stream) (string, error) { 6760 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { 6761 - return GoRustBuffer{ 6762 - inner: C.uniffi_iroh_streamplace_fn_func_get_manifests(FfiConverterStreamINSTANCE.Lower(data), _uniffiStatus), 6763 - } 6764 - }) 6765 - if _uniffiErr != nil { 6766 - var _uniffiDefaultValue string 6767 - return _uniffiDefaultValue, _uniffiErr 6768 - } else { 6769 - return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil 6770 - } 6771 - } 6772 - 6773 // Initialize logging with the default subscriber that respects RUST_LOG environment variable. 6774 // This function is safe to call multiple times - it will only initialize logging once. 6775 func InitLogging() { ··· 6815 return FfiConverterPublicKeyINSTANCE.Lift(_uniffiRV), nil 6816 } 6817 } 6818 - 6819 - func Resign(segsToSign ManySegmentsToSign, signedConcatData Stream) error { 6820 - _, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) bool { 6821 - C.uniffi_iroh_streamplace_fn_func_resign(FfiConverterManySegmentsToSignINSTANCE.Lower(segsToSign), FfiConverterStreamINSTANCE.Lower(signedConcatData), _uniffiStatus) 6822 - return false 6823 - }) 6824 - return _uniffiErr.AsError() 6825 - } 6826 - 6827 - func Sign(manifest string, data Stream, certsStr string, gosigner GoSigner) ([]byte, error) { 6828 - _uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { 6829 - return GoRustBuffer{ 6830 - inner: C.uniffi_iroh_streamplace_fn_func_sign(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterStringINSTANCE.Lower(certsStr), FfiConverterGoSignerINSTANCE.Lower(gosigner), _uniffiStatus), 6831 - } 6832 - }) 6833 - if _uniffiErr != nil { 6834 - var _uniffiDefaultValue []byte 6835 - return _uniffiDefaultValue, _uniffiErr 6836 - } else { 6837 - return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil 6838 - } 6839 - } 6840 - 6841 - func SignWithIngredients(manifest string, data Stream, certsStr string, ingredients ManyStreams, gosigner GoSigner, output Stream) error { 6842 - _, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) bool { 6843 - C.uniffi_iroh_streamplace_fn_func_sign_with_ingredients(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterStringINSTANCE.Lower(certsStr), FfiConverterManyStreamsINSTANCE.Lower(ingredients), FfiConverterGoSignerINSTANCE.Lower(gosigner), FfiConverterStreamINSTANCE.Lower(output), _uniffiStatus) 6844 - return false 6845 - }) 6846 - return _uniffiErr.AsError() 6847 - } 6848 - 6849 - func SubscribeItemDebug(item SubscribeItem) string { 6850 - return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { 6851 - return GoRustBuffer{ 6852 - inner: C.uniffi_iroh_streamplace_fn_func_subscribe_item_debug(FfiConverterSubscribeItemINSTANCE.Lower(item), _uniffiStatus), 6853 - } 6854 - })) 6855 - }
··· 6 import ( 7 "bytes" 8 "encoding/binary" 9 "fmt" 10 "io" 11 "math" 12 "runtime" 13 "runtime/cgo" 14 "sync/atomic" 15 "unsafe" 16 ) 17 ··· 333 334 func init() { 335 336 uniffiCheckChecksums() 337 } 338 ··· 349 } 350 { 351 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 352 return C.uniffi_iroh_streamplace_checksum_func_init_logging() 353 }) 354 if checksum != 40911 { ··· 385 } 386 { 387 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 388 return C.uniffi_iroh_streamplace_checksum_method_nodeaddr_direct_addresses() 389 }) 390 if checksum != 17536 { ··· 448 } 449 { 450 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 451 return C.uniffi_iroh_streamplace_checksum_method_socket_accept() 452 }) 453 + if checksum != 57029 { 454 // If this happens try cleaning and rebuilding your project 455 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_accept: UniFFI API checksum mismatch") 456 } ··· 468 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 469 return C.uniffi_iroh_streamplace_checksum_method_socket_close() 470 }) 471 + if checksum != 61206 { 472 // If this happens try cleaning and rebuilding your project 473 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_close: UniFFI API checksum mismatch") 474 } ··· 477 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 478 return C.uniffi_iroh_streamplace_checksum_method_socket_connect() 479 }) 480 + if checksum != 10698 { 481 // If this happens try cleaning and rebuilding your project 482 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_connect: UniFFI API checksum mismatch") 483 } ··· 486 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 487 return C.uniffi_iroh_streamplace_checksum_method_socket_online() 488 }) 489 + if checksum != 7658 { 490 // If this happens try cleaning and rebuilding your project 491 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_online: UniFFI API checksum mismatch") 492 } ··· 495 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 496 return C.uniffi_iroh_streamplace_checksum_method_socket_ticket() 497 }) 498 + if checksum != 43285 { 499 // If this happens try cleaning and rebuilding your project 500 panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_socket_ticket: UniFFI API checksum mismatch") 501 } 502 } 503 { 504 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 505 + return C.uniffi_iroh_streamplace_checksum_method_stream_close() 506 }) 507 + if checksum != 42672 { 508 // If this happens try cleaning and rebuilding your project 509 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_close: UniFFI API checksum mismatch") 510 } 511 } 512 { 513 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 514 + return C.uniffi_iroh_streamplace_checksum_method_stream_close_read() 515 }) 516 + if checksum != 37182 { 517 // If this happens try cleaning and rebuilding your project 518 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_close_read: UniFFI API checksum mismatch") 519 } 520 } 521 { 522 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 523 + return C.uniffi_iroh_streamplace_checksum_method_stream_close_write() 524 }) 525 + if checksum != 3902 { 526 // If this happens try cleaning and rebuilding your project 527 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_close_write: UniFFI API checksum mismatch") 528 } 529 } 530 { 531 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 532 + return C.uniffi_iroh_streamplace_checksum_method_stream_closed() 533 }) 534 + if checksum != 29084 { 535 // If this happens try cleaning and rebuilding your project 536 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_closed: UniFFI API checksum mismatch") 537 } 538 } 539 { 540 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 541 + return C.uniffi_iroh_streamplace_checksum_method_stream_read() 542 }) 543 + if checksum != 28625 { 544 // If this happens try cleaning and rebuilding your project 545 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_read: UniFFI API checksum mismatch") 546 } 547 } 548 { 549 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 550 + return C.uniffi_iroh_streamplace_checksum_method_stream_write() 551 }) 552 + if checksum != 7829 { 553 // If this happens try cleaning and rebuilding your project 554 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_write: UniFFI API checksum mismatch") 555 } 556 } 557 { 558 checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { 559 + return C.uniffi_iroh_streamplace_checksum_method_stream_write_all() 560 }) 561 + if checksum != 28367 { 562 // If this happens try cleaning and rebuilding your project 563 + panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_stream_write_all: UniFFI API checksum mismatch") 564 } 565 } 566 { ··· 649 650 func (FfiDestroyerUint64) Destroy(_ uint64) {} 651 652 type FfiConverterBool struct{} 653 654 var FfiConverterBoolINSTANCE = FfiConverterBool{} ··· 774 775 func (FfiDestroyerBytes) Destroy(_ []byte) {} 776 777 // Below is an implementation of synchronization requirements outlined in the link. 778 // https://github.com/mozilla/uniffi-rs/blob/0dc031132d9493ca812c3af6e7dd60ad2ea95bf0/uniffi_bindgen/src/bindings/kotlin/templates/ObjectRuntime.kt#L31 779 ··· 837 }) 838 } 839 840 // A peer and it's addressing information. 841 type NodeAddrInterface interface { 842 // Get the direct addresses of this peer. ··· 1094 value.Destroy() 1095 } 1096 1097 // A wrapper for an iroh endpoint that works basically as a socket for streams. 1098 type SocketInterface interface { 1099 + // Accept an incoming connection and return a [`Stream`]. 1100 + Accept() (*Stream, error) 1101 // Get the ALPN for this socket. 1102 Alpn() []byte 1103 + // Close the socket. 1104 Close() 1105 + // Connect to a peer at the given [`NodeAddr`] and return a [`Stream`]. 1106 + Connect(addr *NodeAddr) (*Stream, error) 1107 + // Wait until the socket is online. 1108 Online() 1109 + // Get the ticket for this socket. 1110 Ticket() string 1111 } 1112 ··· 1146 return res, err 1147 } 1148 1149 + // Accept an incoming connection and return a [`Stream`]. 1150 + func (_self *Socket) Accept() (*Stream, error) { 1151 _pointer := _self.ffiObject.incrementPointer("*Socket") 1152 defer _self.ffiObject.decrementPointer() 1153 res, err := uniffiRustCallAsync[AcceptError]( ··· 1158 return res 1159 }, 1160 // liftFn 1161 + func(ffi unsafe.Pointer) *Stream { 1162 + return FfiConverterStreamINSTANCE.Lift(ffi) 1163 }, 1164 C.uniffi_iroh_streamplace_fn_method_socket_accept( 1165 _pointer), ··· 1192 })) 1193 } 1194 1195 + // Close the socket. 1196 func (_self *Socket) Close() { 1197 _pointer := _self.ffiObject.incrementPointer("*Socket") 1198 defer _self.ffiObject.decrementPointer() ··· 1219 1220 } 1221 1222 + // Connect to a peer at the given [`NodeAddr`] and return a [`Stream`]. 1223 + func (_self *Socket) Connect(addr *NodeAddr) (*Stream, error) { 1224 _pointer := _self.ffiObject.incrementPointer("*Socket") 1225 defer _self.ffiObject.decrementPointer() 1226 res, err := uniffiRustCallAsync[ConnectError]( ··· 1231 return res 1232 }, 1233 // liftFn 1234 + func(ffi unsafe.Pointer) *Stream { 1235 + return FfiConverterStreamINSTANCE.Lift(ffi) 1236 }, 1237 C.uniffi_iroh_streamplace_fn_method_socket_connect( 1238 _pointer, FfiConverterNodeAddrINSTANCE.Lower(addr)), ··· 1253 return res, err 1254 } 1255 1256 + // Wait until the socket is online. 1257 func (_self *Socket) Online() { 1258 _pointer := _self.ffiObject.incrementPointer("*Socket") 1259 defer _self.ffiObject.decrementPointer() ··· 1280 1281 } 1282 1283 + // Get the ticket for this socket. 1284 func (_self *Socket) Ticket() string { 1285 _pointer := _self.ffiObject.incrementPointer("*Socket") 1286 defer _self.ffiObject.decrementPointer() ··· 1340 value.Destroy() 1341 } 1342 1343 + // A bidirectional stream over an iroh connection. 1344 + // 1345 + // In QUIC streams and connections are separate concepts. A connection can have multiple streams. 1346 + // For simplicity we expose a single bidirectional stream per connection here. 1347 + type StreamInterface interface { 1348 + // Close the underlying connection. 1349 Close() 1350 + // Close the read side of the stream. 1351 + // 1352 + // Note: this does not close the underlying connection. 1353 CloseRead() error 1354 + // Close the write side of the stream. 1355 + // 1356 + // Note: this does not close the underlying connection. 1357 CloseWrite() error 1358 + // Wait until the connection is closed. 1359 Closed() 1360 + // Read up to n bytes from the stream. 1361 + // 1362 + // Due to the way uniffi works, this can't have the signature that is 1363 + // usually used in golang code. Instead of taking a mutable buffer and 1364 + // returning the number of bytes read, it takes the number of bytes to read 1365 + // and returns a vector with the data read. 1366 + // 1367 + // Wrapping this into a more idiomatic golang interface needs a few lines 1368 + // on the golang side. 1369 Read(n uint64) ([]byte, error) 1370 + // Write up to n bytes from buf to the stream. 1371 Write(buf []byte) (uint32, error) 1372 + // Write all bytes in buf to the stream. 1373 WriteAll(buf []byte) error 1374 } 1375 + 1376 + // A bidirectional stream over an iroh connection. 1377 + // 1378 + // In QUIC streams and connections are separate concepts. A connection can have multiple streams. 1379 + // For simplicity we expose a single bidirectional stream per connection here. 1380 + type Stream struct { 1381 ffiObject FfiObject 1382 } 1383 1384 + // Close the underlying connection. 1385 + func (_self *Stream) Close() { 1386 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1387 defer _self.ffiObject.decrementPointer() 1388 rustCall(func(_uniffiStatus *C.RustCallStatus) bool { 1389 + C.uniffi_iroh_streamplace_fn_method_stream_close( 1390 _pointer, _uniffiStatus) 1391 return false 1392 }) 1393 } 1394 1395 + // Close the read side of the stream. 1396 + // 1397 + // Note: this does not close the underlying connection. 1398 + func (_self *Stream) CloseRead() error { 1399 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1400 defer _self.ffiObject.decrementPointer() 1401 _, err := uniffiRustCallAsync[ReadError]( 1402 FfiConverterReadErrorINSTANCE, ··· 1407 }, 1408 // liftFn 1409 func(_ struct{}) struct{} { return struct{}{} }, 1410 + C.uniffi_iroh_streamplace_fn_method_stream_close_read( 1411 _pointer), 1412 // pollFn 1413 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1426 return err 1427 } 1428 1429 + // Close the write side of the stream. 1430 + // 1431 + // Note: this does not close the underlying connection. 1432 + func (_self *Stream) CloseWrite() error { 1433 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1434 defer _self.ffiObject.decrementPointer() 1435 _, err := uniffiRustCallAsync[WriteError2]( 1436 FfiConverterWriteError2INSTANCE, ··· 1441 }, 1442 // liftFn 1443 func(_ struct{}) struct{} { return struct{}{} }, 1444 + C.uniffi_iroh_streamplace_fn_method_stream_close_write( 1445 _pointer), 1446 // pollFn 1447 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1460 return err 1461 } 1462 1463 + // Wait until the connection is closed. 1464 + func (_self *Stream) Closed() { 1465 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1466 defer _self.ffiObject.decrementPointer() 1467 uniffiRustCallAsync[error]( 1468 nil, ··· 1473 }, 1474 // liftFn 1475 func(_ struct{}) struct{} { return struct{}{} }, 1476 + C.uniffi_iroh_streamplace_fn_method_stream_closed( 1477 _pointer), 1478 // pollFn 1479 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1487 1488 } 1489 1490 + // Read up to n bytes from the stream. 1491 + // 1492 + // Due to the way uniffi works, this can't have the signature that is 1493 + // usually used in golang code. Instead of taking a mutable buffer and 1494 + // returning the number of bytes read, it takes the number of bytes to read 1495 + // and returns a vector with the data read. 1496 + // 1497 + // Wrapping this into a more idiomatic golang interface needs a few lines 1498 + // on the golang side. 1499 + func (_self *Stream) Read(n uint64) ([]byte, error) { 1500 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1501 defer _self.ffiObject.decrementPointer() 1502 res, err := uniffiRustCallAsync[ReadError]( 1503 FfiConverterReadErrorINSTANCE, ··· 1512 func(ffi RustBufferI) []byte { 1513 return FfiConverterBytesINSTANCE.Lift(ffi) 1514 }, 1515 + C.uniffi_iroh_streamplace_fn_method_stream_read( 1516 _pointer, FfiConverterUint64INSTANCE.Lower(n)), 1517 // pollFn 1518 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1531 return res, err 1532 } 1533 1534 + // Write up to n bytes from buf to the stream. 1535 + func (_self *Stream) Write(buf []byte) (uint32, error) { 1536 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1537 defer _self.ffiObject.decrementPointer() 1538 res, err := uniffiRustCallAsync[WriteError2]( 1539 FfiConverterWriteError2INSTANCE, ··· 1546 func(ffi C.uint32_t) uint32 { 1547 return FfiConverterUint32INSTANCE.Lift(ffi) 1548 }, 1549 + C.uniffi_iroh_streamplace_fn_method_stream_write( 1550 _pointer, FfiConverterBytesINSTANCE.Lower(buf)), 1551 // pollFn 1552 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1565 return res, err 1566 } 1567 1568 + // Write all bytes in buf to the stream. 1569 + func (_self *Stream) WriteAll(buf []byte) error { 1570 + _pointer := _self.ffiObject.incrementPointer("*Stream") 1571 defer _self.ffiObject.decrementPointer() 1572 _, err := uniffiRustCallAsync[WriteError2]( 1573 FfiConverterWriteError2INSTANCE, ··· 1578 }, 1579 // liftFn 1580 func(_ struct{}) struct{} { return struct{}{} }, 1581 + C.uniffi_iroh_streamplace_fn_method_stream_write_all( 1582 _pointer, FfiConverterBytesINSTANCE.Lower(buf)), 1583 // pollFn 1584 func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) { ··· 1596 1597 return err 1598 } 1599 + func (object *Stream) Destroy() { 1600 runtime.SetFinalizer(object, nil) 1601 object.ffiObject.destroy() 1602 } 1603 1604 + type FfiConverterStream struct{} 1605 1606 + var FfiConverterStreamINSTANCE = FfiConverterStream{} 1607 1608 + func (c FfiConverterStream) Lift(pointer unsafe.Pointer) *Stream { 1609 + result := &Stream{ 1610 newFfiObject( 1611 pointer, 1612 func(pointer unsafe.Pointer, status *C.RustCallStatus) unsafe.Pointer { 1613 + return C.uniffi_iroh_streamplace_fn_clone_stream(pointer, status) 1614 }, 1615 func(pointer unsafe.Pointer, status *C.RustCallStatus) { 1616 + C.uniffi_iroh_streamplace_fn_free_stream(pointer, status) 1617 }, 1618 ), 1619 } 1620 + runtime.SetFinalizer(result, (*Stream).Destroy) 1621 return result 1622 } 1623 1624 + func (c FfiConverterStream) Read(reader io.Reader) *Stream { 1625 return c.Lift(unsafe.Pointer(uintptr(readUint64(reader)))) 1626 } 1627 1628 + func (c FfiConverterStream) Lower(value *Stream) unsafe.Pointer { 1629 // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, 1630 // because the pointer will be decremented immediately after this function returns, 1631 // and someone will be left holding onto a non-locked pointer. 1632 + pointer := value.ffiObject.incrementPointer("*Stream") 1633 defer value.ffiObject.decrementPointer() 1634 return pointer 1635 1636 } 1637 1638 + func (c FfiConverterStream) Write(writer io.Writer, value *Stream) { 1639 writeUint64(writer, uint64(uintptr(c.Lower(value)))) 1640 } 1641 1642 + type FfiDestroyerStream struct{} 1643 1644 + func (_ FfiDestroyerStream) Destroy(value *Stream) { 1645 value.Destroy() 1646 } 1647 1648 // Configuration for creating a [`Socket`]. 1649 type SocketConfig struct { 1650 + // A 32-byte secret key for the socket. 1651 Secret []byte 1652 + // The ALPN to use for this socket. 1653 + Alpn []byte 1654 } 1655 1656 func (r *SocketConfig) Destroy() { ··· 1688 value.Destroy() 1689 } 1690 1691 type AcceptError struct { 1692 err error 1693 } ··· 1872 } 1873 } 1874 1875 // Error when converting from ffi NodeAddr to iroh::NodeAddr 1876 type NodeAddrError struct { 1877 err error ··· 1991 } 1992 } 1993 1994 type PublicKeyError struct { 1995 err error 1996 } ··· 2131 } 2132 } 2133 2134 type ReadError struct { 2135 err error 2136 } ··· 2223 } 2224 } 2225 2226 type SocketNewError struct { 2227 err error 2228 } ··· 2315 } 2316 } 2317 2318 // Error when converting from ffi NodeAddr to iroh::NodeAddr 2319 type TicketError struct { 2320 err error ··· 2408 } 2409 } 2410 2411 type WriteError2 struct { 2412 err error 2413 } ··· 2537 } 2538 } 2539 2540 type FfiConverterSequenceString struct{} 2541 2542 var FfiConverterSequenceStringINSTANCE = FfiConverterSequenceString{} ··· 2580 } 2581 } 2582 2583 const ( 2584 uniffiRustFuturePollReady int8 = 0 2585 uniffiRustFuturePollMaybeReady int8 = 1 ··· 2643 guard <- struct{}{} 2644 } 2645 2646 // Initialize logging with the default subscriber that respects RUST_LOG environment variable. 2647 // This function is safe to call multiple times - it will only initialize logging once. 2648 func InitLogging() { ··· 2688 return FfiConverterPublicKeyINSTANCE.Lift(_uniffiRV), nil 2689 } 2690 }
+42 -934
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.h
··· 378 379 380 #endif 381 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_DATA_HANDLER_METHOD0 382 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_DATA_HANDLER_METHOD0 383 - typedef void (*UniffiCallbackInterfaceDataHandlerMethod0)(uint64_t uniffi_handle, void* from, RustBuffer topic, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return); 384 - 385 - // Making function static works arround: 386 - // https://github.com/golang/go/issues/11263 387 - static void call_UniffiCallbackInterfaceDataHandlerMethod0( 388 - UniffiCallbackInterfaceDataHandlerMethod0 cb, uint64_t uniffi_handle, void* from, RustBuffer topic, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return) 389 - { 390 - return cb(uniffi_handle, from, topic, data, uniffi_future_callback, uniffi_callback_data, uniffi_out_return); 391 - } 392 - 393 - 394 - #endif 395 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_GO_SIGNER_METHOD0 396 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_GO_SIGNER_METHOD0 397 - typedef void (*UniffiCallbackInterfaceGoSignerMethod0)(uint64_t uniffi_handle, RustBuffer data, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 398 - 399 - // Making function static works arround: 400 - // https://github.com/golang/go/issues/11263 401 - static void call_UniffiCallbackInterfaceGoSignerMethod0( 402 - UniffiCallbackInterfaceGoSignerMethod0 cb, uint64_t uniffi_handle, RustBuffer data, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 403 - { 404 - return cb(uniffi_handle, data, uniffi_out_return, callStatus ); 405 - } 406 - 407 - 408 - #endif 409 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_MANY_SEGMENTS_TO_SIGN_METHOD0 410 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_MANY_SEGMENTS_TO_SIGN_METHOD0 411 - typedef void (*UniffiCallbackInterfaceManySegmentsToSignMethod0)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 412 - 413 - // Making function static works arround: 414 - // https://github.com/golang/go/issues/11263 415 - static void call_UniffiCallbackInterfaceManySegmentsToSignMethod0( 416 - UniffiCallbackInterfaceManySegmentsToSignMethod0 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 417 - { 418 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 419 - } 420 - 421 - 422 - #endif 423 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_MANY_STREAMS_METHOD0 424 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_MANY_STREAMS_METHOD0 425 - typedef void (*UniffiCallbackInterfaceManyStreamsMethod0)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 426 - 427 - // Making function static works arround: 428 - // https://github.com/golang/go/issues/11263 429 - static void call_UniffiCallbackInterfaceManyStreamsMethod0( 430 - UniffiCallbackInterfaceManyStreamsMethod0 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 431 - { 432 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 433 - } 434 - 435 - 436 - #endif 437 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD0 438 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD0 439 - typedef void (*UniffiCallbackInterfaceSegmentToSignMethod0)(uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ); 440 - 441 - // Making function static works arround: 442 - // https://github.com/golang/go/issues/11263 443 - static void call_UniffiCallbackInterfaceSegmentToSignMethod0( 444 - UniffiCallbackInterfaceSegmentToSignMethod0 cb, uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ) 445 - { 446 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 447 - } 448 - 449 - 450 - #endif 451 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD1 452 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD1 453 - typedef void (*UniffiCallbackInterfaceSegmentToSignMethod1)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 454 - 455 - // Making function static works arround: 456 - // https://github.com/golang/go/issues/11263 457 - static void call_UniffiCallbackInterfaceSegmentToSignMethod1( 458 - UniffiCallbackInterfaceSegmentToSignMethod1 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 459 - { 460 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 461 - } 462 - 463 - 464 - #endif 465 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD2 466 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD2 467 - typedef void (*UniffiCallbackInterfaceSegmentToSignMethod2)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 468 - 469 - // Making function static works arround: 470 - // https://github.com/golang/go/issues/11263 471 - static void call_UniffiCallbackInterfaceSegmentToSignMethod2( 472 - UniffiCallbackInterfaceSegmentToSignMethod2 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 473 - { 474 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 475 - } 476 - 477 - 478 - #endif 479 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD3 480 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD3 481 - typedef void (*UniffiCallbackInterfaceSegmentToSignMethod3)(uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ); 482 - 483 - // Making function static works arround: 484 - // https://github.com/golang/go/issues/11263 485 - static void call_UniffiCallbackInterfaceSegmentToSignMethod3( 486 - UniffiCallbackInterfaceSegmentToSignMethod3 cb, uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ) 487 - { 488 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 489 - } 490 - 491 - 492 - #endif 493 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD4 494 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_SEGMENT_TO_SIGN_METHOD4 495 - typedef void (*UniffiCallbackInterfaceSegmentToSignMethod4)(uint64_t uniffi_handle, void* uniffi_out_return, RustCallStatus* callStatus ); 496 - 497 - // Making function static works arround: 498 - // https://github.com/golang/go/issues/11263 499 - static void call_UniffiCallbackInterfaceSegmentToSignMethod4( 500 - UniffiCallbackInterfaceSegmentToSignMethod4 cb, uint64_t uniffi_handle, void* uniffi_out_return, RustCallStatus* callStatus ) 501 - { 502 - return cb(uniffi_handle, uniffi_out_return, callStatus ); 503 - } 504 - 505 - 506 - #endif 507 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD0 508 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD0 509 - typedef void (*UniffiCallbackInterfaceStreamMethod0)(uint64_t uniffi_handle, uint64_t length, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 510 - 511 - // Making function static works arround: 512 - // https://github.com/golang/go/issues/11263 513 - static void call_UniffiCallbackInterfaceStreamMethod0( 514 - UniffiCallbackInterfaceStreamMethod0 cb, uint64_t uniffi_handle, uint64_t length, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) 515 - { 516 - return cb(uniffi_handle, length, uniffi_out_return, callStatus ); 517 - } 518 - 519 - 520 - #endif 521 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD1 522 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD1 523 - typedef void (*UniffiCallbackInterfaceStreamMethod1)(uint64_t uniffi_handle, int64_t pos, uint64_t mode, uint64_t* uniffi_out_return, RustCallStatus* callStatus ); 524 - 525 - // Making function static works arround: 526 - // https://github.com/golang/go/issues/11263 527 - static void call_UniffiCallbackInterfaceStreamMethod1( 528 - UniffiCallbackInterfaceStreamMethod1 cb, uint64_t uniffi_handle, int64_t pos, uint64_t mode, uint64_t* uniffi_out_return, RustCallStatus* callStatus ) 529 - { 530 - return cb(uniffi_handle, pos, mode, uniffi_out_return, callStatus ); 531 - } 532 - 533 - 534 - #endif 535 - #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD2 536 - #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_STREAM_METHOD2 537 - typedef void (*UniffiCallbackInterfaceStreamMethod2)(uint64_t uniffi_handle, RustBuffer data, uint64_t* uniffi_out_return, RustCallStatus* callStatus ); 538 - 539 - // Making function static works arround: 540 - // https://github.com/golang/go/issues/11263 541 - static void call_UniffiCallbackInterfaceStreamMethod2( 542 - UniffiCallbackInterfaceStreamMethod2 cb, uint64_t uniffi_handle, RustBuffer data, uint64_t* uniffi_out_return, RustCallStatus* callStatus ) 543 - { 544 - return cb(uniffi_handle, data, uniffi_out_return, callStatus ); 545 - } 546 - 547 - 548 - #endif 549 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_DATA_HANDLER 550 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_DATA_HANDLER 551 - typedef struct UniffiVTableCallbackInterfaceDataHandler { 552 - UniffiCallbackInterfaceDataHandlerMethod0 handleData; 553 - UniffiCallbackInterfaceFree uniffiFree; 554 - } UniffiVTableCallbackInterfaceDataHandler; 555 - 556 - #endif 557 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_GO_SIGNER 558 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_GO_SIGNER 559 - typedef struct UniffiVTableCallbackInterfaceGoSigner { 560 - UniffiCallbackInterfaceGoSignerMethod0 sign; 561 - UniffiCallbackInterfaceFree uniffiFree; 562 - } UniffiVTableCallbackInterfaceGoSigner; 563 - 564 - #endif 565 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MANY_SEGMENTS_TO_SIGN 566 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MANY_SEGMENTS_TO_SIGN 567 - typedef struct UniffiVTableCallbackInterfaceManySegmentsToSign { 568 - UniffiCallbackInterfaceManySegmentsToSignMethod0 next; 569 - UniffiCallbackInterfaceFree uniffiFree; 570 - } UniffiVTableCallbackInterfaceManySegmentsToSign; 571 - 572 - #endif 573 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MANY_STREAMS 574 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_MANY_STREAMS 575 - typedef struct UniffiVTableCallbackInterfaceManyStreams { 576 - UniffiCallbackInterfaceManyStreamsMethod0 next; 577 - UniffiCallbackInterfaceFree uniffiFree; 578 - } UniffiVTableCallbackInterfaceManyStreams; 579 - 580 - #endif 581 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_SEGMENT_TO_SIGN 582 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_SEGMENT_TO_SIGN 583 - typedef struct UniffiVTableCallbackInterfaceSegmentToSign { 584 - UniffiCallbackInterfaceSegmentToSignMethod0 unsignedSegStream; 585 - UniffiCallbackInterfaceSegmentToSignMethod1 manifestId; 586 - UniffiCallbackInterfaceSegmentToSignMethod2 cert; 587 - UniffiCallbackInterfaceSegmentToSignMethod3 outputSegStream; 588 - UniffiCallbackInterfaceSegmentToSignMethod4 close; 589 - UniffiCallbackInterfaceFree uniffiFree; 590 - } UniffiVTableCallbackInterfaceSegmentToSign; 591 - 592 - #endif 593 - #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_STREAM 594 - #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_STREAM 595 - typedef struct UniffiVTableCallbackInterfaceStream { 596 - UniffiCallbackInterfaceStreamMethod0 readStream; 597 - UniffiCallbackInterfaceStreamMethod1 seekStream; 598 - UniffiCallbackInterfaceStreamMethod2 writeStream; 599 - UniffiCallbackInterfaceFree uniffiFree; 600 - } UniffiVTableCallbackInterfaceStream; 601 - 602 - #endif 603 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_DATAHANDLER 604 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_DATAHANDLER 605 - void* uniffi_iroh_streamplace_fn_clone_datahandler(void* ptr, RustCallStatus *out_status 606 - ); 607 - #endif 608 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_DATAHANDLER 609 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_DATAHANDLER 610 - void uniffi_iroh_streamplace_fn_free_datahandler(void* ptr, RustCallStatus *out_status 611 - ); 612 - #endif 613 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_DATAHANDLER 614 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_DATAHANDLER 615 - void uniffi_iroh_streamplace_fn_init_callback_vtable_datahandler(UniffiVTableCallbackInterfaceDataHandler* vtable 616 - ); 617 - #endif 618 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA 619 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA 620 - uint64_t uniffi_iroh_streamplace_fn_method_datahandler_handle_data(void* ptr, void* from, RustBuffer topic, RustBuffer data 621 - ); 622 - #endif 623 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_DB 624 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_DB 625 - void* uniffi_iroh_streamplace_fn_clone_db(void* ptr, RustCallStatus *out_status 626 - ); 627 - #endif 628 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_DB 629 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_DB 630 - void uniffi_iroh_streamplace_fn_free_db(void* ptr, RustCallStatus *out_status 631 - ); 632 - #endif 633 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_ITER_WITH_OPTS 634 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_ITER_WITH_OPTS 635 - uint64_t uniffi_iroh_streamplace_fn_method_db_iter_with_opts(void* ptr, void* filter 636 - ); 637 - #endif 638 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SHUTDOWN 639 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SHUTDOWN 640 - uint64_t uniffi_iroh_streamplace_fn_method_db_shutdown(void* ptr 641 - ); 642 - #endif 643 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SUBSCRIBE 644 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SUBSCRIBE 645 - void* uniffi_iroh_streamplace_fn_method_db_subscribe(void* ptr, void* filter, RustCallStatus *out_status 646 - ); 647 - #endif 648 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SUBSCRIBE_WITH_OPTS 649 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_SUBSCRIBE_WITH_OPTS 650 - void* uniffi_iroh_streamplace_fn_method_db_subscribe_with_opts(void* ptr, RustBuffer opts, RustCallStatus *out_status 651 - ); 652 - #endif 653 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_WRITE 654 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DB_WRITE 655 - void* uniffi_iroh_streamplace_fn_method_db_write(void* ptr, RustBuffer secret, RustCallStatus *out_status 656 - ); 657 - #endif 658 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_FILTER 659 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_FILTER 660 - void* uniffi_iroh_streamplace_fn_clone_filter(void* ptr, RustCallStatus *out_status 661 - ); 662 - #endif 663 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_FILTER 664 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_FILTER 665 - void uniffi_iroh_streamplace_fn_free_filter(void* ptr, RustCallStatus *out_status 666 - ); 667 - #endif 668 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_FILTER_NEW 669 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_FILTER_NEW 670 - void* uniffi_iroh_streamplace_fn_constructor_filter_new(RustCallStatus *out_status 671 - 672 - ); 673 - #endif 674 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_GLOBAL 675 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_GLOBAL 676 - void* uniffi_iroh_streamplace_fn_method_filter_global(void* ptr, RustCallStatus *out_status 677 - ); 678 - #endif 679 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_SCOPE 680 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_SCOPE 681 - void* uniffi_iroh_streamplace_fn_method_filter_scope(void* ptr, void* scope, RustCallStatus *out_status 682 - ); 683 - #endif 684 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_SCOPES 685 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_SCOPES 686 - void* uniffi_iroh_streamplace_fn_method_filter_scopes(void* ptr, RustBuffer scopes, RustCallStatus *out_status 687 - ); 688 - #endif 689 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_STREAM 690 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_STREAM 691 - void* uniffi_iroh_streamplace_fn_method_filter_stream(void* ptr, RustBuffer stream, RustCallStatus *out_status 692 - ); 693 - #endif 694 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIME_FROM 695 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIME_FROM 696 - void* uniffi_iroh_streamplace_fn_method_filter_time_from(void* ptr, uint64_t min, RustCallStatus *out_status 697 - ); 698 - #endif 699 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIME_RANGE 700 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIME_RANGE 701 - void* uniffi_iroh_streamplace_fn_method_filter_time_range(void* ptr, uint64_t min, uint64_t max, RustCallStatus *out_status 702 - ); 703 - #endif 704 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIMESTAMPS 705 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_FILTER_TIMESTAMPS 706 - void* uniffi_iroh_streamplace_fn_method_filter_timestamps(void* ptr, RustBuffer min, RustBuffer max, RustCallStatus *out_status 707 - ); 708 - #endif 709 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_GOSIGNER 710 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_GOSIGNER 711 - void* uniffi_iroh_streamplace_fn_clone_gosigner(void* ptr, RustCallStatus *out_status 712 - ); 713 - #endif 714 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_GOSIGNER 715 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_GOSIGNER 716 - void uniffi_iroh_streamplace_fn_free_gosigner(void* ptr, RustCallStatus *out_status 717 - ); 718 - #endif 719 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_GOSIGNER 720 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_GOSIGNER 721 - void uniffi_iroh_streamplace_fn_init_callback_vtable_gosigner(UniffiVTableCallbackInterfaceGoSigner* vtable 722 - ); 723 - #endif 724 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_GOSIGNER_SIGN 725 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_GOSIGNER_SIGN 726 - RustBuffer uniffi_iroh_streamplace_fn_method_gosigner_sign(void* ptr, RustBuffer data, RustCallStatus *out_status 727 - ); 728 - #endif 729 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_MANYSEGMENTSTOSIGN 730 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_MANYSEGMENTSTOSIGN 731 - void* uniffi_iroh_streamplace_fn_clone_manysegmentstosign(void* ptr, RustCallStatus *out_status 732 - ); 733 - #endif 734 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_MANYSEGMENTSTOSIGN 735 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_MANYSEGMENTSTOSIGN 736 - void uniffi_iroh_streamplace_fn_free_manysegmentstosign(void* ptr, RustCallStatus *out_status 737 - ); 738 - #endif 739 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_MANYSEGMENTSTOSIGN 740 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_MANYSEGMENTSTOSIGN 741 - void uniffi_iroh_streamplace_fn_init_callback_vtable_manysegmentstosign(UniffiVTableCallbackInterfaceManySegmentsToSign* vtable 742 - ); 743 - #endif 744 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_MANYSEGMENTSTOSIGN_NEXT 745 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_MANYSEGMENTSTOSIGN_NEXT 746 - RustBuffer uniffi_iroh_streamplace_fn_method_manysegmentstosign_next(void* ptr, RustCallStatus *out_status 747 - ); 748 - #endif 749 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_MANYSTREAMS 750 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_MANYSTREAMS 751 - void* uniffi_iroh_streamplace_fn_clone_manystreams(void* ptr, RustCallStatus *out_status 752 - ); 753 - #endif 754 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_MANYSTREAMS 755 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_MANYSTREAMS 756 - void uniffi_iroh_streamplace_fn_free_manystreams(void* ptr, RustCallStatus *out_status 757 - ); 758 - #endif 759 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_MANYSTREAMS 760 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_MANYSTREAMS 761 - void uniffi_iroh_streamplace_fn_init_callback_vtable_manystreams(UniffiVTableCallbackInterfaceManyStreams* vtable 762 - ); 763 - #endif 764 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_MANYSTREAMS_NEXT 765 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_MANYSTREAMS_NEXT 766 - RustBuffer uniffi_iroh_streamplace_fn_method_manystreams_next(void* ptr, RustCallStatus *out_status 767 - ); 768 - #endif 769 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODE 770 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODE 771 - void* uniffi_iroh_streamplace_fn_clone_node(void* ptr, RustCallStatus *out_status 772 - ); 773 - #endif 774 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_NODE 775 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_NODE 776 - void uniffi_iroh_streamplace_fn_free_node(void* ptr, RustCallStatus *out_status 777 - ); 778 - #endif 779 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_FORWARDER 780 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_FORWARDER 781 - uint64_t uniffi_iroh_streamplace_fn_constructor_node_forwarder(RustBuffer config 782 - ); 783 - #endif 784 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_RECEIVER 785 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_RECEIVER 786 - uint64_t uniffi_iroh_streamplace_fn_constructor_node_receiver(RustBuffer config, void* handler 787 - ); 788 - #endif 789 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_SENDER 790 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CONSTRUCTOR_NODE_SENDER 791 - uint64_t uniffi_iroh_streamplace_fn_constructor_node_sender(RustBuffer config 792 - ); 793 - #endif 794 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_ADD_TICKETS 795 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_ADD_TICKETS 796 - uint64_t uniffi_iroh_streamplace_fn_method_node_add_tickets(void* ptr, RustBuffer peers 797 - ); 798 - #endif 799 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_DB 800 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_DB 801 - void* uniffi_iroh_streamplace_fn_method_node_db(void* ptr, RustCallStatus *out_status 802 - ); 803 - #endif 804 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_JOIN_PEERS 805 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_JOIN_PEERS 806 - uint64_t uniffi_iroh_streamplace_fn_method_node_join_peers(void* ptr, RustBuffer peers 807 - ); 808 - #endif 809 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_NODE_ID 810 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_NODE_ID 811 - uint64_t uniffi_iroh_streamplace_fn_method_node_node_id(void* ptr 812 - ); 813 - #endif 814 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_NODE_SCOPE 815 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_NODE_SCOPE 816 - void* uniffi_iroh_streamplace_fn_method_node_node_scope(void* ptr, RustCallStatus *out_status 817 - ); 818 - #endif 819 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SEND_SEGMENT 820 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SEND_SEGMENT 821 - uint64_t uniffi_iroh_streamplace_fn_method_node_send_segment(void* ptr, RustBuffer key, RustBuffer data 822 - ); 823 - #endif 824 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SHUTDOWN 825 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SHUTDOWN 826 - uint64_t uniffi_iroh_streamplace_fn_method_node_shutdown(void* ptr 827 - ); 828 - #endif 829 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SUBSCRIBE 830 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_SUBSCRIBE 831 - uint64_t uniffi_iroh_streamplace_fn_method_node_subscribe(void* ptr, RustBuffer key, void* remote_id 832 - ); 833 - #endif 834 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_TICKET 835 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_TICKET 836 - uint64_t uniffi_iroh_streamplace_fn_method_node_ticket(void* ptr 837 - ); 838 - #endif 839 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_UNSUBSCRIBE 840 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_NODE_UNSUBSCRIBE 841 - uint64_t uniffi_iroh_streamplace_fn_method_node_unsubscribe(void* ptr, RustBuffer key, void* remote_id 842 - ); 843 - #endif 844 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODEADDR 845 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODEADDR 846 void* uniffi_iroh_streamplace_fn_clone_nodeaddr(void* ptr, RustCallStatus *out_status ··· 916 RustBuffer uniffi_iroh_streamplace_fn_method_publickey_uniffi_trait_display(void* ptr, RustCallStatus *out_status 917 ); 918 #endif 919 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SEGMENTTOSIGN 920 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SEGMENTTOSIGN 921 - void* uniffi_iroh_streamplace_fn_clone_segmenttosign(void* ptr, RustCallStatus *out_status 922 - ); 923 - #endif 924 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_SEGMENTTOSIGN 925 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_SEGMENTTOSIGN 926 - void uniffi_iroh_streamplace_fn_free_segmenttosign(void* ptr, RustCallStatus *out_status 927 - ); 928 - #endif 929 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_SEGMENTTOSIGN 930 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_SEGMENTTOSIGN 931 - void uniffi_iroh_streamplace_fn_init_callback_vtable_segmenttosign(UniffiVTableCallbackInterfaceSegmentToSign* vtable 932 - ); 933 - #endif 934 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_UNSIGNED_SEG_STREAM 935 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_UNSIGNED_SEG_STREAM 936 - void* uniffi_iroh_streamplace_fn_method_segmenttosign_unsigned_seg_stream(void* ptr, RustCallStatus *out_status 937 - ); 938 - #endif 939 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_MANIFEST_ID 940 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_MANIFEST_ID 941 - RustBuffer uniffi_iroh_streamplace_fn_method_segmenttosign_manifest_id(void* ptr, RustCallStatus *out_status 942 - ); 943 - #endif 944 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_CERT 945 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_CERT 946 - RustBuffer uniffi_iroh_streamplace_fn_method_segmenttosign_cert(void* ptr, RustCallStatus *out_status 947 - ); 948 - #endif 949 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_OUTPUT_SEG_STREAM 950 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_OUTPUT_SEG_STREAM 951 - void* uniffi_iroh_streamplace_fn_method_segmenttosign_output_seg_stream(void* ptr, RustCallStatus *out_status 952 - ); 953 - #endif 954 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_CLOSE 955 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SEGMENTTOSIGN_CLOSE 956 - void uniffi_iroh_streamplace_fn_method_segmenttosign_close(void* ptr, RustCallStatus *out_status 957 - ); 958 - #endif 959 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SOCKET 960 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SOCKET 961 void* uniffi_iroh_streamplace_fn_clone_socket(void* ptr, RustCallStatus *out_status ··· 1011 void uniffi_iroh_streamplace_fn_free_stream(void* ptr, RustCallStatus *out_status 1012 ); 1013 #endif 1014 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_STREAM 1015 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_INIT_CALLBACK_VTABLE_STREAM 1016 - void uniffi_iroh_streamplace_fn_init_callback_vtable_stream(UniffiVTableCallbackInterfaceStream* vtable 1017 - ); 1018 - #endif 1019 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_READ_STREAM 1020 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_READ_STREAM 1021 - RustBuffer uniffi_iroh_streamplace_fn_method_stream_read_stream(void* ptr, uint64_t length, RustCallStatus *out_status 1022 - ); 1023 - #endif 1024 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_SEEK_STREAM 1025 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_SEEK_STREAM 1026 - uint64_t uniffi_iroh_streamplace_fn_method_stream_seek_stream(void* ptr, int64_t pos, uint64_t mode, RustCallStatus *out_status 1027 - ); 1028 - #endif 1029 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE_STREAM 1030 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE_STREAM 1031 - uint64_t uniffi_iroh_streamplace_fn_method_stream_write_stream(void* ptr, RustBuffer data, RustCallStatus *out_status 1032 - ); 1033 - #endif 1034 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_STREAM2 1035 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_STREAM2 1036 - void* uniffi_iroh_streamplace_fn_clone_stream2(void* ptr, RustCallStatus *out_status 1037 - ); 1038 - #endif 1039 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_STREAM2 1040 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_STREAM2 1041 - void uniffi_iroh_streamplace_fn_free_stream2(void* ptr, RustCallStatus *out_status 1042 - ); 1043 - #endif 1044 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE 1045 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE 1046 - void uniffi_iroh_streamplace_fn_method_stream2_close(void* ptr, RustCallStatus *out_status 1047 - ); 1048 - #endif 1049 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE_READ 1050 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE_READ 1051 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_close_read(void* ptr 1052 - ); 1053 - #endif 1054 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE_WRITE 1055 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSE_WRITE 1056 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_close_write(void* ptr 1057 - ); 1058 - #endif 1059 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSED 1060 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_CLOSED 1061 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_closed(void* ptr 1062 ); 1063 #endif 1064 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_READ 1065 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_READ 1066 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_read(void* ptr, uint64_t n 1067 ); 1068 #endif 1069 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_WRITE 1070 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_WRITE 1071 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_write(void* ptr, RustBuffer buf 1072 ); 1073 #endif 1074 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_WRITE_ALL 1075 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM2_WRITE_ALL 1076 - uint64_t uniffi_iroh_streamplace_fn_method_stream2_write_all(void* ptr, RustBuffer buf 1077 ); 1078 #endif 1079 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SUBSCRIBERESPONSE 1080 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SUBSCRIBERESPONSE 1081 - void* uniffi_iroh_streamplace_fn_clone_subscriberesponse(void* ptr, RustCallStatus *out_status 1082 ); 1083 #endif 1084 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_SUBSCRIBERESPONSE 1085 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_SUBSCRIBERESPONSE 1086 - void uniffi_iroh_streamplace_fn_free_subscriberesponse(void* ptr, RustCallStatus *out_status 1087 - ); 1088 - #endif 1089 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SUBSCRIBERESPONSE_NEXT_RAW 1090 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SUBSCRIBERESPONSE_NEXT_RAW 1091 - uint64_t uniffi_iroh_streamplace_fn_method_subscriberesponse_next_raw(void* ptr 1092 - ); 1093 - #endif 1094 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SUBSCRIBERESPONSE_UNIFFI_TRAIT_DEBUG 1095 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SUBSCRIBERESPONSE_UNIFFI_TRAIT_DEBUG 1096 - RustBuffer uniffi_iroh_streamplace_fn_method_subscriberesponse_uniffi_trait_debug(void* ptr, RustCallStatus *out_status 1097 - ); 1098 - #endif 1099 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_WRITESCOPE 1100 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_WRITESCOPE 1101 - void* uniffi_iroh_streamplace_fn_clone_writescope(void* ptr, RustCallStatus *out_status 1102 - ); 1103 - #endif 1104 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_WRITESCOPE 1105 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FREE_WRITESCOPE 1106 - void uniffi_iroh_streamplace_fn_free_writescope(void* ptr, RustCallStatus *out_status 1107 - ); 1108 - #endif 1109 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_WRITESCOPE_PUT 1110 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_WRITESCOPE_PUT 1111 - uint64_t uniffi_iroh_streamplace_fn_method_writescope_put(void* ptr, RustBuffer stream, RustBuffer key, RustBuffer value 1112 - ); 1113 - #endif 1114 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_GET_MANIFEST_AND_CERT 1115 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_GET_MANIFEST_AND_CERT 1116 - RustBuffer uniffi_iroh_streamplace_fn_func_get_manifest_and_cert(void* data, RustCallStatus *out_status 1117 ); 1118 #endif 1119 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_GET_MANIFESTS 1120 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_GET_MANIFESTS 1121 - RustBuffer uniffi_iroh_streamplace_fn_func_get_manifests(void* data, RustCallStatus *out_status 1122 ); 1123 #endif 1124 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_INIT_LOGGING ··· 1140 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_NODE_ID_FROM_TICKET 1141 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_NODE_ID_FROM_TICKET 1142 void* uniffi_iroh_streamplace_fn_func_node_id_from_ticket(RustBuffer ticket_str, RustCallStatus *out_status 1143 - ); 1144 - #endif 1145 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_RESIGN 1146 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_RESIGN 1147 - void uniffi_iroh_streamplace_fn_func_resign(void* segs_to_sign, void* signed_concat_data, RustCallStatus *out_status 1148 - ); 1149 - #endif 1150 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN 1151 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN 1152 - RustBuffer uniffi_iroh_streamplace_fn_func_sign(RustBuffer manifest, void* data, RustBuffer certs_str, void* gosigner, RustCallStatus *out_status 1153 - ); 1154 - #endif 1155 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN_WITH_INGREDIENTS 1156 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN_WITH_INGREDIENTS 1157 - void uniffi_iroh_streamplace_fn_func_sign_with_ingredients(RustBuffer manifest, void* data, RustBuffer certs_str, void* ingredients, void* gosigner, void* output, RustCallStatus *out_status 1158 - ); 1159 - #endif 1160 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SUBSCRIBE_ITEM_DEBUG 1161 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SUBSCRIBE_ITEM_DEBUG 1162 - RustBuffer uniffi_iroh_streamplace_fn_func_subscribe_item_debug(RustBuffer item, RustCallStatus *out_status 1163 ); 1164 #endif 1165 #ifndef UNIFFI_FFIDEF_FFI_IROH_STREAMPLACE_RUSTBUFFER_ALLOC ··· 1442 void ffi_iroh_streamplace_rust_future_complete_void(uint64_t handle, RustCallStatus *out_status 1443 ); 1444 #endif 1445 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_GET_MANIFEST_AND_CERT 1446 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_GET_MANIFEST_AND_CERT 1447 - uint16_t uniffi_iroh_streamplace_checksum_func_get_manifest_and_cert(void 1448 - 1449 - ); 1450 - #endif 1451 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_GET_MANIFESTS 1452 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_GET_MANIFESTS 1453 - uint16_t uniffi_iroh_streamplace_checksum_func_get_manifests(void 1454 - 1455 - ); 1456 - #endif 1457 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_INIT_LOGGING 1458 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_INIT_LOGGING 1459 uint16_t uniffi_iroh_streamplace_checksum_func_init_logging(void ··· 1478 1479 ); 1480 #endif 1481 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_RESIGN 1482 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_RESIGN 1483 - uint16_t uniffi_iroh_streamplace_checksum_func_resign(void 1484 - 1485 - ); 1486 - #endif 1487 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SIGN 1488 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SIGN 1489 - uint16_t uniffi_iroh_streamplace_checksum_func_sign(void 1490 - 1491 - ); 1492 - #endif 1493 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SIGN_WITH_INGREDIENTS 1494 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SIGN_WITH_INGREDIENTS 1495 - uint16_t uniffi_iroh_streamplace_checksum_func_sign_with_ingredients(void 1496 - 1497 - ); 1498 - #endif 1499 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SUBSCRIBE_ITEM_DEBUG 1500 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_SUBSCRIBE_ITEM_DEBUG 1501 - uint16_t uniffi_iroh_streamplace_checksum_func_subscribe_item_debug(void 1502 - 1503 - ); 1504 - #endif 1505 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DATAHANDLER_HANDLE_DATA 1506 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DATAHANDLER_HANDLE_DATA 1507 - uint16_t uniffi_iroh_streamplace_checksum_method_datahandler_handle_data(void 1508 - 1509 - ); 1510 - #endif 1511 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_ITER_WITH_OPTS 1512 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_ITER_WITH_OPTS 1513 - uint16_t uniffi_iroh_streamplace_checksum_method_db_iter_with_opts(void 1514 - 1515 - ); 1516 - #endif 1517 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SHUTDOWN 1518 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SHUTDOWN 1519 - uint16_t uniffi_iroh_streamplace_checksum_method_db_shutdown(void 1520 - 1521 - ); 1522 - #endif 1523 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SUBSCRIBE 1524 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SUBSCRIBE 1525 - uint16_t uniffi_iroh_streamplace_checksum_method_db_subscribe(void 1526 - 1527 - ); 1528 - #endif 1529 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SUBSCRIBE_WITH_OPTS 1530 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_SUBSCRIBE_WITH_OPTS 1531 - uint16_t uniffi_iroh_streamplace_checksum_method_db_subscribe_with_opts(void 1532 - 1533 - ); 1534 - #endif 1535 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_WRITE 1536 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_DB_WRITE 1537 - uint16_t uniffi_iroh_streamplace_checksum_method_db_write(void 1538 - 1539 - ); 1540 - #endif 1541 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_GLOBAL 1542 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_GLOBAL 1543 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_global(void 1544 - 1545 - ); 1546 - #endif 1547 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_SCOPE 1548 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_SCOPE 1549 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_scope(void 1550 - 1551 - ); 1552 - #endif 1553 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_SCOPES 1554 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_SCOPES 1555 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_scopes(void 1556 - 1557 - ); 1558 - #endif 1559 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_STREAM 1560 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_STREAM 1561 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_stream(void 1562 - 1563 - ); 1564 - #endif 1565 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIME_FROM 1566 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIME_FROM 1567 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_time_from(void 1568 - 1569 - ); 1570 - #endif 1571 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIME_RANGE 1572 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIME_RANGE 1573 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_time_range(void 1574 - 1575 - ); 1576 - #endif 1577 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIMESTAMPS 1578 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_FILTER_TIMESTAMPS 1579 - uint16_t uniffi_iroh_streamplace_checksum_method_filter_timestamps(void 1580 - 1581 - ); 1582 - #endif 1583 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_GOSIGNER_SIGN 1584 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_GOSIGNER_SIGN 1585 - uint16_t uniffi_iroh_streamplace_checksum_method_gosigner_sign(void 1586 - 1587 - ); 1588 - #endif 1589 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_MANYSEGMENTSTOSIGN_NEXT 1590 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_MANYSEGMENTSTOSIGN_NEXT 1591 - uint16_t uniffi_iroh_streamplace_checksum_method_manysegmentstosign_next(void 1592 - 1593 - ); 1594 - #endif 1595 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_MANYSTREAMS_NEXT 1596 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_MANYSTREAMS_NEXT 1597 - uint16_t uniffi_iroh_streamplace_checksum_method_manystreams_next(void 1598 - 1599 - ); 1600 - #endif 1601 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_ADD_TICKETS 1602 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_ADD_TICKETS 1603 - uint16_t uniffi_iroh_streamplace_checksum_method_node_add_tickets(void 1604 - 1605 - ); 1606 - #endif 1607 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_DB 1608 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_DB 1609 - uint16_t uniffi_iroh_streamplace_checksum_method_node_db(void 1610 - 1611 - ); 1612 - #endif 1613 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_JOIN_PEERS 1614 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_JOIN_PEERS 1615 - uint16_t uniffi_iroh_streamplace_checksum_method_node_join_peers(void 1616 - 1617 - ); 1618 - #endif 1619 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_NODE_ID 1620 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_NODE_ID 1621 - uint16_t uniffi_iroh_streamplace_checksum_method_node_node_id(void 1622 - 1623 - ); 1624 - #endif 1625 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_NODE_SCOPE 1626 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_NODE_SCOPE 1627 - uint16_t uniffi_iroh_streamplace_checksum_method_node_node_scope(void 1628 - 1629 - ); 1630 - #endif 1631 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SEND_SEGMENT 1632 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SEND_SEGMENT 1633 - uint16_t uniffi_iroh_streamplace_checksum_method_node_send_segment(void 1634 - 1635 - ); 1636 - #endif 1637 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SHUTDOWN 1638 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SHUTDOWN 1639 - uint16_t uniffi_iroh_streamplace_checksum_method_node_shutdown(void 1640 - 1641 - ); 1642 - #endif 1643 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SUBSCRIBE 1644 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_SUBSCRIBE 1645 - uint16_t uniffi_iroh_streamplace_checksum_method_node_subscribe(void 1646 - 1647 - ); 1648 - #endif 1649 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_TICKET 1650 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_TICKET 1651 - uint16_t uniffi_iroh_streamplace_checksum_method_node_ticket(void 1652 - 1653 - ); 1654 - #endif 1655 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_UNSUBSCRIBE 1656 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODE_UNSUBSCRIBE 1657 - uint16_t uniffi_iroh_streamplace_checksum_method_node_unsubscribe(void 1658 - 1659 - ); 1660 - #endif 1661 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODEADDR_DIRECT_ADDRESSES 1662 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODEADDR_DIRECT_ADDRESSES 1663 uint16_t uniffi_iroh_streamplace_checksum_method_nodeaddr_direct_addresses(void ··· 1700 1701 ); 1702 #endif 1703 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_UNSIGNED_SEG_STREAM 1704 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_UNSIGNED_SEG_STREAM 1705 - uint16_t uniffi_iroh_streamplace_checksum_method_segmenttosign_unsigned_seg_stream(void 1706 - 1707 - ); 1708 - #endif 1709 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_MANIFEST_ID 1710 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_MANIFEST_ID 1711 - uint16_t uniffi_iroh_streamplace_checksum_method_segmenttosign_manifest_id(void 1712 - 1713 - ); 1714 - #endif 1715 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_CERT 1716 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_CERT 1717 - uint16_t uniffi_iroh_streamplace_checksum_method_segmenttosign_cert(void 1718 - 1719 - ); 1720 - #endif 1721 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_OUTPUT_SEG_STREAM 1722 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_OUTPUT_SEG_STREAM 1723 - uint16_t uniffi_iroh_streamplace_checksum_method_segmenttosign_output_seg_stream(void 1724 - 1725 - ); 1726 - #endif 1727 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_CLOSE 1728 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SEGMENTTOSIGN_CLOSE 1729 - uint16_t uniffi_iroh_streamplace_checksum_method_segmenttosign_close(void 1730 - 1731 - ); 1732 - #endif 1733 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SOCKET_ACCEPT 1734 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SOCKET_ACCEPT 1735 uint16_t uniffi_iroh_streamplace_checksum_method_socket_accept(void ··· 1766 1767 ); 1768 #endif 1769 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_READ_STREAM 1770 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_READ_STREAM 1771 - uint16_t uniffi_iroh_streamplace_checksum_method_stream_read_stream(void 1772 - 1773 - ); 1774 - #endif 1775 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_SEEK_STREAM 1776 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_SEEK_STREAM 1777 - uint16_t uniffi_iroh_streamplace_checksum_method_stream_seek_stream(void 1778 - 1779 - ); 1780 - #endif 1781 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE_STREAM 1782 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE_STREAM 1783 - uint16_t uniffi_iroh_streamplace_checksum_method_stream_write_stream(void 1784 - 1785 - ); 1786 - #endif 1787 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE 1788 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE 1789 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_close(void 1790 - 1791 - ); 1792 - #endif 1793 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE_READ 1794 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE_READ 1795 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_close_read(void 1796 - 1797 - ); 1798 - #endif 1799 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE_WRITE 1800 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSE_WRITE 1801 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_close_write(void 1802 - 1803 - ); 1804 - #endif 1805 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSED 1806 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_CLOSED 1807 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_closed(void 1808 - 1809 - ); 1810 - #endif 1811 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_READ 1812 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_READ 1813 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_read(void 1814 - 1815 - ); 1816 - #endif 1817 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_WRITE 1818 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_WRITE 1819 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_write(void 1820 - 1821 - ); 1822 - #endif 1823 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_WRITE_ALL 1824 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM2_WRITE_ALL 1825 - uint16_t uniffi_iroh_streamplace_checksum_method_stream2_write_all(void 1826 1827 ); 1828 #endif 1829 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SUBSCRIBERESPONSE_NEXT_RAW 1830 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SUBSCRIBERESPONSE_NEXT_RAW 1831 - uint16_t uniffi_iroh_streamplace_checksum_method_subscriberesponse_next_raw(void 1832 1833 ); 1834 #endif 1835 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_WRITESCOPE_PUT 1836 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_WRITESCOPE_PUT 1837 - uint16_t uniffi_iroh_streamplace_checksum_method_writescope_put(void 1838 1839 ); 1840 #endif 1841 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_FILTER_NEW 1842 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_FILTER_NEW 1843 - uint16_t uniffi_iroh_streamplace_checksum_constructor_filter_new(void 1844 1845 ); 1846 #endif 1847 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_FORWARDER 1848 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_FORWARDER 1849 - uint16_t uniffi_iroh_streamplace_checksum_constructor_node_forwarder(void 1850 1851 ); 1852 #endif 1853 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_RECEIVER 1854 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_RECEIVER 1855 - uint16_t uniffi_iroh_streamplace_checksum_constructor_node_receiver(void 1856 1857 ); 1858 #endif 1859 - #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_SENDER 1860 - #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_CONSTRUCTOR_NODE_SENDER 1861 - uint16_t uniffi_iroh_streamplace_checksum_constructor_node_sender(void 1862 1863 ); 1864 #endif ··· 1893 ); 1894 #endif 1895 1896 - void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uint64_t uniffi_handle, void* from, RustBuffer topic, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return); 1897 - void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree(uint64_t handle); 1898 - void iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerMethod0(uint64_t uniffi_handle, RustBuffer data, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1899 - void iroh_streamplace_cgo_dispatchCallbackInterfaceGoSignerFree(uint64_t handle); 1900 - void iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignMethod0(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1901 - void iroh_streamplace_cgo_dispatchCallbackInterfaceManySegmentsToSignFree(uint64_t handle); 1902 - void iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsMethod0(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1903 - void iroh_streamplace_cgo_dispatchCallbackInterfaceManyStreamsFree(uint64_t handle); 1904 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod0(uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ); 1905 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod1(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1906 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod2(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1907 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod3(uint64_t uniffi_handle, void** uniffi_out_return, RustCallStatus* callStatus ); 1908 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignMethod4(uint64_t uniffi_handle, void* uniffi_out_return, RustCallStatus* callStatus ); 1909 - void iroh_streamplace_cgo_dispatchCallbackInterfaceSegmentToSignFree(uint64_t handle); 1910 - void iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod0(uint64_t uniffi_handle, uint64_t length, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); 1911 - void iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod1(uint64_t uniffi_handle, int64_t pos, uint64_t mode, uint64_t* uniffi_out_return, RustCallStatus* callStatus ); 1912 - void iroh_streamplace_cgo_dispatchCallbackInterfaceStreamMethod2(uint64_t uniffi_handle, RustBuffer data, uint64_t* uniffi_out_return, RustCallStatus* callStatus ); 1913 - void iroh_streamplace_cgo_dispatchCallbackInterfaceStreamFree(uint64_t handle); 1914 1915 void iroh_streamplace_uniffiFutureContinuationCallback(uint64_t, int8_t); 1916 void iroh_streamplace_uniffiFreeGorutine(uint64_t);
··· 378 379 380 #endif 381 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODEADDR 382 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_NODEADDR 383 void* uniffi_iroh_streamplace_fn_clone_nodeaddr(void* ptr, RustCallStatus *out_status ··· 453 RustBuffer uniffi_iroh_streamplace_fn_method_publickey_uniffi_trait_display(void* ptr, RustCallStatus *out_status 454 ); 455 #endif 456 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SOCKET 457 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SOCKET 458 void* uniffi_iroh_streamplace_fn_clone_socket(void* ptr, RustCallStatus *out_status ··· 508 void uniffi_iroh_streamplace_fn_free_stream(void* ptr, RustCallStatus *out_status 509 ); 510 #endif 511 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE 512 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE 513 + void uniffi_iroh_streamplace_fn_method_stream_close(void* ptr, RustCallStatus *out_status 514 ); 515 #endif 516 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE_READ 517 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE_READ 518 + uint64_t uniffi_iroh_streamplace_fn_method_stream_close_read(void* ptr 519 ); 520 #endif 521 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE_WRITE 522 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSE_WRITE 523 + uint64_t uniffi_iroh_streamplace_fn_method_stream_close_write(void* ptr 524 ); 525 #endif 526 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSED 527 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_CLOSED 528 + uint64_t uniffi_iroh_streamplace_fn_method_stream_closed(void* ptr 529 ); 530 #endif 531 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_READ 532 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_READ 533 + uint64_t uniffi_iroh_streamplace_fn_method_stream_read(void* ptr, uint64_t n 534 ); 535 #endif 536 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE 537 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE 538 + uint64_t uniffi_iroh_streamplace_fn_method_stream_write(void* ptr, RustBuffer buf 539 ); 540 #endif 541 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE_ALL 542 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_STREAM_WRITE_ALL 543 + uint64_t uniffi_iroh_streamplace_fn_method_stream_write_all(void* ptr, RustBuffer buf 544 ); 545 #endif 546 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_INIT_LOGGING ··· 562 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_NODE_ID_FROM_TICKET 563 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_NODE_ID_FROM_TICKET 564 void* uniffi_iroh_streamplace_fn_func_node_id_from_ticket(RustBuffer ticket_str, RustCallStatus *out_status 565 ); 566 #endif 567 #ifndef UNIFFI_FFIDEF_FFI_IROH_STREAMPLACE_RUSTBUFFER_ALLOC ··· 844 void ffi_iroh_streamplace_rust_future_complete_void(uint64_t handle, RustCallStatus *out_status 845 ); 846 #endif 847 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_INIT_LOGGING 848 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_FUNC_INIT_LOGGING 849 uint16_t uniffi_iroh_streamplace_checksum_func_init_logging(void ··· 868 869 ); 870 #endif 871 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODEADDR_DIRECT_ADDRESSES 872 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_NODEADDR_DIRECT_ADDRESSES 873 uint16_t uniffi_iroh_streamplace_checksum_method_nodeaddr_direct_addresses(void ··· 910 911 ); 912 #endif 913 #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SOCKET_ACCEPT 914 #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SOCKET_ACCEPT 915 uint16_t uniffi_iroh_streamplace_checksum_method_socket_accept(void ··· 946 947 ); 948 #endif 949 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE 950 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE 951 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_close(void 952 953 ); 954 #endif 955 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE_READ 956 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE_READ 957 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_close_read(void 958 959 ); 960 #endif 961 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE_WRITE 962 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSE_WRITE 963 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_close_write(void 964 965 ); 966 #endif 967 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSED 968 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_CLOSED 969 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_closed(void 970 971 ); 972 #endif 973 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_READ 974 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_READ 975 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_read(void 976 977 ); 978 #endif 979 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE 980 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE 981 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_write(void 982 983 ); 984 #endif 985 + #ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE_ALL 986 + #define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_STREAM_WRITE_ALL 987 + uint16_t uniffi_iroh_streamplace_checksum_method_stream_write_all(void 988 989 ); 990 #endif ··· 1019 ); 1020 #endif 1021 1022 1023 void iroh_streamplace_uniffiFutureContinuationCallback(uint64_t, int8_t); 1024 void iroh_streamplace_uniffiFreeGorutine(uint64_t);
-280
rust/iroh-streamplace/src/c2pa.rs
··· 1 - use std::{io::Cursor, sync::Arc}; 2 - 3 - use base64::{Engine as _, engine::general_purpose::STANDARD}; 4 - use c2pa::{ 5 - Builder, CallbackSigner, Ingredient, Reader, jumbf_io, settings::Settings, 6 - status_tracker::StatusTracker, store::Store, 7 - }; 8 - use serde_json; 9 - 10 - use crate::{ 11 - error::SPError, 12 - streams::{ManyStreams, Stream, StreamAdapter}, 13 - }; 14 - #[uniffi::export] 15 - pub fn get_manifest_and_cert(data: &dyn Stream) -> Result<String, SPError> { 16 - let reader = Reader::from_stream("video/mp4", StreamAdapter::from(data)) 17 - .map_err(|e| SPError::C2paError(e.to_string()))?; 18 - 19 - if let Some(manifest) = reader.active_manifest() { 20 - let cert_chain = if let Some(si) = manifest.signature_info() { 21 - si.cert_chain() 22 - } else { 23 - return Err(SPError::NoCertificateChainFound); 24 - }; 25 - 26 - let result = serde_json::json!({ 27 - "manifest": manifest, 28 - "cert": cert_chain, 29 - "validation_results": reader.validation_results(), 30 - "validation_state": reader.validation_state(), 31 - }); 32 - 33 - return Ok(result.to_string()); 34 - } 35 - Err(SPError::NoCertificateChainFound) 36 - } 37 - 38 - #[uniffi::export(with_foreign)] 39 - pub trait GoSigner: Send + Sync { 40 - fn sign(&self, data: Vec<u8>) -> Result<Vec<u8>, SPError>; 41 - } 42 - 43 - // #[derive(uniffi::Object)] 44 - // struct Authenticator { 45 - // gosigner: Arc<dyn GoSigner>, 46 - // } 47 - 48 - // impl Authenticator { 49 - // pub fn new(gosigner: Arc<dyn GoSigner>) -> Self { 50 - // Self { gosigner } 51 - // } 52 - 53 - // pub fn login(&self) { 54 - // let username = self.gosigner.get("username".into()); 55 - // let password = self.gosigner.get("password".into()); 56 - // } 57 - // } 58 - 59 - const TOML_SETTINGS: &str = r#" 60 - version_major = 1 61 - version_minor = 0 62 - 63 - [trust] 64 - 65 - [core] 66 - debug = true 67 - hash_alg = "sha256" 68 - salt_jumbf_boxes = true 69 - prefer_box_hash = false 70 - merkle_tree_max_proofs = 5 71 - compress_manifests = true 72 - 73 - [verify] 74 - verify_after_reading = false 75 - verify_after_sign = false 76 - verify_trust = false 77 - verify_timestamp_trust = false 78 - ocsp_fetch = false 79 - remote_manifest_fetch = false 80 - check_ingredient_trust = false 81 - skip_ingredient_conflict_resolution = false 82 - strict_v1_validation = false 83 - 84 - [builder.thumbnail] 85 - enabled = false 86 - ignore_errors = true 87 - long_edge = 1024 88 - prefer_smallest_format = true 89 - quality = "medium" 90 - 91 - [builder.actions] 92 - all_actions_included = false 93 - 94 - [builder.actions.auto_created_action] 95 - enabled = true 96 - source_type = "http://c2pa.org/digitalsourcetype/empty" 97 - 98 - [builder.actions.auto_opened_action] 99 - enabled = true 100 - 101 - [builder.actions.auto_placed_action] 102 - enabled = true 103 - "#; 104 - 105 - #[uniffi::export] 106 - pub fn sign( 107 - manifest: String, 108 - data: &dyn Stream, 109 - certs_str: String, 110 - gosigner: Arc<dyn GoSigner>, 111 - ) -> Result<Vec<u8>, SPError> { 112 - Settings::from_toml(TOML_SETTINGS).map_err(|e| SPError::C2paError(e.to_string()))?; 113 - let certs = STANDARD 114 - .decode(certs_str) 115 - .map_err(|e| SPError::C2paError(e.to_string()))?; 116 - let callback_signer = CallbackSigner::new( 117 - move |_context: *const (), data: &[u8]| { 118 - let signature = gosigner 119 - .sign(data.to_vec()) 120 - .map_err(|e| c2pa::Error::BadParam(e.to_string()))?; 121 - Ok(signature) 122 - }, 123 - c2pa::SigningAlg::Es256K, 124 - certs, 125 - ); 126 - let mut builder = 127 - Builder::from_json(&manifest).map_err(|e| SPError::C2paError(e.to_string()))?; 128 - let mut output = Vec::new(); 129 - let mut input_cursor = StreamAdapter::from(data); 130 - let mut output_cursor = Cursor::new(&mut output); 131 - builder 132 - .sign( 133 - &callback_signer, 134 - "video/mp4", 135 - &mut input_cursor, 136 - &mut output_cursor, 137 - ) 138 - .map_err(|e| SPError::C2paError(e.to_string()))?; 139 - Ok(output) 140 - } 141 - 142 - #[uniffi::export] 143 - pub fn get_manifests(data: &dyn Stream) -> Result<String, SPError> { 144 - let store = Reader::from_stream("video/mp4", StreamAdapter::from(data)) 145 - .map_err(|e| SPError::C2paError(e.to_string()))?; 146 - let mut certs: std::collections::HashMap<String, String> = std::collections::HashMap::new(); 147 - for (label, manifest) in store.manifests() { 148 - let cert_chain = manifest 149 - .signature_info() 150 - .ok_or(SPError::C2paError(format!( 151 - "No signature info for manifest: {}", 152 - label 153 - )))? 154 - .cert_chain(); 155 - certs.insert(label.clone(), cert_chain.to_string()); 156 - } 157 - let result = serde_json::json!({ 158 - "manifests": store.manifests(), 159 - "certs": certs 160 - }); 161 - Ok(result.to_string()) 162 - } 163 - 164 - #[uniffi::export(with_foreign)] 165 - pub trait SegmentToSign: Send + Sync { 166 - fn unsigned_seg_stream(&self) -> Arc<dyn Stream>; 167 - fn manifest_id(&self) -> String; 168 - fn cert(&self) -> Vec<u8>; 169 - fn output_seg_stream(&self) -> Arc<dyn Stream>; 170 - fn close(&self); 171 - } 172 - 173 - #[uniffi::export(with_foreign)] 174 - pub trait ManySegmentsToSign: Send + Sync { 175 - fn next(&self) -> Option<Arc<dyn SegmentToSign>>; 176 - } 177 - 178 - #[uniffi::export] 179 - pub fn resign( 180 - segs_to_sign: &dyn ManySegmentsToSign, 181 - signed_concat_data: &dyn Stream, 182 - ) -> Result<(), SPError> { 183 - let mut validation_log = StatusTracker::default(); 184 - 185 - let combined_store = Store::from_stream( 186 - "video/mp4", 187 - StreamAdapter::from(signed_concat_data), 188 - true, 189 - &mut validation_log, 190 - ) 191 - .map_err(|e| SPError::C2paError(format!("from_stream failed: {}", e)))?; 192 - 193 - while let Some(seg) = segs_to_sign.next() { 194 - let unsigned_seg_data_stream = seg.unsigned_seg_stream(); 195 - let manifest_id = seg.manifest_id(); 196 - let cert = seg.cert(); 197 - let output_stream = seg.output_seg_stream(); 198 - let mut input_cursor = StreamAdapter::from(&*unsigned_seg_data_stream); 199 - let mut output_cursor = StreamAdapter::from(&*output_stream); 200 - 201 - // let mut output = Vec::<u8>::new(); 202 - let seg_claim = 203 - combined_store 204 - .get_claim(manifest_id.as_str()) 205 - .ok_or(SPError::C2paError(format!( 206 - "Segment claim not found: {}", 207 - manifest_id 208 - )))?; 209 - let signature_val = seg_claim.signature_val().clone(); 210 - 211 - let callback_signer = CallbackSigner::new( 212 - move |_context: *const (), _data: &[u8]| Ok(signature_val.clone()), 213 - c2pa::SigningAlg::Es256K, 214 - cert, 215 - ); 216 - 217 - let mut seg_store = Store::new(); 218 - let _provenance = seg_store 219 - .commit_claim(seg_claim.clone()) 220 - .map_err(|e| SPError::C2paError(format!("commit_claim failed: {}", e)))?; 221 - 222 - let jumbf_bytes = seg_store 223 - .to_jumbf(&callback_signer) 224 - .map_err(|e| SPError::C2paError(format!("to_jumbf failed: {}", e)))?; 225 - 226 - jumbf_io::save_jumbf_to_stream( 227 - "video/mp4", 228 - &mut input_cursor, 229 - &mut output_cursor, 230 - &jumbf_bytes, 231 - ) 232 - .map_err(|e| SPError::C2paError(format!("save_jumbf_to_stream failed: {}", e)))?; 233 - seg.close(); 234 - } 235 - 236 - Ok(()) 237 - } 238 - 239 - #[uniffi::export] 240 - pub fn sign_with_ingredients( 241 - manifest: String, 242 - data: &dyn Stream, 243 - certs_str: String, 244 - ingredients: &dyn ManyStreams, 245 - gosigner: Arc<dyn GoSigner>, 246 - output: &dyn Stream, 247 - ) -> Result<(), SPError> { 248 - let certs = STANDARD 249 - .decode(certs_str) 250 - .map_err(|e| SPError::C2paError(e.to_string()))?; 251 - Settings::from_toml(TOML_SETTINGS).map_err(|e| SPError::C2paError(e.to_string()))?; 252 - let callback_signer = CallbackSigner::new( 253 - move |_context: *const (), data: &[u8]| { 254 - gosigner 255 - .sign(data.to_vec()) 256 - .map_err(|e| c2pa::Error::BadParam(e.to_string())) 257 - }, 258 - c2pa::SigningAlg::Es256K, 259 - certs, 260 - ); 261 - let mut builder = 262 - Builder::from_json(&manifest).map_err(|e| SPError::C2paError(e.to_string()))?; 263 - while let Some(ingredient) = ingredients.next() { 264 - let mut cursor = StreamAdapter::from(&*ingredient); 265 - let ingredient = Ingredient::from_stream("video/mp4", &mut cursor) 266 - .map_err(|e| SPError::C2paError(e.to_string()))?; 267 - builder.add_ingredient(ingredient); 268 - } 269 - let mut input_cursor = StreamAdapter::from(data); 270 - let mut output_cursor = StreamAdapter::from(output); 271 - builder 272 - .sign( 273 - &callback_signer, 274 - "video/mp4", 275 - &mut input_cursor, 276 - &mut output_cursor, 277 - ) 278 - .map_err(|e| SPError::C2paError(e.to_string()))?; 279 - Ok(()) 280 - }
···
-569
rust/iroh-streamplace/src/db.rs
··· 1 - use std::{ 2 - fmt::{self, Debug}, 3 - ops::Bound, 4 - pin::Pin, 5 - sync::Arc, 6 - time::Duration, 7 - }; 8 - 9 - use bytes::Bytes; 10 - use n0_future::{Stream, StreamExt}; 11 - use ref_cast::RefCast; 12 - use snafu::Snafu; 13 - use tokio::sync::Mutex; 14 - 15 - use crate::public_key::PublicKey; 16 - 17 - // the files here are just copied from iroh-smol-kv-uniffi/src/code 18 - mod kv { 19 - mod time_bound; 20 - pub use time_bound::TimeBound; 21 - mod subscribe_mode; 22 - pub use subscribe_mode::SubscribeMode; 23 - } 24 - pub use kv::{SubscribeMode, TimeBound}; 25 - use util::format_bytes; 26 - 27 - /// Error creating a new database node. 28 - #[derive(Debug, Snafu, uniffi::Error)] 29 - #[snafu(module)] 30 - pub enum CreateError { 31 - /// The provided private key is invalid (not 32 bytes). 32 - PrivateKey { size: u64 }, 33 - /// The provided gossip topic is invalid (not 32 bytes). 34 - Topic { size: u64 }, 35 - /// Failed to bind the iroh endpoint. 36 - Bind { message: String }, 37 - /// Failed to subscribe to the gossip topic. 38 - Subscribe { message: String }, 39 - } 40 - 41 - /// Error joining peers. 42 - #[derive(Debug, Snafu, uniffi::Error)] 43 - #[snafu(module)] 44 - pub enum JoinPeersError { 45 - /// Failed to parse a provided iroh node ticket. 46 - Ticket { message: String }, 47 - /// Error during the join peers operation. 48 - Irpc { message: String }, 49 - } 50 - 51 - /// Error joining peers. 52 - #[derive(Debug, Snafu, uniffi::Error)] 53 - #[snafu(module)] 54 - pub enum ParseError { 55 - /// Failed to parse a provided iroh node ticket. 56 - Ticket { message: String }, 57 - } 58 - 59 - /// Error putting a value into the database. 60 - #[derive(Debug, Snafu, uniffi::Error)] 61 - #[snafu(module)] 62 - pub enum PutError { 63 - /// Error during the put operation. 64 - Irpc { message: String }, 65 - } 66 - 67 - /// Configuration for an iroh-streamplace node. 68 - #[derive(uniffi::Record, Clone)] 69 - pub struct Config { 70 - /// An Ed25519 secret key as a 32 byte array. 71 - pub key: Vec<u8>, 72 - /// The gossip topic to use. Must be 32 bytes. 73 - /// 74 - /// You can use e.g. a BLAKE3 hash of a topic string here. This can be used 75 - /// as a cheap way to have a shared secret - nodes that do not know the topic 76 - /// cannot connect to the swarm. 77 - pub topic: Vec<u8>, 78 - /// Maximum duration to wait for sending a stream piece to a peer. 79 - pub max_send_duration: Duration, 80 - /// Disable using relays, for tests. 81 - pub disable_relay: bool, 82 - } 83 - 84 - #[derive(uniffi::Enum, Debug, Clone)] 85 - enum StreamFilter { 86 - All, 87 - Global, 88 - Stream(Vec<u8>), 89 - } 90 - 91 - /// A filter for subscriptions and iteration. 92 - #[derive(uniffi::Object, Debug, Clone)] 93 - pub struct Filter { 94 - scope: Option<Vec<Arc<PublicKey>>>, 95 - stream: StreamFilter, 96 - min_time: TimeBound, 97 - max_time: TimeBound, 98 - } 99 - 100 - #[uniffi::export] 101 - impl Filter { 102 - /// Creates a new filter that matches everything. 103 - #[uniffi::constructor] 104 - pub fn new() -> Arc<Self> { 105 - Arc::new(Self { 106 - scope: None, 107 - stream: StreamFilter::All, 108 - min_time: TimeBound::Unbounded, 109 - max_time: TimeBound::Unbounded, 110 - }) 111 - } 112 - 113 - /// Restrict to the global namespace, no per stream data. 114 - pub fn global(mut self: Arc<Self>) -> Arc<Self> { 115 - let this = Arc::make_mut(&mut self); 116 - this.stream = StreamFilter::Global; 117 - self 118 - } 119 - 120 - /// Restrict to one specific stream, no global data. 121 - pub fn stream(mut self: Arc<Self>, stream: Vec<u8>) -> Arc<Self> { 122 - let this = Arc::make_mut(&mut self); 123 - this.stream = StreamFilter::Stream(stream); 124 - self 125 - } 126 - 127 - /// Restrict to a set of scopes. 128 - pub fn scopes(mut self: Arc<Self>, scopes: Vec<Arc<PublicKey>>) -> Arc<Self> { 129 - let this = Arc::make_mut(&mut self); 130 - this.scope = Some(scopes); 131 - self 132 - } 133 - 134 - /// Restrict to a single scope. 135 - pub fn scope(self: Arc<Self>, scope: Arc<PublicKey>) -> Arc<Self> { 136 - self.scopes(vec![scope]) 137 - } 138 - 139 - /// Restrict to a time range. 140 - pub fn timestamps(mut self: Arc<Self>, min: TimeBound, max: TimeBound) -> Arc<Self> { 141 - let this = Arc::make_mut(&mut self); 142 - this.min_time = min; 143 - this.max_time = max; 144 - self 145 - } 146 - 147 - /// Restrict to a time range given in nanoseconds since unix epoch. 148 - pub fn time_range(self: Arc<Self>, min: u64, max: u64) -> Arc<Self> { 149 - self.timestamps(TimeBound::Included(min), TimeBound::Excluded(max)) 150 - } 151 - 152 - /// Restrict to a time range starting at min, unbounded at the top. 153 - pub fn time_from(self: Arc<Self>, min: u64) -> Arc<Self> { 154 - self.timestamps(TimeBound::Included(min), TimeBound::Unbounded) 155 - } 156 - } 157 - 158 - impl From<Filter> for iroh_smol_kv::Filter { 159 - fn from(value: Filter) -> Self { 160 - let mut filter = iroh_smol_kv::Filter::ALL; 161 - match value.stream { 162 - // everything 163 - StreamFilter::All => {} 164 - // everything starting with 'g', for the global namespace 165 - StreamFilter::Global => { 166 - filter = filter.key_prefix(b"g".as_ref()); 167 - } 168 - // a specific stream, everything starting with 's' + escaped stream name 169 - StreamFilter::Stream(t) => { 170 - let prefix = util::encode_stream_and_key(Some(&t), &[]); 171 - filter = filter.key_prefix(prefix); 172 - } 173 - }; 174 - filter = filter.timestamps_nanos(( 175 - Bound::<u64>::from(value.min_time), 176 - Bound::<u64>::from(value.max_time), 177 - )); 178 - if let Some(scopes) = value.scope { 179 - let keys = scopes.iter().map(|k| iroh::PublicKey::from(k.as_ref())); 180 - filter = filter.scopes(keys); 181 - } 182 - filter 183 - } 184 - } 185 - 186 - /// Error getting the next item from a subscription. 187 - #[derive(uniffi::Enum, Snafu, Debug)] 188 - #[snafu(module)] 189 - pub enum SubscribeNextError { 190 - /// Error during the subscribe next operation. 191 - Irpc { message: String }, 192 - } 193 - 194 - /// Error getting the next item from a subscription. 195 - #[derive(uniffi::Enum, Snafu, Debug)] 196 - #[snafu(module)] 197 - pub enum WriteError { 198 - /// The provided private key is invalid (not 32 bytes). 199 - PrivateKeySize { size: u64 }, 200 - } 201 - 202 - /// Error shutting down the database. 203 - /// 204 - /// This can occur if the db is already shut down or if there is an internal error. 205 - #[derive(uniffi::Enum, Snafu, Debug)] 206 - #[snafu(module)] 207 - pub enum ShutdownError { 208 - /// Error during the shutdown operation. 209 - Irpc { message: String }, 210 - } 211 - 212 - /// An entry returned from the database. 213 - #[derive(uniffi::Record, Debug, PartialEq, Eq)] 214 - pub struct Entry { 215 - scope: Arc<PublicKey>, 216 - stream: Option<Vec<u8>>, 217 - key: Vec<u8>, 218 - value: Vec<u8>, 219 - timestamp: u64, 220 - } 221 - 222 - /// An item returned from a subscription. 223 - #[derive(uniffi::Enum, Debug)] 224 - pub enum SubscribeItem { 225 - Entry { 226 - scope: Arc<PublicKey>, 227 - stream: Option<Vec<u8>>, 228 - key: Vec<u8>, 229 - value: Vec<u8>, 230 - timestamp: u64, 231 - }, 232 - CurrentDone, 233 - Expired { 234 - scope: Arc<PublicKey>, 235 - stream: Option<Vec<u8>>, 236 - key: Vec<u8>, 237 - timestamp: u64, 238 - }, 239 - Other, 240 - } 241 - 242 - fn fmt_stream(stream: &Option<Vec<u8>>) -> String { 243 - match stream { 244 - None => "<nil>".to_string(), 245 - Some(s) => format_bytes(s), 246 - } 247 - } 248 - 249 - #[uniffi::export] 250 - pub fn subscribe_item_debug(item: &SubscribeItem) -> String { 251 - match item { 252 - SubscribeItem::Entry { 253 - scope, 254 - stream, 255 - key, 256 - value, 257 - timestamp, 258 - } => format!( 259 - "Entry {{ scope: {}, stream: {}, key: {}, value: {}, timestamp: {} }}", 260 - scope.fmt_short(), 261 - fmt_stream(stream), 262 - format_bytes(key), 263 - format_bytes(value), 264 - timestamp 265 - ), 266 - SubscribeItem::CurrentDone => "CurrentDone".to_string(), 267 - SubscribeItem::Expired { 268 - scope, 269 - stream, 270 - key, 271 - timestamp, 272 - } => format!( 273 - "Expired {{ scope: {}, stream: {}, key: {}, timestamp: {} }}", 274 - scope.fmt_short(), 275 - fmt_stream(stream), 276 - format_bytes(key), 277 - timestamp 278 - ), 279 - SubscribeItem::Other => "Other".to_string(), 280 - } 281 - } 282 - 283 - impl From<iroh_smol_kv::SubscribeItem> for SubscribeItem { 284 - fn from(item: iroh_smol_kv::SubscribeItem) -> Self { 285 - match &item { 286 - iroh_smol_kv::SubscribeItem::Entry((scope, key, value)) => { 287 - let Some((stream, key)) = util::decode_stream_and_key(key) else { 288 - return Self::Other; 289 - }; 290 - Self::Entry { 291 - scope: Arc::new((*scope).into()), 292 - stream, 293 - key, 294 - value: value.value.to_vec(), 295 - timestamp: value.timestamp, 296 - } 297 - } 298 - iroh_smol_kv::SubscribeItem::CurrentDone => Self::CurrentDone, 299 - iroh_smol_kv::SubscribeItem::Expired((scope, topic, timestamp)) => { 300 - let (stream, key) = util::decode_stream_and_key(topic).unwrap(); 301 - Self::Expired { 302 - scope: Arc::new((*scope).into()), 303 - stream, 304 - key, 305 - timestamp: *timestamp, 306 - } 307 - } 308 - } 309 - } 310 - } 311 - 312 - /// A response to a subscribe request. 313 - /// 314 - /// This can be used as a stream of [`SubscribeItem`]s. 315 - #[derive(uniffi::Object)] 316 - #[uniffi::export(Debug)] 317 - #[allow(clippy::type_complexity)] 318 - pub struct SubscribeResponse { 319 - inner: Mutex< 320 - Pin< 321 - Box< 322 - dyn Stream<Item = Result<iroh_smol_kv::SubscribeItem, irpc::Error>> 323 - + Send 324 - + Sync 325 - + 'static, 326 - >, 327 - >, 328 - >, 329 - } 330 - 331 - impl fmt::Debug for SubscribeResponse { 332 - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 333 - f.debug_struct("SubscribeResponse").finish_non_exhaustive() 334 - } 335 - } 336 - 337 - #[uniffi::export] 338 - impl SubscribeResponse { 339 - pub async fn next_raw(&self) -> Result<Option<SubscribeItem>, SubscribeNextError> { 340 - let mut this = self.inner.lock().await; 341 - match this.as_mut().next().await { 342 - None => Ok(None), 343 - Some(Ok(item)) => Ok(Some(item.into())), 344 - Some(Err(e)) => Err(SubscribeNextError::Irpc { 345 - message: e.to_string(), 346 - }), 347 - } 348 - } 349 - } 350 - 351 - /// Options for subscribing. 352 - /// 353 - /// `filter` specifies what to subscribe to. 354 - /// `mode` specifies whether to get current items, new items, or both. 355 - #[derive(uniffi::Record)] 356 - pub struct SubscribeOpts { 357 - pub filter: Arc<Filter>, 358 - pub mode: SubscribeMode, 359 - } 360 - 361 - impl From<SubscribeOpts> for iroh_smol_kv::Subscribe { 362 - fn from(opts: SubscribeOpts) -> Self { 363 - iroh_smol_kv::Subscribe { 364 - filter: opts.filter.as_ref().clone().into(), 365 - mode: opts.mode.into(), 366 - } 367 - } 368 - } 369 - 370 - /// A write scope that can be used to put values into the database. 371 - /// 372 - /// The default write scope is available from the [`Node::node_scope`] method. 373 - #[derive(Clone, Debug, RefCast, uniffi::Object)] 374 - #[repr(transparent)] 375 - pub struct WriteScope(iroh_smol_kv::WriteScope); 376 - 377 - #[uniffi::export] 378 - impl WriteScope { 379 - pub async fn put( 380 - &self, 381 - stream: Option<Vec<u8>>, 382 - key: Vec<u8>, 383 - value: Vec<u8>, 384 - ) -> Result<(), PutError> { 385 - self.put_impl(stream, key, value.into()) 386 - .await 387 - .map_err(|e| PutError::Irpc { 388 - message: e.to_string(), 389 - }) 390 - } 391 - } 392 - 393 - impl WriteScope { 394 - pub fn new(inner: iroh_smol_kv::WriteScope) -> Self { 395 - Self(inner) 396 - } 397 - 398 - /// Put a value into the database, optionally in a specific stream. 399 - pub async fn put_impl( 400 - &self, 401 - stream: Option<impl AsRef<[u8]>>, 402 - key: impl AsRef<[u8]>, 403 - value: Bytes, 404 - ) -> Result<(), irpc::Error> { 405 - let key = key.as_ref(); 406 - let stream = stream.as_ref().map(|s| s.as_ref()); 407 - let encoded = util::encode_stream_and_key(stream, key); 408 - self.0.put(encoded, value).await?; 409 - Ok(()) 410 - } 411 - } 412 - 413 - /// Iroh-streamplace specific metadata database. 414 - #[derive(Debug, Clone, RefCast, uniffi::Object)] 415 - #[repr(transparent)] 416 - pub struct Db(iroh_smol_kv::Client); 417 - 418 - impl Db { 419 - pub fn new(inner: iroh_smol_kv::Client) -> Self { 420 - Self(inner) 421 - } 422 - 423 - pub fn inner(&self) -> &iroh_smol_kv::Client { 424 - &self.0 425 - } 426 - } 427 - 428 - #[uniffi::export] 429 - impl Db { 430 - pub fn write(&self, secret: Vec<u8>) -> Result<Arc<WriteScope>, WriteError> { 431 - let secret = iroh::SecretKey::from_bytes(&secret.try_into().map_err(|e: Vec<u8>| { 432 - WriteError::PrivateKeySize { 433 - size: e.len() as u64, 434 - } 435 - })?); 436 - let write = self.0.write(secret); 437 - Ok(Arc::new(WriteScope::new(write))) 438 - } 439 - 440 - pub async fn iter_with_opts( 441 - &self, 442 - filter: Arc<Filter>, 443 - ) -> Result<Vec<Entry>, SubscribeNextError> { 444 - let sub = self.subscribe_with_opts(SubscribeOpts { 445 - filter, 446 - mode: SubscribeMode::Current, 447 - }); 448 - let mut items = Vec::new(); 449 - while let Some(item) = sub.next_raw().await? { 450 - match item { 451 - SubscribeItem::Entry { 452 - scope, 453 - stream, 454 - key, 455 - value, 456 - timestamp, 457 - } => { 458 - items.push(Entry { 459 - scope, 460 - stream, 461 - key, 462 - value, 463 - timestamp, 464 - }); 465 - } 466 - _ => unreachable!("we used SubscribeMode::Current, so we should only get entries"), 467 - } 468 - } 469 - Ok(items) 470 - } 471 - 472 - pub fn subscribe(&self, filter: Arc<Filter>) -> Arc<SubscribeResponse> { 473 - self.subscribe_with_opts(SubscribeOpts { 474 - filter, 475 - mode: SubscribeMode::Both, 476 - }) 477 - } 478 - 479 - /// Subscribe with options. 480 - pub fn subscribe_with_opts(&self, opts: SubscribeOpts) -> Arc<SubscribeResponse> { 481 - Arc::new(SubscribeResponse { 482 - inner: Mutex::new(Box::pin( 483 - self.0.subscribe_with_opts(opts.into()).stream_raw(), 484 - )), 485 - }) 486 - } 487 - 488 - /// Shutdown the database client and all subscriptions. 489 - pub async fn shutdown(&self) -> Result<(), ShutdownError> { 490 - Ok(self.0.shutdown().await.map_err(|e| ShutdownError::Irpc { 491 - message: e.to_string(), 492 - })?) 493 - } 494 - } 495 - 496 - mod util { 497 - 498 - pub fn encode_stream_and_key(stream: Option<&[u8]>, key: &[u8]) -> Vec<u8> { 499 - let mut result = Vec::new(); 500 - if let Some(s) = stream { 501 - result.push(b's'); 502 - postcard::to_io(s, &mut result).unwrap(); 503 - } else { 504 - result.push(b'g'); 505 - } 506 - result.extend(key); 507 - result 508 - } 509 - 510 - pub fn decode_stream_and_key(encoded: &[u8]) -> Option<(Option<Vec<u8>>, Vec<u8>)> { 511 - match encoded.split_first() { 512 - Some((b's', mut rest)) => { 513 - let (stream, rest) = postcard::take_from_bytes(&mut rest).ok()?; 514 - Some((Some(stream), rest.to_vec())) 515 - } 516 - Some((b'g', rest)) => Some((None, rest.to_vec())), 517 - _ => None, 518 - } 519 - } 520 - 521 - pub fn format_bytes(bytes: &[u8]) -> String { 522 - if bytes.is_empty() { 523 - return "\"\"".to_string(); 524 - } 525 - let Ok(s) = std::str::from_utf8(bytes) else { 526 - return hex::encode(bytes); 527 - }; 528 - if s.chars() 529 - .any(|c| c.is_control() && c != '\n' && c != '\t' && c != '\r') 530 - { 531 - return hex::encode(bytes); 532 - } 533 - format!("\"{}\"", escape_string(s)) 534 - } 535 - 536 - pub fn escape_string(s: &str) -> String { 537 - s.chars() 538 - .map(|c| match c { 539 - '"' => "\\\"".to_string(), 540 - '\\' => "\\\\".to_string(), 541 - '\n' => "\\n".to_string(), 542 - '\t' => "\\t".to_string(), 543 - '\r' => "\\r".to_string(), 544 - c => c.to_string(), 545 - }) 546 - .collect() 547 - } 548 - } 549 - 550 - #[cfg(test)] 551 - mod tests { 552 - use super::util; 553 - 554 - #[test] 555 - fn escape_unescape() { 556 - let cases: Vec<(Option<&[u8]>, &[u8])> = vec![ 557 - (None, b"key1"), 558 - (Some(b""), b""), 559 - (Some(b""), b"a"), 560 - (Some(b"a"), b""), 561 - ]; 562 - for (stream, key) in cases { 563 - let encoded = util::encode_stream_and_key(stream, key); 564 - let (decoded_stream, decoded_key) = util::decode_stream_and_key(&encoded).unwrap(); 565 - assert_eq!(decoded_stream.as_deref(), stream); 566 - assert_eq!(decoded_key.as_slice(), key); 567 - } 568 - } 569 - }
···
-29
rust/iroh-streamplace/src/db/kv/subscribe_mode.rs
··· 1 - use iroh_smol_kv as w; 2 - 3 - /// Subscription mode for key-value subscriptions. 4 - #[derive(uniffi::Enum, Debug, Clone, Copy)] 5 - pub enum SubscribeMode { 6 - Current, 7 - Future, 8 - Both, 9 - } 10 - 11 - impl From<w::SubscribeMode> for SubscribeMode { 12 - fn from(m: w::SubscribeMode) -> Self { 13 - match m { 14 - w::SubscribeMode::Current => SubscribeMode::Current, 15 - w::SubscribeMode::Future => SubscribeMode::Future, 16 - w::SubscribeMode::Both => SubscribeMode::Both, 17 - } 18 - } 19 - } 20 - 21 - impl From<SubscribeMode> for w::SubscribeMode { 22 - fn from(m: SubscribeMode) -> Self { 23 - match m { 24 - SubscribeMode::Current => w::SubscribeMode::Current, 25 - SubscribeMode::Future => w::SubscribeMode::Future, 26 - SubscribeMode::Both => w::SubscribeMode::Both, 27 - } 28 - } 29 - }
···
-29
rust/iroh-streamplace/src/db/kv/time_bound.rs
··· 1 - use std::ops::Bound; 2 - 3 - /// A bound on time for filtering. 4 - #[derive(uniffi::Enum, Debug, Clone, Copy)] 5 - pub enum TimeBound { 6 - Unbounded, 7 - Included(u64), 8 - Excluded(u64), 9 - } 10 - 11 - impl From<Bound<u64>> for TimeBound { 12 - fn from(b: Bound<u64>) -> Self { 13 - match b { 14 - Bound::Unbounded => TimeBound::Unbounded, 15 - Bound::Included(t) => TimeBound::Included(t), 16 - Bound::Excluded(t) => TimeBound::Excluded(t), 17 - } 18 - } 19 - } 20 - 21 - impl From<TimeBound> for Bound<u64> { 22 - fn from(b: TimeBound) -> Self { 23 - match b { 24 - TimeBound::Unbounded => Bound::Unbounded, 25 - TimeBound::Included(t) => Bound::Included(t), 26 - TimeBound::Excluded(t) => Bound::Excluded(t), 27 - } 28 - } 29 - }
···
-10
rust/iroh-streamplace/src/error.rs
··· 1 - #[derive(Debug, thiserror::Error, uniffi::Error)] 2 - #[uniffi(flat_error)] 3 - pub enum SPError { 4 - #[error("No certificate chain found")] 5 - NoCertificateChainFound, 6 - #[error("C2PA error: {0}")] 7 - C2paError(String), 8 - #[error("IO Error: {0}")] 9 - IOError(String), 10 - }
···
-833
rust/iroh-streamplace/src/lib.rs
··· 1 uniffi::setup_scaffolding!(); 2 3 - pub mod c2pa; 4 - pub mod error; 5 pub mod node_addr; 6 pub mod public_key; 7 - pub mod streams; 8 9 use std::sync::{LazyLock, Once}; 10 11 - mod db; 12 - pub use db::*; 13 - #[cfg(test)] 14 - mod tests; 15 - 16 - #[cfg(test)] 17 - mod test_stream; 18 - 19 mod socket; 20 pub use socket::*; 21 ··· 26 /// Ensure logging is only initialized once 27 static LOGGING_INIT: Once = Once::new(); 28 29 - use std::{ 30 - collections::{BTreeMap, BTreeSet, HashSet}, 31 - str::FromStr, 32 - sync::Arc, 33 - }; 34 - 35 - use bytes::Bytes; 36 - use iroh::{NodeId, PublicKey, RelayMode, SecretKey, discovery::static_provider::StaticProvider}; 37 - use iroh_base::ticket::NodeTicket; 38 - use iroh_gossip::{net::Gossip, proto::TopicId}; 39 - use irpc::{WithChannels, rpc::RemoteService}; 40 - use irpc_iroh::{IrohProtocol, IrohRemoteConnection}; 41 - use n0_future::future::Boxed; 42 - 43 - mod rpc { 44 - //! Protocol API 45 - use bytes::Bytes; 46 - use iroh::NodeId; 47 - use irpc::{channel::oneshot, rpc_requests}; 48 - use serde::{Deserialize, Serialize}; 49 - 50 - pub const ALPN: &[u8] = b"/iroh/streamplace/1"; 51 - 52 - /// Subscribe to the given `key` 53 - #[derive(Debug, Serialize, Deserialize)] 54 - pub struct Subscribe { 55 - pub key: String, 56 - // TODO: verify 57 - pub remote_id: NodeId, 58 - } 59 - 60 - /// Unsubscribe from the given `key` 61 - #[derive(Debug, Serialize, Deserialize)] 62 - pub struct Unsubscribe { 63 - pub key: String, 64 - // TODO: verify 65 - pub remote_id: NodeId, 66 - } 67 - 68 - // #[derive(Debug, Serialize, Deserialize)] 69 - // pub struct SendSegment { 70 - // pub key: String, 71 - // pub data: Bytes, 72 - // } 73 - 74 - #[derive(Debug, Clone, Serialize, Deserialize)] 75 - pub struct RecvSegment { 76 - pub from: NodeId, 77 - pub key: String, 78 - pub data: Bytes, 79 - } 80 - 81 - // Use the macro to generate both the Protocol and Message enums 82 - // plus implement Channels for each type 83 - #[rpc_requests(message = Message)] 84 - #[derive(Serialize, Deserialize, Debug)] 85 - pub enum Protocol { 86 - #[rpc(tx=oneshot::Sender<()>)] 87 - Subscribe(Subscribe), 88 - #[rpc(tx=oneshot::Sender<()>)] 89 - Unsubscribe(Unsubscribe), 90 - #[rpc(tx=oneshot::Sender<()>)] 91 - RecvSegment(RecvSegment), 92 - } 93 - } 94 - 95 - mod api { 96 - //! Protocol API 97 - use bytes::Bytes; 98 - use iroh::{NodeAddr, NodeId}; 99 - use irpc::{channel::oneshot, rpc_requests}; 100 - use serde::{Deserialize, Serialize}; 101 - 102 - /// Subscribe to the given `key` 103 - #[derive(Debug, Serialize, Deserialize)] 104 - pub struct Subscribe { 105 - pub key: String, 106 - // TODO: verify 107 - pub remote_id: NodeId, 108 - } 109 - 110 - /// Unsubscribe from the given `key` 111 - #[derive(Debug, Serialize, Deserialize)] 112 - pub struct Unsubscribe { 113 - pub key: String, 114 - // TODO: verify 115 - pub remote_id: NodeId, 116 - } 117 - 118 - #[derive(Debug, Serialize, Deserialize)] 119 - pub struct SendSegment { 120 - pub key: String, 121 - pub data: Bytes, 122 - } 123 - 124 - #[derive(Debug, Serialize, Deserialize)] 125 - pub struct JoinPeers { 126 - pub peers: Vec<NodeAddr>, 127 - } 128 - 129 - #[derive(Debug, Serialize, Deserialize)] 130 - pub struct AddTickets { 131 - pub peers: Vec<NodeAddr>, 132 - } 133 - 134 - #[derive(Debug, Serialize, Deserialize)] 135 - pub struct GetNodeAddr; 136 - 137 - #[derive(Debug, Serialize, Deserialize)] 138 - pub struct Shutdown; 139 - 140 - // Use the macro to generate both the Protocol and Message enums 141 - // plus implement Channels for each type 142 - #[rpc_requests(message = Message)] 143 - #[derive(Serialize, Deserialize, Debug)] 144 - pub enum Protocol { 145 - #[rpc(tx=oneshot::Sender<()>)] 146 - Subscribe(Subscribe), 147 - #[rpc(tx=oneshot::Sender<()>)] 148 - Unsubscribe(Unsubscribe), 149 - #[rpc(tx=oneshot::Sender<()>)] 150 - SendSegment(SendSegment), 151 - #[rpc(tx=oneshot::Sender<()>)] 152 - JoinPeers(JoinPeers), 153 - #[rpc(tx=oneshot::Sender<()>)] 154 - AddTickets(AddTickets), 155 - #[rpc(tx=oneshot::Sender<NodeAddr>)] 156 - GetNodeAddr(GetNodeAddr), 157 - #[rpc(tx=oneshot::Sender<()>)] 158 - Shutdown(Shutdown), 159 - } 160 - } 161 - use api::{Message as ApiMessage, Protocol as ApiProtocol}; 162 - use n0_future::{FuturesUnordered, StreamExt}; 163 - use rpc::{Message as RpcMessage, Protocol as RpcProtocol}; 164 - use snafu::Snafu; 165 - use tracing::{Instrument, debug, error, trace, trace_span, warn}; 166 - 167 - use crate::rpc::RecvSegment; 168 - 169 /// Initialize logging with the default subscriber that respects RUST_LOG environment variable. 170 /// This function is safe to call multiple times - it will only initialize logging once. 171 #[uniffi::export] ··· 191 tracing_subscriber::fmt().with_env_filter(filter).init(); 192 }); 193 } 194 - 195 - pub(crate) enum HandlerMode { 196 - Sender, 197 - Forwarder, 198 - Receiver(Arc<dyn DataHandler>), 199 - } 200 - 201 - impl HandlerMode { 202 - pub fn mode_str(&self) -> &'static str { 203 - match self { 204 - HandlerMode::Sender => "sender", 205 - HandlerMode::Forwarder => "forwarder", 206 - HandlerMode::Receiver(_) => "receiver", 207 - } 208 - } 209 - } 210 - 211 - type Tasks = FuturesUnordered<Boxed<(NodeId, Result<(), RpcTaskError>)>>; 212 - 213 - /// Actor that contains both a kv db for metadata and a handler for the rpc protocol. 214 - /// 215 - /// This can be used both for sender and receiver nodes. Sender nodes will just set the 216 - /// handler to None. 217 - struct Actor { 218 - /// Receiver for rpc messages from remote nodes 219 - rpc_rx: tokio::sync::mpsc::Receiver<RpcMessage>, 220 - /// Receiver for API messages from the user 221 - api_rx: tokio::sync::mpsc::Receiver<ApiMessage>, 222 - /// nodes I need to send to for each stream 223 - subscribers: BTreeMap<String, BTreeSet<NodeId>>, 224 - /// nodes I am subscribed to 225 - subscriptions: BTreeMap<String, NodeId>, 226 - /// lightweight typed connection pool 227 - connections: ConnectionPool, 228 - /// How to handle incoming data 229 - handler: HandlerMode, 230 - /// Static provider for node discovery 231 - sp: StaticProvider, 232 - /// Iroh protocol router, I need to keep it around to keep the protocol alive 233 - router: iroh::protocol::Router, 234 - /// Metadata db 235 - client: db::Db, 236 - /// Write scope for this node for the metadata db 237 - write: db::WriteScope, 238 - /// Ongoing tasks 239 - tasks: Tasks, 240 - /// Configuration, needed for timeouts etc. 241 - config: Arc<Config>, 242 - } 243 - 244 - #[derive(Debug, Clone)] 245 - struct Connection { 246 - id: NodeId, 247 - rpc: irpc::Client<RpcProtocol>, 248 - } 249 - 250 - #[derive(Debug, Snafu)] 251 - enum RpcTaskError { 252 - #[snafu(transparent)] 253 - Task { source: irpc::Error }, 254 - #[snafu(transparent)] 255 - Timeout { source: tokio::time::error::Elapsed }, 256 - } 257 - 258 - struct ConnectionPool { 259 - endpoint: iroh::Endpoint, 260 - connections: BTreeMap<NodeId, Connection>, 261 - } 262 - 263 - impl ConnectionPool { 264 - fn new(endpoint: iroh::Endpoint) -> Self { 265 - Self { 266 - endpoint, 267 - connections: BTreeMap::new(), 268 - } 269 - } 270 - 271 - /// Cheap conn pool hack 272 - fn get(&mut self, remote: &NodeId) -> Connection { 273 - if !self.connections.contains_key(remote) { 274 - trace!(remote = %remote.fmt_short(),"ConnectionPool.get is inserting a new remote connection"); 275 - let conn = IrohRemoteConnection::new( 276 - self.endpoint.clone(), 277 - (*remote).into(), 278 - rpc::ALPN.to_vec(), 279 - ); 280 - let conn = Connection { 281 - rpc: irpc::Client::boxed(conn), 282 - id: *remote, 283 - }; 284 - self.connections.insert(*remote, conn); 285 - } 286 - self.connections 287 - .get_mut(remote) 288 - .expect("just inserted") 289 - .clone() 290 - } 291 - 292 - fn remove(&mut self, remote: &NodeId) { 293 - self.connections.remove(remote); 294 - } 295 - } 296 - 297 - impl Actor { 298 - pub async fn spawn( 299 - endpoint: iroh::Endpoint, 300 - sp: StaticProvider, 301 - topic: iroh_gossip::proto::TopicId, 302 - config: Config, 303 - handler: HandlerMode, 304 - ) -> Result<(Node, impl Future<Output = ()>), iroh_gossip::api::ApiError> { 305 - let (rpc_tx, rpc_rx) = tokio::sync::mpsc::channel::<RpcMessage>(512); 306 - let (api_tx, api_rx) = tokio::sync::mpsc::channel::<ApiMessage>(512); 307 - let gossip = Gossip::builder().spawn(endpoint.clone()); 308 - let id = endpoint.node_id(); 309 - let router = iroh::protocol::Router::builder(endpoint.clone()) 310 - .accept(iroh_gossip::ALPN, gossip.clone()) 311 - .accept( 312 - rpc::ALPN, 313 - IrohProtocol::new(rpc::Protocol::remote_handler(rpc_tx.into())), 314 - ) 315 - .spawn(); 316 - let topic = gossip.subscribe(topic, vec![]).await?; 317 - let secret = router.endpoint().secret_key().clone(); 318 - let db_config = Default::default(); 319 - let client = iroh_smol_kv::Client::local(topic, db_config); 320 - let write = db::WriteScope::new(client.write(secret.clone())); 321 - let client = db::Db::new(client); 322 - let actor = Self { 323 - rpc_rx, 324 - api_rx, 325 - subscribers: BTreeMap::new(), 326 - subscriptions: BTreeMap::new(), 327 - connections: ConnectionPool::new(router.endpoint().clone()), 328 - handler, 329 - router, 330 - sp, 331 - write: write.clone(), 332 - client: client.clone(), 333 - tasks: FuturesUnordered::new(), 334 - config: Arc::new(config), 335 - }; 336 - let api = Node { 337 - client: Arc::new(client), 338 - write: Arc::new(write), 339 - api: irpc::Client::local(api_tx), 340 - }; 341 - Ok(( 342 - api, 343 - actor 344 - .run() 345 - .instrument(trace_span!("actor", id=%id.fmt_short())), 346 - )) 347 - } 348 - 349 - async fn run(mut self) { 350 - loop { 351 - tokio::select! { 352 - msg = self.rpc_rx.recv() => { 353 - trace!("received local rpc message"); 354 - let Some(msg) = msg else { 355 - error!("rpc channel closed"); 356 - break; 357 - }; 358 - self.handle_rpc(msg).instrument(trace_span!("rpc")).await; 359 - } 360 - msg = self.api_rx.recv() => { 361 - trace!("received remote rpc message"); 362 - let Some(msg) = msg else { 363 - break; 364 - }; 365 - if let Some(shutdown) = self.handle_api(msg).instrument(trace_span!("api")).await { 366 - shutdown.send(()).await.ok(); 367 - break; 368 - } 369 - } 370 - res = self.tasks.next(), if !self.tasks.is_empty() => { 371 - trace!("processing task"); 372 - let Some((remote_id, res)) = res else { 373 - error!("task finished but no result"); 374 - break; 375 - }; 376 - match res { 377 - Ok(()) => {} 378 - Err(RpcTaskError::Timeout { source }) => { 379 - warn!("call to {remote_id} timed out: {source}"); 380 - } 381 - Err(RpcTaskError::Task { source }) => { 382 - warn!("call to {remote_id} failed: {source}"); 383 - } 384 - } 385 - self.connections.remove(&remote_id); 386 - } 387 - } 388 - } 389 - warn!("RPC Actor loop has closed"); 390 - } 391 - 392 - async fn update_subscriber_meta(&mut self, key: &str) { 393 - let n = self 394 - .subscribers 395 - .get(key) 396 - .map(|s| s.len()) 397 - .unwrap_or_default(); 398 - let v = n.to_string().into_bytes(); 399 - self.write 400 - .put_impl(Some(key.as_bytes().to_vec()), b"subscribers", v.into()) 401 - .await 402 - .ok(); 403 - } 404 - 405 - /// Requests from remote nodes 406 - async fn handle_rpc(&mut self, msg: RpcMessage) { 407 - trace!("RPC.handle_rpc"); 408 - match msg { 409 - RpcMessage::Subscribe(msg) => { 410 - trace!(inner = ?msg.inner, "RpcMessage::Subscribe"); 411 - let WithChannels { 412 - tx, 413 - inner: rpc::Subscribe { key, remote_id }, 414 - .. 415 - } = msg; 416 - self.subscribers 417 - .entry(key.clone()) 418 - .or_default() 419 - .insert(remote_id); 420 - self.update_subscriber_meta(&key).await; 421 - tx.send(()).await.ok(); 422 - } 423 - RpcMessage::Unsubscribe(msg) => { 424 - debug!(inner = ?msg.inner, "RpcMessage::Unsubscribe"); 425 - let WithChannels { 426 - tx, 427 - inner: rpc::Unsubscribe { key, remote_id }, 428 - .. 429 - } = msg; 430 - if let Some(e) = self.subscribers.get_mut(&key) 431 - && !e.remove(&remote_id) 432 - { 433 - warn!( 434 - "unsubscribe: no subscription for {} from {}", 435 - key, remote_id 436 - ); 437 - } 438 - if let Some(subscriptions) = self.subscribers.get(&key) 439 - && subscriptions.is_empty() 440 - { 441 - self.subscribers.remove(&key); 442 - } 443 - self.update_subscriber_meta(&key).await; 444 - tx.send(()).await.ok(); 445 - } 446 - RpcMessage::RecvSegment(msg) => { 447 - trace!(inner = ?msg.inner, "RpcMessage::RecvSegment"); 448 - let WithChannels { 449 - tx, 450 - inner: rpc::RecvSegment { key, from, data }, 451 - .. 452 - } = msg; 453 - match &self.handler { 454 - HandlerMode::Sender => { 455 - warn!("received segment but in sender mode"); 456 - } 457 - HandlerMode::Forwarder => { 458 - trace!("forwarding segment"); 459 - if let Some(remotes) = self.subscribers.get(&key) { 460 - Self::handle_send( 461 - &mut self.tasks, 462 - &mut self.connections, 463 - &self.config, 464 - key, 465 - data, 466 - remotes, 467 - ); 468 - } else { 469 - trace!("no subscribers for stream {}", key); 470 - } 471 - } 472 - HandlerMode::Receiver(handler) => { 473 - if self.subscriptions.contains_key(&key) { 474 - let from = Arc::new(from.into()); 475 - handler.handle_data(from, key, data.to_vec()).await; 476 - } else { 477 - warn!("received segment for unsubscribed key: {}", key); 478 - } 479 - } 480 - }; 481 - tx.send(()).await.ok(); 482 - } 483 - } 484 - } 485 - 486 - async fn handle_api(&mut self, msg: ApiMessage) -> Option<irpc::channel::oneshot::Sender<()>> { 487 - trace!("RPC.handle_api"); 488 - match msg { 489 - ApiMessage::SendSegment(msg) => { 490 - trace!(inner = ?msg.inner, "ApiMessage::SendSegment"); 491 - let WithChannels { 492 - tx, 493 - inner: api::SendSegment { key, data }, 494 - .. 495 - } = msg; 496 - if let Some(remotes) = self.subscribers.get(&key) { 497 - Self::handle_send( 498 - &mut self.tasks, 499 - &mut self.connections, 500 - &self.config, 501 - key, 502 - data, 503 - remotes, 504 - ); 505 - } else { 506 - trace!("no subscribers for stream {}", key); 507 - } 508 - tx.send(()).await.ok(); 509 - } 510 - ApiMessage::Subscribe(msg) => { 511 - trace!(inner = ?msg.inner, "ApiMessage::Subscribe"); 512 - let WithChannels { 513 - tx, 514 - inner: api::Subscribe { key, remote_id }, 515 - .. 516 - } = msg; 517 - let conn = self.connections.get(&remote_id); 518 - tx.send(()).await.ok(); 519 - trace!(remote = %remote_id.fmt_short(), key = %key, "send rpc::Subscribe message"); 520 - conn.rpc 521 - .rpc(rpc::Subscribe { 522 - key: key.clone(), 523 - remote_id: self.node_id(), 524 - }) 525 - .await 526 - .ok(); 527 - trace!(remote = %remote_id.fmt_short(), key = %key, "inserting subscription"); 528 - self.subscriptions.insert(key, remote_id); 529 - trace!("finished inserting subscription"); 530 - } 531 - ApiMessage::Unsubscribe(msg) => { 532 - trace!(inner = ?msg.inner, "ApiMessage::Unsubscribe"); 533 - let WithChannels { 534 - tx, 535 - inner: api::Unsubscribe { key, remote_id }, 536 - .. 537 - } = msg; 538 - let conn = self.connections.get(&remote_id); 539 - tx.send(()).await.ok(); 540 - conn.rpc 541 - .rpc(rpc::Unsubscribe { 542 - key: key.clone(), 543 - remote_id: self.node_id(), 544 - }) 545 - .await 546 - .ok(); 547 - self.subscriptions.remove(&key); 548 - } 549 - ApiMessage::AddTickets(msg) => { 550 - trace!(inner = ?msg.inner, "ApiMessage::AddTickets"); 551 - let WithChannels { 552 - tx, 553 - inner: api::AddTickets { peers }, 554 - .. 555 - } = msg; 556 - for addr in &peers { 557 - self.sp.add_node_info(addr.clone()); 558 - } 559 - // self.client.inner().join_peers(ids).await.ok(); 560 - tx.send(()).await.ok(); 561 - } 562 - ApiMessage::JoinPeers(msg) => { 563 - trace!(inner = ?msg.inner, "ApiMessage::JoinPeers"); 564 - let WithChannels { 565 - tx, 566 - inner: api::JoinPeers { peers }, 567 - .. 568 - } = msg; 569 - let ids = peers 570 - .iter() 571 - .map(|a| a.node_id) 572 - .filter(|id| *id != self.node_id()) 573 - .collect::<HashSet<_>>(); 574 - for addr in &peers { 575 - self.sp.add_node_info(addr.clone()); 576 - } 577 - self.client.inner().join_peers(ids).await.ok(); 578 - tx.send(()).await.ok(); 579 - } 580 - ApiMessage::GetNodeAddr(msg) => { 581 - trace!(inner = ?msg.inner, "ApiMessage::GetNodeAddr"); 582 - let WithChannels { tx, .. } = msg; 583 - if !self.config.disable_relay { 584 - // don't await home relay if we have disabled relays, this will hang forever 585 - self.router.endpoint().online().await; 586 - } 587 - let addr = self.router.endpoint().node_addr(); 588 - tx.send(addr).await.ok(); 589 - } 590 - ApiMessage::Shutdown(msg) => { 591 - trace!(inner = ?msg.inner, "ApiMessage::Shutdown"); 592 - return Some(msg.tx); 593 - } 594 - } 595 - None 596 - } 597 - 598 - fn handle_send( 599 - tasks: &mut Tasks, 600 - connections: &mut ConnectionPool, 601 - config: &Arc<Config>, 602 - key: String, 603 - data: Bytes, 604 - remotes: &BTreeSet<NodeId>, 605 - ) { 606 - let me = connections.endpoint.node_id(); 607 - let msg = rpc::RecvSegment { 608 - key, 609 - data, 610 - from: me, 611 - }; 612 - for remote in remotes { 613 - trace!(remote = %remote.fmt_short(), key = %msg.key, "handle_send to remote"); 614 - let conn = connections.get(remote); 615 - tasks.push(Box::pin(Self::forward_task( 616 - config.clone(), 617 - conn, 618 - msg.clone(), 619 - ))); 620 - } 621 - } 622 - 623 - async fn forward_task( 624 - config: Arc<Config>, 625 - conn: Connection, 626 - msg: RecvSegment, 627 - ) -> (NodeId, Result<(), RpcTaskError>) { 628 - let id = conn.id; 629 - let res = async move { 630 - tokio::time::timeout(config.max_send_duration, conn.rpc.rpc(msg)).await??; 631 - Ok(()) 632 - } 633 - .await; 634 - (id, res) 635 - } 636 - 637 - fn node_id(&self) -> PublicKey { 638 - self.router.endpoint().node_id() 639 - } 640 - } 641 - 642 - /// Iroh-streamplace node that can send, forward or receive stream segments. 643 - #[derive(Clone, uniffi::Object)] 644 - pub struct Node { 645 - client: Arc<db::Db>, 646 - write: Arc<db::WriteScope>, 647 - api: irpc::Client<ApiProtocol>, 648 - } 649 - 650 - impl Node { 651 - pub(crate) async fn new_in_runtime( 652 - config: Config, 653 - handler: HandlerMode, 654 - ) -> Result<Arc<Self>, CreateError> { 655 - let mode_str = Bytes::from(handler.mode_str()); 656 - let secret_key = 657 - SecretKey::from_bytes(&<[u8; 32]>::try_from(config.key.clone()).map_err(|e| { 658 - CreateError::PrivateKey { 659 - size: e.len() as u64, 660 - } 661 - })?); 662 - let topic = 663 - TopicId::from_bytes(<[u8; 32]>::try_from(config.topic.clone()).map_err(|e| { 664 - CreateError::Topic { 665 - size: e.len() as u64, 666 - } 667 - })?); 668 - let relay_mode = if config.disable_relay { 669 - RelayMode::Disabled 670 - } else { 671 - RelayMode::Default 672 - }; 673 - let sp = StaticProvider::new(); 674 - let endpoint = iroh::Endpoint::builder() 675 - .secret_key(secret_key) 676 - .relay_mode(relay_mode) 677 - .discovery(sp.clone()) 678 - .bind() 679 - .await 680 - .map_err(|e| CreateError::Bind { 681 - message: e.to_string(), 682 - })?; 683 - let (api, actor) = Actor::spawn(endpoint, sp, topic, config, handler) 684 - .await 685 - .map_err(|e| CreateError::Subscribe { 686 - message: e.to_string(), 687 - })?; 688 - api.node_scope() 689 - .put_impl(Option::<Vec<u8>>::None, b"mode", mode_str) 690 - .await 691 - .ok(); 692 - tokio::spawn(actor); 693 - Ok(Arc::new(api)) 694 - } 695 - } 696 - 697 - /// DataHandler trait that is exported to go for receiving data callbacks. 698 - #[uniffi::export(with_foreign)] 699 - #[async_trait::async_trait] 700 - pub trait DataHandler: Send + Sync { 701 - async fn handle_data( 702 - &self, 703 - from: Arc<crate::public_key::PublicKey>, 704 - topic: String, 705 - data: Vec<u8>, 706 - ); 707 - } 708 - 709 - #[uniffi::export] 710 - impl Node { 711 - /// Create a new streamplace client node. 712 - #[uniffi::constructor] 713 - pub async fn sender(config: Config) -> Result<Arc<Self>, CreateError> { 714 - RUNTIME.block_on(Self::new_in_runtime(config, HandlerMode::Sender)) 715 - } 716 - 717 - #[uniffi::constructor] 718 - pub async fn forwarder(config: Config) -> Result<Arc<Self>, CreateError> { 719 - RUNTIME.block_on(Self::new_in_runtime(config, HandlerMode::Forwarder)) 720 - } 721 - 722 - #[uniffi::constructor] 723 - pub async fn receiver( 724 - config: Config, 725 - handler: Arc<dyn DataHandler>, 726 - ) -> Result<Arc<Self>, CreateError> { 727 - RUNTIME.block_on(Self::new_in_runtime(config, HandlerMode::Receiver(handler))) 728 - } 729 - 730 - /// Get a handle to the db to watch for changes locally or globally. 731 - pub fn db(&self) -> Arc<db::Db> { 732 - self.client.clone() 733 - } 734 - 735 - /// Get a handle to the write scope for this node. 736 - /// 737 - /// This is equivalent to calling `db.write(...)` with the secret key used to create the node. 738 - pub fn node_scope(&self) -> Arc<db::WriteScope> { 739 - self.write.clone() 740 - } 741 - 742 - /// Subscribe to updates for a given stream from a remote node. 743 - pub async fn subscribe( 744 - &self, 745 - key: String, 746 - remote_id: Arc<crate::public_key::PublicKey>, 747 - ) -> Result<(), PutError> { 748 - self.api 749 - .rpc(api::Subscribe { 750 - key, 751 - remote_id: remote_id.as_ref().into(), 752 - }) 753 - .await 754 - .map_err(|e| PutError::Irpc { 755 - message: e.to_string(), 756 - }) 757 - } 758 - 759 - /// Unsubscribe from updates for a given stream from a remote node. 760 - pub async fn unsubscribe( 761 - &self, 762 - key: String, 763 - remote_id: Arc<crate::public_key::PublicKey>, 764 - ) -> Result<(), PutError> { 765 - self.api 766 - .rpc(api::Unsubscribe { 767 - key, 768 - remote_id: remote_id.as_ref().into(), 769 - }) 770 - .await 771 - .map_err(|e| PutError::Irpc { 772 - message: e.to_string(), 773 - }) 774 - } 775 - 776 - /// Send a segment to all subscribers of the given stream. 777 - pub async fn send_segment(&self, key: String, data: Vec<u8>) -> Result<(), PutError> { 778 - debug!(key = &key, data_len = data.len(), "Node.send_segment"); 779 - self.api 780 - .rpc(api::SendSegment { 781 - key, 782 - data: data.into(), 783 - }) 784 - .await 785 - .map_err(|e| PutError::Irpc { 786 - message: e.to_string(), 787 - }) 788 - } 789 - 790 - /// Join peers by their node tickets. 791 - pub async fn join_peers(&self, peers: Vec<String>) -> Result<(), JoinPeersError> { 792 - let peers = peers 793 - .iter() 794 - .map(|p| NodeTicket::from_str(p)) 795 - .collect::<Result<Vec<_>, _>>() 796 - .map_err(|e| JoinPeersError::Ticket { 797 - message: e.to_string(), 798 - })?; 799 - let addrs = peers 800 - .iter() 801 - .map(|t| t.node_addr().clone()) 802 - .collect::<Vec<_>>(); 803 - self.api 804 - .rpc(api::JoinPeers { peers: addrs }) 805 - .await 806 - .map_err(|e| JoinPeersError::Irpc { 807 - message: e.to_string(), 808 - }) 809 - } 810 - 811 - /// Add tickets for remote peers 812 - pub async fn add_tickets(&self, peers: Vec<String>) -> Result<(), JoinPeersError> { 813 - let peers = peers 814 - .iter() 815 - .map(|p| NodeTicket::from_str(p)) 816 - .collect::<Result<Vec<_>, _>>() 817 - .map_err(|e| JoinPeersError::Ticket { 818 - message: e.to_string(), 819 - })?; 820 - let addrs = peers 821 - .iter() 822 - .map(|t| t.node_addr().clone()) 823 - .collect::<Vec<_>>(); 824 - self.api 825 - .rpc(api::AddTickets { peers: addrs }) 826 - .await 827 - .map_err(|e| JoinPeersError::Irpc { 828 - message: e.to_string(), 829 - }) 830 - } 831 - 832 - /// Get this node's ticket. 833 - pub async fn ticket(&self) -> Result<String, PutError> { 834 - let addr = self 835 - .api 836 - .rpc(api::GetNodeAddr) 837 - .await 838 - .map_err(|e| PutError::Irpc { 839 - message: e.to_string(), 840 - })?; 841 - Ok(NodeTicket::from(addr).to_string()) 842 - } 843 - 844 - /// Get this node's node ID. 845 - pub async fn node_id(&self) -> Result<Arc<crate::public_key::PublicKey>, PutError> { 846 - let addr = self 847 - .api 848 - .rpc(api::GetNodeAddr) 849 - .await 850 - .map_err(|e| PutError::Irpc { 851 - message: e.to_string(), 852 - })?; 853 - Ok(Arc::new(addr.node_id.into())) 854 - } 855 - 856 - /// Shutdown the node, including the streaming system and the metadata db. 857 - pub async fn shutdown(&self) -> Result<(), ShutdownError> { 858 - // shut down both the streams and the db concurrently, even if one fails 859 - let (res1, res2) = tokio::join!(self.shutdown_streams(), self.client.shutdown()); 860 - res1?; 861 - res2?; 862 - Ok(()) 863 - } 864 - } 865 - 866 - impl Node { 867 - async fn shutdown_streams(&self) -> std::result::Result<(), ShutdownError> { 868 - self.api 869 - .rpc(api::Shutdown) 870 - .await 871 - .map_err(|e| ShutdownError::Irpc { 872 - message: e.to_string(), 873 - }) 874 - } 875 - }
··· 1 uniffi::setup_scaffolding!(); 2 3 pub mod node_addr; 4 pub mod public_key; 5 6 use std::sync::{LazyLock, Once}; 7 8 mod socket; 9 pub use socket::*; 10 ··· 15 /// Ensure logging is only initialized once 16 static LOGGING_INIT: Once = Once::new(); 17 18 /// Initialize logging with the default subscriber that respects RUST_LOG environment variable. 19 /// This function is safe to call multiple times - it will only initialize logging once. 20 #[uniffi::export] ··· 40 tracing_subscriber::fmt().with_env_filter(filter).init(); 41 }); 42 }
+41 -17
rust/iroh-streamplace/src/socket.rs
··· 46 self.alpn.clone() 47 } 48 49 - /// Accept an incoming connection and return a [`Stream2`]. 50 - pub async fn accept(&self) -> Result<Arc<Stream2>, AcceptError> { 51 RUNTIME.block_on(self.accept0()) 52 } 53 54 - /// Connect to a peer at the given [`NodeAddr`] and return a [`Stream2`]. 55 pub async fn connect( 56 &self, 57 addr: Arc<crate::node_addr::NodeAddr>, 58 - ) -> Result<Arc<Stream2>, ConnectError> { 59 RUNTIME.block_on(self.connect0(addr)) 60 } 61 ··· 83 }) 84 } 85 86 - async fn accept0(&self) -> Result<Arc<Stream2>, AcceptError> { 87 let incoming = self 88 .endpoint 89 .accept() ··· 97 let (send, recv) = conn.accept_bi().await.map_err(|e| AcceptError::Other { 98 message: e.to_string(), 99 })?; 100 - Ok(Arc::new(Stream2 { 101 recv: tokio::sync::Mutex::new(recv), 102 send: tokio::sync::Mutex::new(send), 103 conn, ··· 107 async fn connect0( 108 &self, 109 addr: Arc<crate::node_addr::NodeAddr>, 110 - ) -> Result<Arc<Stream2>, ConnectError> { 111 let node_addr: iroh::NodeAddr = 112 (*addr) 113 .clone() ··· 125 let (send, recv) = conn.open_bi().await.map_err(|e| ConnectError::Other { 126 message: e.to_string(), 127 })?; 128 - Ok(Arc::new(Stream2 { 129 recv: tokio::sync::Mutex::new(recv), 130 send: tokio::sync::Mutex::new(send), 131 conn, ··· 156 157 #[derive(Debug, thiserror::Error, uniffi::Error)] 158 #[uniffi(flat_error)] 159 - pub enum WriteError2 { 160 #[error("Other error: {message}")] 161 Other { message: String }, 162 } ··· 168 Other { message: String }, 169 } 170 171 #[derive(Debug, uniffi::Object)] 172 - pub struct Stream2 { 173 recv: tokio::sync::Mutex<iroh::endpoint::RecvStream>, 174 send: tokio::sync::Mutex<iroh::endpoint::SendStream>, 175 conn: iroh::endpoint::Connection, 176 } 177 178 #[uniffi::export] 179 - impl Stream2 { 180 pub async fn read(&self, n: u64) -> Result<Vec<u8>, ReadError> { 181 let mut buf = vec![0u8; n as usize]; 182 let n = self ··· 195 Ok(buf) 196 } 197 198 - pub async fn write_all(&self, buf: &[u8]) -> Result<(), WriteError2> { 199 - self.send.lock().await.write_all(buf).await.map_err(|e| WriteError2::Other { 200 message: e.to_string(), 201 }) 202 } 203 204 - pub async fn write(&self, buf: &[u8]) -> Result<u32, WriteError2> { 205 let n = self.send 206 .lock() 207 .await 208 .write(&buf) 209 .await 210 - .map_err(|e| WriteError2::Other { 211 message: e.to_string(), 212 })?; 213 Ok(n as u32) 214 } 215 216 - pub async fn close_write(&self) -> Result<(), WriteError2> { 217 - self.send.lock().await.finish().map_err(|e| WriteError2::Other { 218 message: e.to_string(), 219 })?; 220 Ok(()) 221 } 222 223 pub async fn close_read(&self) -> Result<(), ReadError> { 224 self.recv.lock().await.stop(0u32.into()).map_err(|e| ReadError::Other { 225 message: e.to_string(), ··· 227 Ok(()) 228 } 229 230 pub fn close(&self) { 231 self.conn.close(0u32.into(), b""); 232 } 233 234 pub async fn closed(&self) { 235 RUNTIME.block_on(async { 236 let _reason = self.conn.closed().await;
··· 46 self.alpn.clone() 47 } 48 49 + /// Accept an incoming connection and return a [`Stream`]. 50 + pub async fn accept(&self) -> Result<Arc<Stream>, AcceptError> { 51 RUNTIME.block_on(self.accept0()) 52 } 53 54 + /// Connect to a peer at the given [`NodeAddr`] and return a [`Stream`]. 55 pub async fn connect( 56 &self, 57 addr: Arc<crate::node_addr::NodeAddr>, 58 + ) -> Result<Arc<Stream>, ConnectError> { 59 RUNTIME.block_on(self.connect0(addr)) 60 } 61 ··· 83 }) 84 } 85 86 + async fn accept0(&self) -> Result<Arc<Stream>, AcceptError> { 87 let incoming = self 88 .endpoint 89 .accept() ··· 97 let (send, recv) = conn.accept_bi().await.map_err(|e| AcceptError::Other { 98 message: e.to_string(), 99 })?; 100 + Ok(Arc::new(Stream { 101 recv: tokio::sync::Mutex::new(recv), 102 send: tokio::sync::Mutex::new(send), 103 conn, ··· 107 async fn connect0( 108 &self, 109 addr: Arc<crate::node_addr::NodeAddr>, 110 + ) -> Result<Arc<Stream>, ConnectError> { 111 let node_addr: iroh::NodeAddr = 112 (*addr) 113 .clone() ··· 125 let (send, recv) = conn.open_bi().await.map_err(|e| ConnectError::Other { 126 message: e.to_string(), 127 })?; 128 + Ok(Arc::new(Stream { 129 recv: tokio::sync::Mutex::new(recv), 130 send: tokio::sync::Mutex::new(send), 131 conn, ··· 156 157 #[derive(Debug, thiserror::Error, uniffi::Error)] 158 #[uniffi(flat_error)] 159 + pub enum WriteError { 160 #[error("Other error: {message}")] 161 Other { message: String }, 162 } ··· 168 Other { message: String }, 169 } 170 171 + /// A bidirectional stream over an iroh connection. 172 + /// 173 + /// In QUIC streams and connections are separate concepts. A connection can have multiple streams. 174 + /// For simplicity we expose a single bidirectional stream per connection here. 175 #[derive(Debug, uniffi::Object)] 176 + pub struct Stream { 177 recv: tokio::sync::Mutex<iroh::endpoint::RecvStream>, 178 send: tokio::sync::Mutex<iroh::endpoint::SendStream>, 179 conn: iroh::endpoint::Connection, 180 } 181 182 #[uniffi::export] 183 + impl Stream { 184 + 185 + /// Read up to n bytes from the stream. 186 + /// 187 + /// Due to the way uniffi works, this can't have the signature that is 188 + /// usually used in golang code. Instead of taking a mutable buffer and 189 + /// returning the number of bytes read, it takes the number of bytes to read 190 + /// and returns a vector with the data read. 191 + /// 192 + /// Wrapping this into a more idiomatic golang interface needs a few lines 193 + /// on the golang side. 194 pub async fn read(&self, n: u64) -> Result<Vec<u8>, ReadError> { 195 let mut buf = vec![0u8; n as usize]; 196 let n = self ··· 209 Ok(buf) 210 } 211 212 + /// Write all bytes in buf to the stream. 213 + pub async fn write_all(&self, buf: &[u8]) -> Result<(), WriteError> { 214 + self.send.lock().await.write_all(buf).await.map_err(|e| WriteError::Other { 215 message: e.to_string(), 216 }) 217 } 218 219 + /// Write up to n bytes from buf to the stream. 220 + pub async fn write(&self, buf: &[u8]) -> Result<u32, WriteError> { 221 let n = self.send 222 .lock() 223 .await 224 .write(&buf) 225 .await 226 + .map_err(|e| WriteError::Other { 227 message: e.to_string(), 228 })?; 229 Ok(n as u32) 230 } 231 232 + /// Close the write side of the stream. 233 + /// 234 + /// Note: this does not close the underlying connection. 235 + pub async fn close_write(&self) -> Result<(), WriteError> { 236 + self.send.lock().await.finish().map_err(|e| WriteError::Other { 237 message: e.to_string(), 238 })?; 239 Ok(()) 240 } 241 242 + /// Close the read side of the stream. 243 + /// 244 + /// Note: this does not close the underlying connection. 245 pub async fn close_read(&self) -> Result<(), ReadError> { 246 self.recv.lock().await.stop(0u32.into()).map_err(|e| ReadError::Other { 247 message: e.to_string(), ··· 249 Ok(()) 250 } 251 252 + /// Close the underlying connection. 253 pub fn close(&self) { 254 self.conn.close(0u32.into(), b""); 255 } 256 257 + /// Wait until the connection is closed. 258 pub async fn closed(&self) { 259 RUNTIME.block_on(async { 260 let _reason = self.conn.closed().await;
-168
rust/iroh-streamplace/src/streams.rs
··· 1 - // Copyright 2023 Adobe. All rights reserved. 2 - // This file is licensed to you under the Apache License, 3 - // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 4 - // or the MIT license (http://opensource.org/licenses/MIT), 5 - // at your option. 6 - 7 - // Unless required by applicable law or agreed to in writing, 8 - // this software is distributed on an "AS IS" BASIS, WITHOUT 9 - // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or 10 - // implied. See the LICENSE-MIT and LICENSE-APACHE files for the 11 - // specific language governing permissions and limitations under 12 - // each license. 13 - 14 - use std::{ 15 - io::{Read, Seek, SeekFrom, Write}, 16 - sync::Arc, 17 - }; 18 - 19 - use crate::error::SPError; 20 - 21 - // #[repr(C)] 22 - // #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 23 - // pub enum SeekMode { 24 - // Start = 0, 25 - // End = 1, 26 - // Current = 2, 27 - // } 28 - 29 - /// This allows for a callback stream over the Uniffi interface. 30 - /// Implement these stream functions in the foreign language 31 - /// and this will provide Rust Stream trait implementations 32 - /// This is necessary since the Rust traits cannot be implemented directly 33 - /// as uniffi callbacks 34 - #[uniffi::export(with_foreign)] 35 - pub trait Stream: Send + Sync { 36 - /// Read a stream of bytes from the stream 37 - fn read_stream(&self, length: u64) -> Result<Vec<u8>, SPError>; 38 - /// Seek to a position in the stream 39 - fn seek_stream(&self, pos: i64, mode: u64) -> Result<u64, SPError>; 40 - /// Write a stream of bytes to the stream 41 - fn write_stream(&self, data: Vec<u8>) -> Result<u64, SPError>; 42 - } 43 - 44 - impl Stream for Arc<dyn Stream> { 45 - fn read_stream(&self, length: u64) -> Result<Vec<u8>, SPError> { 46 - (**self).read_stream(length) 47 - } 48 - 49 - fn seek_stream(&self, pos: i64, mode: u64) -> Result<u64, SPError> { 50 - (**self).seek_stream(pos, mode) 51 - } 52 - 53 - fn write_stream(&self, data: Vec<u8>) -> Result<u64, SPError> { 54 - (**self).write_stream(data) 55 - } 56 - } 57 - 58 - impl AsMut<dyn Stream> for dyn Stream { 59 - fn as_mut(&mut self) -> &mut Self { 60 - self 61 - } 62 - } 63 - 64 - pub struct StreamAdapter<'a> { 65 - pub stream: &'a dyn Stream, 66 - } 67 - 68 - impl<'a> StreamAdapter<'a> { 69 - pub fn from_stream_mut(stream: &'a mut dyn Stream) -> Self { 70 - Self { stream } 71 - } 72 - } 73 - 74 - impl<'a> From<&'a dyn Stream> for StreamAdapter<'a> { 75 - fn from(stream: &'a dyn Stream) -> Self { 76 - Self { stream } 77 - } 78 - } 79 - 80 - impl<'a> Read for StreamAdapter<'a> { 81 - fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { 82 - let mut bytes = self 83 - .stream 84 - .read_stream(buf.len() as u64) 85 - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; 86 - let len = bytes.len(); 87 - buf.iter_mut().zip(bytes.drain(..)).for_each(|(dest, src)| { 88 - *dest = src; 89 - }); 90 - //println!("read: {:?}", len); 91 - Ok(len) 92 - } 93 - } 94 - 95 - impl<'a> Seek for StreamAdapter<'a> { 96 - fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> { 97 - let (pos, mode) = match pos { 98 - SeekFrom::Current(pos) => (pos, 2), 99 - SeekFrom::Start(pos) => (pos as i64, 0), 100 - SeekFrom::End(pos) => (pos, 1), 101 - }; 102 - //println!("Stream Seek {}", pos); 103 - self.stream 104 - .seek_stream(pos, mode) 105 - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)) 106 - } 107 - } 108 - 109 - impl<'a> Write for StreamAdapter<'a> { 110 - fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { 111 - let len = self 112 - .stream 113 - .write_stream(buf.to_vec()) 114 - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?; 115 - Ok(len as usize) 116 - } 117 - 118 - fn flush(&mut self) -> std::io::Result<()> { 119 - Ok(()) 120 - } 121 - } 122 - 123 - #[uniffi::export(with_foreign)] 124 - pub trait ManyStreams: Send + Sync { 125 - /// Get the next stream from the many streams 126 - fn next(&self) -> Option<Arc<dyn Stream>>; 127 - } 128 - 129 - #[cfg(test)] 130 - mod tests { 131 - use super::*; 132 - use crate::test_stream::TestStream; 133 - 134 - #[test] 135 - fn test_stream_read() { 136 - let mut test = TestStream::from_memory(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); 137 - let mut stream = StreamAdapter::from_stream_mut(&mut test); 138 - let mut buf = [0u8; 5]; 139 - let len = stream.read(&mut buf).unwrap(); 140 - assert_eq!(len, 5); 141 - assert_eq!(buf, [0, 1, 2, 3, 4]); 142 - } 143 - 144 - #[test] 145 - fn test_stream_seek() { 146 - let mut test = TestStream::from_memory(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); 147 - let mut stream = StreamAdapter { stream: &mut test }; 148 - let pos = stream.seek(SeekFrom::Start(5)).unwrap(); 149 - assert_eq!(pos, 5); 150 - let mut buf = [0u8; 5]; 151 - let len = stream.read(&mut buf).unwrap(); 152 - assert_eq!(len, 5); 153 - assert_eq!(buf, [5, 6, 7, 8, 9]); 154 - } 155 - 156 - #[test] 157 - fn test_stream_write() { 158 - let mut test = TestStream::new(); 159 - let mut stream = StreamAdapter { stream: &mut test }; 160 - let len = stream.write(&[0, 1, 2, 3, 4]).unwrap(); 161 - assert_eq!(len, 5); 162 - stream.seek(SeekFrom::Start(0)).unwrap(); 163 - let mut buf = [0u8; 5]; 164 - let len = stream.read(&mut buf).unwrap(); 165 - assert_eq!(len, 5); 166 - assert_eq!(buf, [0, 1, 2, 3, 4]); 167 - } 168 - }
···
-80
rust/iroh-streamplace/src/test_stream.rs
··· 1 - // Copyright 2023 Adobe. All rights reserved. 2 - // This file is licensed to you under the Apache License, 3 - // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) 4 - // or the MIT license (http://opensource.org/licenses/MIT), 5 - // at your option. 6 - 7 - // Unless required by applicable law or agreed to in writing, 8 - // this software is distributed on an "AS IS" BASIS, WITHOUT 9 - // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or 10 - // implied. See the LICENSE-MIT and LICENSE-APACHE files for the 11 - // specific language governing permissions and limitations under 12 - // each license. 13 - 14 - use std::{ 15 - io::{Cursor, Read, Seek, SeekFrom, Write}, 16 - sync::RwLock, 17 - }; 18 - 19 - use crate::{error::SPError, streams::Stream}; 20 - 21 - pub struct TestStream { 22 - stream: RwLock<Cursor<Vec<u8>>>, 23 - } 24 - 25 - impl TestStream { 26 - pub fn new() -> Self { 27 - Self { 28 - stream: RwLock::new(Cursor::new(Vec::new())), 29 - } 30 - } 31 - pub fn from_memory(data: Vec<u8>) -> Self { 32 - Self { 33 - stream: RwLock::new(Cursor::new(data)), 34 - } 35 - } 36 - } 37 - 38 - impl Stream for TestStream { 39 - fn read_stream(&self, length: u64) -> Result<Vec<u8>, SPError> { 40 - if let Ok(mut stream) = RwLock::write(&self.stream) { 41 - let mut data = vec![0u8; length as usize]; 42 - let bytes_read = stream 43 - .read(&mut data) 44 - .map_err(|e| SPError::IOError(e.to_string()))?; 45 - data.truncate(bytes_read); 46 - //println!("read_stream: {:?}, pos {:?}", data.len(), (*stream).position()); 47 - Ok(data) 48 - } else { 49 - Err(SPError::IOError("RwLock".to_string()))? 50 - } 51 - } 52 - 53 - fn seek_stream(&self, pos: i64, mode: u64) -> Result<u64, SPError> { 54 - if let Ok(mut stream) = RwLock::write(&self.stream) { 55 - //stream.seek(SeekFrom::Start(pos as u64)).map_err(|e| StreamError::Io{ reason: e.to_string()})?; 56 - let whence = match mode { 57 - 0 => SeekFrom::Start(pos as u64), 58 - 1 => SeekFrom::End(pos as i64), 59 - 2 => SeekFrom::Current(pos as i64), 60 - 3_u64..=u64::MAX => unimplemented!(), 61 - }; 62 - Ok(stream 63 - .seek(whence) 64 - .map_err(|e| SPError::IOError(e.to_string()))?) 65 - } else { 66 - Err(SPError::IOError("RwLock".to_string())) 67 - } 68 - } 69 - 70 - fn write_stream(&self, data: Vec<u8>) -> Result<u64, SPError> { 71 - if let Ok(mut stream) = RwLock::write(&self.stream) { 72 - let len = stream 73 - .write(&data) 74 - .map_err(|e| SPError::IOError(e.to_string()))?; 75 - Ok(len as u64) 76 - } else { 77 - Err(SPError::IOError("RwLock".to_string()))? 78 - } 79 - } 80 - }
···
-299
rust/iroh-streamplace/src/tests.rs
··· 1 - use std::{ops::Deref, sync::Arc, time::Duration}; 2 - 3 - use async_trait::async_trait; 4 - use n0_future::{BufferedStreamExt, StreamExt, stream}; 5 - use testresult::TestResult; 6 - 7 - use super::*; 8 - 9 - struct TestNode { 10 - node: Arc<Node>, 11 - public: Arc<crate::public_key::PublicKey>, 12 - ticket: String, 13 - #[allow(dead_code)] 14 - private: Vec<u8>, 15 - } 16 - 17 - impl Deref for TestNode { 18 - type Target = Node; 19 - 20 - fn deref(&self) -> &Self::Target { 21 - &self.node 22 - } 23 - } 24 - 25 - impl TestNode { 26 - /// Helper to create a test node with given config and handler mode. 27 - async fn new(handler: HandlerMode) -> TestResult<TestNode> { 28 - let config = Config { 29 - key: vec![0_u8; 32], // will be replaced 30 - topic: vec![0_u8; 32], // all nodes use the same topic 31 - max_send_duration: Duration::from_secs(10), 32 - disable_relay: false, 33 - }; 34 - Self::new_with_config(handler, config).await 35 - } 36 - 37 - async fn new_with_config(handler: HandlerMode, mut config: Config) -> TestResult<TestNode> { 38 - let key = iroh::SecretKey::generate(&mut rand::rng()); 39 - let key = key.to_bytes().to_vec(); 40 - config.key = key.clone(); 41 - let node = Node::new_in_runtime(config, handler).await?; 42 - let public = node.node_id().await?; 43 - let ticket = node.ticket().await?; 44 - Ok(TestNode { 45 - node, 46 - private: key, 47 - public, 48 - ticket, 49 - }) 50 - } 51 - } 52 - 53 - /// Helper to create multiple test nodes with given handler mode. 54 - async fn test_nodes( 55 - n: usize, 56 - handler: impl Fn(usize) -> HandlerMode + Send + Sync, 57 - disable_relay: bool, 58 - ) -> TestResult<Vec<TestNode>> { 59 - const PAR: usize = 32; 60 - let modes = (0..n).map(handler).collect::<Vec<_>>(); 61 - 62 - let config = Config { 63 - key: vec![0_u8; 32], // will be replaced 64 - topic: vec![0_u8; 32], 65 - max_send_duration: Duration::from_secs(10), 66 - disable_relay, 67 - }; 68 - // create all nodes in parallel 69 - let nodes = stream::iter(modes) 70 - .map(|mode| TestNode::new_with_config(mode, config.clone())) 71 - .buffered_unordered(PAR) 72 - .collect::<Vec<_>>() 73 - .await; 74 - let nodes = nodes.into_iter().collect::<TestResult<Vec<_>>>()?; 75 - // join everyone to everyone 76 - let tickets = nodes.iter().map(|n| n.ticket.clone()).collect::<Vec<_>>(); 77 - let res = stream::iter(&nodes) 78 - .map(|n| n.join_peers(tickets.clone())) 79 - .buffered_unordered(PAR) 80 - .collect::<Vec<_>>() 81 - .await; 82 - res.into_iter().collect::<Result<Vec<_>, _>>()?; 83 - Ok(nodes) 84 - } 85 - 86 - #[tokio::test] 87 - async fn one_node() -> TestResult<()> { 88 - tracing_subscriber::fmt::try_init().ok(); 89 - let node = TestNode::new(HandlerMode::Sender).await?.node; 90 - let write = node.node_scope(); 91 - let db = node.db(); 92 - println!("Ticket: {}", node.ticket().await?); 93 - write 94 - .put(Some(b"stream1".to_vec()), b"s".to_vec(), b"y".to_vec()) 95 - .await?; 96 - write 97 - .put(Some(b"stream2".to_vec()), b"s".to_vec(), b"y".to_vec()) 98 - .await?; 99 - let res = db.subscribe_with_opts(SubscribeOpts { 100 - filter: Filter::new(), 101 - mode: SubscribeMode::Both, 102 - }); 103 - while let Some(item) = res.next_raw().await? { 104 - if let SubscribeItem::CurrentDone = item { 105 - break; 106 - } 107 - println!("Got item: {item:?}"); 108 - } 109 - let res = db 110 - .iter_with_opts( 111 - Filter::new() 112 - .stream(b"stream1".to_vec()) 113 - .scope(node.node_id().await?), 114 - ) 115 - .await?; 116 - println!("Iter result: {res:?}"); 117 - Ok(()) 118 - } 119 - 120 - struct TestHandler<T> { 121 - info: T, 122 - sender: tokio::sync::mpsc::Sender<(T, String, Vec<u8>)>, 123 - } 124 - 125 - impl<T> TestHandler<T> { 126 - fn new(info: T, sender: tokio::sync::mpsc::Sender<(T, String, Vec<u8>)>) -> Self { 127 - Self { info, sender } 128 - } 129 - } 130 - 131 - #[async_trait] 132 - impl<T: Clone + Send + Sync + 'static> DataHandler for TestHandler<T> { 133 - async fn handle_data(&self, _from: Arc<public_key::PublicKey>, topic: String, data: Vec<u8>) { 134 - self.sender 135 - .send((self.info.clone(), topic, data)) 136 - .await 137 - .ok(); 138 - } 139 - } 140 - 141 - #[tokio::test] 142 - async fn two_nodes_send_receive() -> TestResult<()> { 143 - tracing_subscriber::fmt::try_init().ok(); 144 - let (tx, mut rx) = tokio::sync::mpsc::channel(32); 145 - let handler = Arc::new(TestHandler::new((), tx)); 146 - let sender = TestNode::new(HandlerMode::Sender).await?; 147 - let receiver = TestNode::new(HandlerMode::Receiver(handler)).await?; 148 - // join the sender to the receiver. This will also configure the receiver endpoint to be able to dial the sender. 149 - receiver.join_peers(vec![sender.ticket.clone()]).await?; 150 - let stream = "teststream".to_string(); 151 - receiver 152 - .subscribe(stream.clone(), sender.public.clone()) 153 - .await?; 154 - sender.send_segment(stream, b"segment1".to_vec()).await?; 155 - let (_, stream, data) = rx.recv().await.expect("should get data"); 156 - assert_eq!(stream, "teststream"); 157 - assert_eq!(data, b"segment1".to_vec()); 158 - Ok(()) 159 - } 160 - 161 - #[tokio::test] 162 - async fn three_nodes_send_forward_receive() -> TestResult<()> { 163 - tracing_subscriber::fmt::try_init().ok(); 164 - let (tx, mut rx) = tokio::sync::mpsc::channel(32); 165 - let handler = Arc::new(TestHandler::new((), tx)); 166 - let sender = TestNode::new(HandlerMode::Sender).await?; 167 - let forwarder = TestNode::new(HandlerMode::Forwarder).await?; 168 - let receiver = TestNode::new(HandlerMode::Receiver(handler)).await?; 169 - // join everyone to everyone, so the receiver can reach the sender via the forwarder. 170 - let tickets = vec![ 171 - sender.ticket.clone(), 172 - forwarder.ticket.clone(), 173 - receiver.ticket.clone(), 174 - ]; 175 - receiver.join_peers(tickets.clone()).await?; 176 - forwarder.join_peers(tickets.clone()).await?; 177 - sender.join_peers(tickets).await?; 178 - let stream = "teststream".to_string(); 179 - receiver 180 - .subscribe(stream.clone(), forwarder.public.clone()) 181 - .await?; 182 - forwarder 183 - .subscribe(stream.clone(), sender.public.clone()) 184 - .await?; 185 - sender.send_segment(stream, b"segment1".to_vec()).await?; 186 - let (_, stream, data) = rx.recv().await.expect("should get data"); 187 - assert_eq!(stream, "teststream"); 188 - assert_eq!(data, b"segment1".to_vec()); 189 - Ok(()) 190 - } 191 - 192 - #[tokio::test] 193 - async fn meta_three_nodes_send_forward_receive() -> TestResult<()> { 194 - tracing_subscriber::fmt::try_init().ok(); 195 - let (tx, mut rx) = tokio::sync::mpsc::channel(32); 196 - let handler = Arc::new(TestHandler::new((), tx)); 197 - let sender = TestNode::new(HandlerMode::Sender).await?; 198 - let forwarder = TestNode::new(HandlerMode::Forwarder).await?; 199 - let receiver = TestNode::new(HandlerMode::Receiver(handler)).await?; 200 - // join everyone to everyone, so the receiver can reach the sender via the forwarder. 201 - let tickets = vec![ 202 - sender.ticket.clone(), 203 - forwarder.ticket.clone(), 204 - receiver.ticket.clone(), 205 - ]; 206 - receiver.join_peers(tickets.clone()).await?; 207 - forwarder.join_peers(tickets.clone()).await?; 208 - sender.join_peers(tickets).await?; 209 - let stream = "teststream".to_string(); 210 - receiver 211 - .subscribe(stream.clone(), forwarder.public.clone()) 212 - .await?; 213 - forwarder 214 - .subscribe(stream.clone(), sender.public.clone()) 215 - .await?; 216 - sender.send_segment(stream, b"segment1".to_vec()).await?; 217 - let (_, stream, data) = rx.recv().await.expect("should get data"); 218 - assert_eq!(stream, "teststream"); 219 - assert_eq!(data, b"segment1".to_vec()); 220 - let stream = receiver.db().subscribe(Filter::new()); 221 - while let Some(item) = stream.next_raw().await? { 222 - println!("{}", subscribe_item_debug(&item)); 223 - } 224 - Ok(()) 225 - } 226 - 227 - async fn broadcast( 228 - nsenders: usize, 229 - nforwarders: usize, 230 - nreceivers: usize, 231 - nmsgs: usize, 232 - ) -> TestResult<()> { 233 - let (tx, mut rx) = tokio::sync::mpsc::channel(32); 234 - let ntotal = nsenders + nforwarders + nreceivers; 235 - let senders = 0..nsenders; 236 - let forwarders = nsenders..(nsenders + nforwarders); 237 - let receivers = (nsenders + nforwarders)..ntotal; 238 - let make_handler = |i: usize| { 239 - if senders.contains(&i) { 240 - HandlerMode::Sender 241 - } else if forwarders.contains(&i) { 242 - HandlerMode::Forwarder 243 - } else { 244 - HandlerMode::Receiver(Arc::new(TestHandler::new(i, tx.clone()))) 245 - } 246 - }; 247 - let nodes = test_nodes(ntotal, make_handler, true).await?; 248 - let senders = &nodes[senders]; 249 - let forwarders = &nodes[forwarders]; 250 - let receivers = &nodes[receivers]; 251 - let stream = "teststream".to_string(); 252 - // subscribe all forwarders to a sender, round robin 253 - for (i, forwarder) in forwarders.iter().enumerate() { 254 - let sender = &senders[i % senders.len()]; 255 - forwarder 256 - .subscribe(stream.clone(), sender.public.clone()) 257 - .await?; 258 - } 259 - // subscribe all receivers to a forwarder, round robin 260 - for (i, receiver) in receivers.iter().enumerate() { 261 - let forwarder = &forwarders[i % forwarders.len()]; 262 - receiver 263 - .subscribe(stream.clone(), forwarder.public.clone()) 264 - .await?; 265 - } 266 - for _ in 0..nmsgs { 267 - for sender in senders { 268 - sender 269 - .send_segment(stream.clone(), b"segment1".to_vec()) 270 - .await?; 271 - } 272 - for _ in 0..receivers.len() { 273 - let (i, stream, _) = rx.recv().await.expect("should get data"); 274 - println!("Node {i} got data on stream {stream}"); 275 - } 276 - } 277 - Ok(()) 278 - } 279 - 280 - #[tokio::test] 281 - async fn broadcast_1_2_4() -> TestResult<()> { 282 - tracing_subscriber::fmt().try_init().ok(); 283 - broadcast(1, 2, 4, 1).await?; 284 - Ok(()) 285 - } 286 - 287 - #[tokio::test] 288 - async fn broadcast_1_3_9() -> TestResult<()> { 289 - tracing_subscriber::fmt().try_init().ok(); 290 - broadcast(1, 3, 9, 1).await?; 291 - Ok(()) 292 - } 293 - 294 - #[tokio::test] 295 - async fn broadcast_1_4_16() -> TestResult<()> { 296 - tracing_subscriber::fmt().try_init().ok(); 297 - broadcast(1, 4, 16, 100).await?; 298 - Ok(()) 299 - }
···