tangled
alpha
login
or
join now
stream.place
/
streamplace
77
fork
atom
Live video on the AT Protocol
77
fork
atom
overview
issues
1
pulls
pipelines
iroh: update to previously-integrated version
Eli Mallon
7 months ago
b383ef72
8a80a31e
+155
-246
5 changed files
expand all
collapse all
unified
split
Cargo.lock
Makefile
pkg
iroh
generated
iroh_streamplace
iroh_streamplace.go
iroh_streamplace.h
rust
iroh-streamplace
Makefile
+16
-90
Cargo.lock
···
327
version = "1.10.1"
328
source = "registry+https://github.com/rust-lang/crates.io-index"
329
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
330
-
dependencies = [
331
-
"serde",
332
-
]
333
334
[[package]]
335
name = "camino"
···
1466
]
1467
1468
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1469
name = "indexmap"
1470
version = "2.10.0"
1471
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1752
"anyhow",
1753
"async-trait",
1754
"bytes",
0
1755
"iroh",
1756
-
"irpc",
1757
-
"irpc-iroh",
1758
"n0-future 0.2.0",
1759
-
"postcard",
1760
-
"serde",
1761
"snafu",
1762
"tokio",
1763
"tracing",
···
1767
]
1768
1769
[[package]]
1770
-
name = "irpc"
1771
-
version = "0.7.0"
1772
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1773
-
checksum = "a9f8f1d0987ea9da3d74698f921d0a817a214c83b2635a33ed4bc3efa4de1acd"
1774
-
dependencies = [
1775
-
"anyhow",
1776
-
"futures-buffered",
1777
-
"futures-util",
1778
-
"iroh-quinn",
1779
-
"irpc-derive",
1780
-
"n0-future 0.1.3",
1781
-
"postcard",
1782
-
"rcgen",
1783
-
"rustls",
1784
-
"serde",
1785
-
"smallvec",
1786
-
"thiserror 2.0.14",
1787
-
"tokio",
1788
-
"tokio-util",
1789
-
"tracing",
1790
-
]
1791
-
1792
-
[[package]]
1793
-
name = "irpc-derive"
1794
-
version = "0.5.0"
1795
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1796
-
checksum = "3e0b26b834d401a046dd9d47bc236517c746eddbb5d25ff3e1a6075bfa4eebdb"
1797
-
dependencies = [
1798
-
"proc-macro2",
1799
-
"quote",
1800
-
"syn 1.0.109",
1801
-
]
1802
-
1803
-
[[package]]
1804
-
name = "irpc-iroh"
1805
-
version = "0.7.0"
1806
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1807
-
checksum = "f5926531af491c6962db4d79f43ea219404cb800889922a728b1d3b92f887eda"
1808
-
dependencies = [
1809
-
"anyhow",
1810
-
"getrandom 0.3.3",
1811
-
"iroh",
1812
-
"irpc",
1813
-
"n0-future 0.1.3",
1814
-
"postcard",
1815
-
"serde",
1816
-
"tokio",
1817
-
"tracing",
1818
-
]
1819
-
1820
-
[[package]]
1821
name = "itoa"
1822
version = "1.0.15"
1823
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2338
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
2339
2340
[[package]]
2341
-
name = "pem"
2342
-
version = "3.0.5"
2343
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2344
-
checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3"
2345
-
dependencies = [
2346
-
"base64",
2347
-
"serde",
2348
-
]
2349
-
2350
-
[[package]]
2351
name = "pem-rfc7468"
2352
version = "0.7.0"
2353
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2823
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
2824
dependencies = [
2825
"getrandom 0.3.3",
2826
-
]
2827
-
2828
-
[[package]]
2829
-
name = "rcgen"
2830
-
version = "0.13.2"
2831
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2832
-
checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2"
2833
-
dependencies = [
2834
-
"pem",
2835
-
"ring",
2836
-
"rustls-pki-types",
2837
-
"time",
2838
-
"yasna",
2839
]
2840
2841
[[package]]
···
4591
checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb"
4592
dependencies = [
4593
"xml-rs",
4594
-
]
4595
-
4596
-
[[package]]
4597
-
name = "yasna"
4598
-
version = "0.5.2"
4599
-
source = "registry+https://github.com/rust-lang/crates.io-index"
4600
-
checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd"
4601
-
dependencies = [
4602
-
"time",
4603
]
4604
4605
[[package]]
···
327
version = "1.10.1"
328
source = "registry+https://github.com/rust-lang/crates.io-index"
329
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
0
0
0
330
331
[[package]]
332
name = "camino"
···
1463
]
1464
1465
[[package]]
1466
+
name = "imsg"
1467
+
version = "0.1.0"
1468
+
source = "git+https://github.com/n0-computer/imsg?branch=main#9165b1c6d6bc27ea324a01b1090fb7f269f05dc2"
1469
+
dependencies = [
1470
+
"anyhow",
1471
+
"bytes",
1472
+
"iroh",
1473
+
"n0-future 0.2.0",
1474
+
"thiserror 2.0.14",
1475
+
"tokio",
1476
+
"tokio-util",
1477
+
"tracing",
1478
+
]
1479
+
1480
+
[[package]]
1481
name = "indexmap"
1482
version = "2.10.0"
1483
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1764
"anyhow",
1765
"async-trait",
1766
"bytes",
1767
+
"imsg",
1768
"iroh",
0
0
1769
"n0-future 0.2.0",
0
0
1770
"snafu",
1771
"tokio",
1772
"tracing",
···
1776
]
1777
1778
[[package]]
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1779
name = "itoa"
1780
version = "1.0.15"
1781
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2296
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
2297
2298
[[package]]
0
0
0
0
0
0
0
0
0
0
2299
name = "pem-rfc7468"
2300
version = "0.7.0"
2301
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2771
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
2772
dependencies = [
2773
"getrandom 0.3.3",
0
0
0
0
0
0
0
0
0
0
0
0
0
2774
]
2775
2776
[[package]]
···
4526
checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb"
4527
dependencies = [
4528
"xml-rs",
0
0
0
0
0
0
0
0
0
4529
]
4530
4531
[[package]]
+4
Makefile
···
837
&& git add . \
838
&& git commit -m "Update streamplace $(VERSION)" \
839
&& git push
0
0
0
0
···
837
&& git add . \
838
&& git commit -m "Update streamplace $(VERSION)" \
839
&& git push
840
+
841
+
.PHONY: iroh-streamplace
842
+
iroh-streamplace:
843
+
uniffi-bindgen-go --out-dir pkg/iroh/generated --library ./target/debug/libiroh_streamplace.so
+121
-114
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.go
···
353
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
354
return C.uniffi_iroh_streamplace_checksum_method_datahandler_handle_data()
355
})
356
-
if checksum != 27893 {
357
// If this happens try cleaning and rebuilding your project
358
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_datahandler_handle_data: UniFFI API checksum mismatch")
359
}
···
441
}
442
{
443
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
444
-
return C.uniffi_iroh_streamplace_checksum_method_receiver_subscribe()
445
})
446
-
if checksum != 24145 {
447
-
// If this happens try cleaning and rebuilding your project
448
-
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_receiver_subscribe: UniFFI API checksum mismatch")
449
-
}
450
-
}
451
-
{
452
-
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
453
-
return C.uniffi_iroh_streamplace_checksum_method_receiver_unsubscribe()
454
-
})
455
-
if checksum != 21760 {
456
// If this happens try cleaning and rebuilding your project
457
-
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_receiver_unsubscribe: UniFFI API checksum mismatch")
458
}
459
}
460
{
···
470
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
471
return C.uniffi_iroh_streamplace_checksum_method_sender_send()
472
})
473
-
if checksum != 23930 {
474
// If this happens try cleaning and rebuilding your project
475
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_sender_send: UniFFI API checksum mismatch")
476
}
···
720
}
721
722
type DataHandler interface {
723
-
HandleData(topic string, data []byte)
724
}
725
type DataHandlerImpl struct {
726
ffiObject FfiObject
727
}
728
729
-
func (_self *DataHandlerImpl) HandleData(topic string, data []byte) {
730
_pointer := _self.ffiObject.incrementPointer("DataHandler")
731
defer _self.ffiObject.decrementPointer()
732
uniffiRustCallAsync[struct{}](
···
739
// liftFn
740
func(_ struct{}) struct{} { return struct{}{} },
741
C.uniffi_iroh_streamplace_fn_method_datahandler_handle_data(
742
-
_pointer, FfiConverterStringINSTANCE.Lower(topic), FfiConverterBytesINSTANCE.Lower(data)),
743
// pollFn
744
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
745
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
···
854
}
855
856
//export iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0
857
-
func iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uniffiHandle C.uint64_t, topic C.RustBuffer, data C.RustBuffer, uniffiFutureCallback C.UniffiForeignFutureCompleteVoid, uniffiCallbackData C.uint64_t, uniffiOutReturn *C.UniffiForeignFuture) {
858
handle := uint64(uniffiHandle)
859
uniffiObj, ok := FfiConverterDataHandlerINSTANCE.handleMap.tryGet(handle)
860
if !ok {
···
886
}()
887
888
uniffiObj.HandleData(
889
-
FfiConverterStringINSTANCE.Lift(GoRustBuffer{
890
-
inner: topic,
891
-
}),
892
FfiConverterBytesINSTANCE.Lift(GoRustBuffer{
893
inner: data,
894
}),
···
1282
1283
type ReceiverInterface interface {
1284
NodeAddr() *NodeAddr
1285
-
// Subscribe to the given topic on the remote.
1286
-
Subscribe(remoteId *PublicKey, topic string) *Error
1287
-
// Unsubscribe from this topic on the remote.
1288
-
Unsubscribe(remoteId *PublicKey, topic string) *Error
1289
}
1290
type Receiver struct {
1291
ffiObject FfiObject
···
1346
1347
return res
1348
}
1349
-
1350
-
// Subscribe to the given topic on the remote.
1351
-
func (_self *Receiver) Subscribe(remoteId *PublicKey, topic string) *Error {
1352
-
_pointer := _self.ffiObject.incrementPointer("*Receiver")
1353
-
defer _self.ffiObject.decrementPointer()
1354
-
_, err := uniffiRustCallAsync[Error](
1355
-
FfiConverterErrorINSTANCE,
1356
-
// completeFn
1357
-
func(handle C.uint64_t, status *C.RustCallStatus) struct{} {
1358
-
C.ffi_iroh_streamplace_rust_future_complete_void(handle, status)
1359
-
return struct{}{}
1360
-
},
1361
-
// liftFn
1362
-
func(_ struct{}) struct{} { return struct{}{} },
1363
-
C.uniffi_iroh_streamplace_fn_method_receiver_subscribe(
1364
-
_pointer, FfiConverterPublicKeyINSTANCE.Lower(remoteId), FfiConverterStringINSTANCE.Lower(topic)),
1365
-
// pollFn
1366
-
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
1367
-
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
1368
-
},
1369
-
// freeFn
1370
-
func(handle C.uint64_t) {
1371
-
C.ffi_iroh_streamplace_rust_future_free_void(handle)
1372
-
},
1373
-
)
1374
-
1375
-
return err
1376
-
}
1377
-
1378
-
// Unsubscribe from this topic on the remote.
1379
-
func (_self *Receiver) Unsubscribe(remoteId *PublicKey, topic string) *Error {
1380
-
_pointer := _self.ffiObject.incrementPointer("*Receiver")
1381
-
defer _self.ffiObject.decrementPointer()
1382
-
_, err := uniffiRustCallAsync[Error](
1383
-
FfiConverterErrorINSTANCE,
1384
-
// completeFn
1385
-
func(handle C.uint64_t, status *C.RustCallStatus) struct{} {
1386
-
C.ffi_iroh_streamplace_rust_future_complete_void(handle, status)
1387
-
return struct{}{}
1388
-
},
1389
-
// liftFn
1390
-
func(_ struct{}) struct{} { return struct{}{} },
1391
-
C.uniffi_iroh_streamplace_fn_method_receiver_unsubscribe(
1392
-
_pointer, FfiConverterPublicKeyINSTANCE.Lower(remoteId), FfiConverterStringINSTANCE.Lower(topic)),
1393
-
// pollFn
1394
-
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
1395
-
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
1396
-
},
1397
-
// freeFn
1398
-
func(handle C.uint64_t) {
1399
-
C.ffi_iroh_streamplace_rust_future_free_void(handle)
1400
-
},
1401
-
)
1402
-
1403
-
return err
1404
-
}
1405
func (object *Receiver) Destroy() {
1406
runtime.SetFinalizer(object, nil)
1407
object.ffiObject.destroy()
···
1452
}
1453
1454
type SenderInterface interface {
0
1455
NodeAddr() *NodeAddr
1456
-
// Sends the given data to all subscribers that have subscribed to this `key`.
1457
-
Send(key string, data []byte) *Error
1458
}
1459
type Sender struct {
1460
ffiObject FfiObject
···
1487
return res, err
1488
}
1489
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1490
func (_self *Sender) NodeAddr() *NodeAddr {
1491
_pointer := _self.ffiObject.incrementPointer("*Sender")
1492
defer _self.ffiObject.decrementPointer()
···
1516
return res
1517
}
1518
1519
-
// Sends the given data to all subscribers that have subscribed to this `key`.
1520
-
func (_self *Sender) Send(key string, data []byte) *Error {
1521
_pointer := _self.ffiObject.incrementPointer("*Sender")
1522
defer _self.ffiObject.decrementPointer()
1523
_, err := uniffiRustCallAsync[Error](
···
1530
// liftFn
1531
func(_ struct{}) struct{} { return struct{}{} },
1532
C.uniffi_iroh_streamplace_fn_method_sender_send(
1533
-
_pointer, FfiConverterStringINSTANCE.Lower(key), FfiConverterBytesINSTANCE.Lower(data)),
1534
// pollFn
1535
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
1536
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
···
1620
var ErrErrorInvalidUrl = fmt.Errorf("ErrorInvalidUrl")
1621
var ErrErrorIrohConnect = fmt.Errorf("ErrorIrohConnect")
1622
var ErrErrorInvalidNetworkAddress = fmt.Errorf("ErrorInvalidNetworkAddress")
0
0
0
1623
var ErrErrorMissingConnection = fmt.Errorf("ErrorMissingConnection")
1624
var ErrErrorInvalidPublicKey = fmt.Errorf("ErrorInvalidPublicKey")
1625
-
var ErrErrorIrpc = fmt.Errorf("ErrorIrpc")
1626
1627
// Variant structs
1628
type ErrorIrohBind struct {
···
1701
return target == ErrErrorInvalidNetworkAddress
1702
}
1703
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1704
type ErrorMissingConnection struct {
1705
message string
1706
}
···
1739
return target == ErrErrorInvalidPublicKey
1740
}
1741
1742
-
type ErrorIrpc struct {
1743
-
message string
1744
-
}
1745
-
1746
-
func NewErrorIrpc() *Error {
1747
-
return &Error{err: &ErrorIrpc{}}
1748
-
}
1749
-
1750
-
func (e ErrorIrpc) destroy() {
1751
-
}
1752
-
1753
-
func (err ErrorIrpc) Error() string {
1754
-
return fmt.Sprintf("Irpc: %s", err.message)
1755
-
}
1756
-
1757
-
func (self ErrorIrpc) Is(target error) bool {
1758
-
return target == ErrErrorIrpc
1759
-
}
1760
-
1761
type FfiConverterError struct{}
1762
1763
var FfiConverterErrorINSTANCE = FfiConverterError{}
···
1784
case 4:
1785
return &Error{&ErrorInvalidNetworkAddress{message}}
1786
case 5:
0
0
0
0
0
0
1787
return &Error{&ErrorMissingConnection{message}}
1788
-
case 6:
1789
return &Error{&ErrorInvalidPublicKey{message}}
1790
-
case 7:
1791
-
return &Error{&ErrorIrpc{message}}
1792
default:
1793
panic(fmt.Sprintf("Unknown error code %d in FfiConverterError.Read()", errorID))
1794
}
···
1805
writeInt32(writer, 3)
1806
case *ErrorInvalidNetworkAddress:
1807
writeInt32(writer, 4)
1808
-
case *ErrorMissingConnection:
1809
writeInt32(writer, 5)
1810
-
case *ErrorInvalidPublicKey:
1811
writeInt32(writer, 6)
1812
-
case *ErrorIrpc:
1813
writeInt32(writer, 7)
0
0
0
0
1814
default:
1815
_ = variantValue
1816
panic(fmt.Sprintf("invalid error value `%v` in FfiConverterError.Write", value))
···
1829
variantValue.destroy()
1830
case ErrorInvalidNetworkAddress:
1831
variantValue.destroy()
0
0
0
0
0
0
1832
case ErrorMissingConnection:
1833
variantValue.destroy()
1834
case ErrorInvalidPublicKey:
1835
-
variantValue.destroy()
1836
-
case ErrorIrpc:
1837
variantValue.destroy()
1838
default:
1839
_ = variantValue
···
353
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
354
return C.uniffi_iroh_streamplace_checksum_method_datahandler_handle_data()
355
})
356
+
if checksum != 61779 {
357
// If this happens try cleaning and rebuilding your project
358
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_datahandler_handle_data: UniFFI API checksum mismatch")
359
}
···
441
}
442
{
443
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
444
+
return C.uniffi_iroh_streamplace_checksum_method_sender_add_peer()
445
})
446
+
if checksum != 34321 {
0
0
0
0
0
0
0
0
0
447
// If this happens try cleaning and rebuilding your project
448
+
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_sender_add_peer: UniFFI API checksum mismatch")
449
}
450
}
451
{
···
461
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
462
return C.uniffi_iroh_streamplace_checksum_method_sender_send()
463
})
464
+
if checksum != 24369 {
465
// If this happens try cleaning and rebuilding your project
466
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_method_sender_send: UniFFI API checksum mismatch")
467
}
···
711
}
712
713
type DataHandler interface {
714
+
HandleData(peer *PublicKey, data []byte)
715
}
716
type DataHandlerImpl struct {
717
ffiObject FfiObject
718
}
719
720
+
func (_self *DataHandlerImpl) HandleData(peer *PublicKey, data []byte) {
721
_pointer := _self.ffiObject.incrementPointer("DataHandler")
722
defer _self.ffiObject.decrementPointer()
723
uniffiRustCallAsync[struct{}](
···
730
// liftFn
731
func(_ struct{}) struct{} { return struct{}{} },
732
C.uniffi_iroh_streamplace_fn_method_datahandler_handle_data(
733
+
_pointer, FfiConverterPublicKeyINSTANCE.Lower(peer), FfiConverterBytesINSTANCE.Lower(data)),
734
// pollFn
735
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
736
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
···
845
}
846
847
//export iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0
848
+
func iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uniffiHandle C.uint64_t, peer unsafe.Pointer, data C.RustBuffer, uniffiFutureCallback C.UniffiForeignFutureCompleteVoid, uniffiCallbackData C.uint64_t, uniffiOutReturn *C.UniffiForeignFuture) {
849
handle := uint64(uniffiHandle)
850
uniffiObj, ok := FfiConverterDataHandlerINSTANCE.handleMap.tryGet(handle)
851
if !ok {
···
877
}()
878
879
uniffiObj.HandleData(
880
+
FfiConverterPublicKeyINSTANCE.Lift(peer),
0
0
881
FfiConverterBytesINSTANCE.Lift(GoRustBuffer{
882
inner: data,
883
}),
···
1271
1272
type ReceiverInterface interface {
1273
NodeAddr() *NodeAddr
0
0
0
0
1274
}
1275
type Receiver struct {
1276
ffiObject FfiObject
···
1331
1332
return res
1333
}
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1334
func (object *Receiver) Destroy() {
1335
runtime.SetFinalizer(object, nil)
1336
object.ffiObject.destroy()
···
1381
}
1382
1383
type SenderInterface interface {
1384
+
AddPeer(addr *NodeAddr) *Error
1385
NodeAddr() *NodeAddr
1386
+
Send(nodeId *PublicKey, data []byte) *Error
0
1387
}
1388
type Sender struct {
1389
ffiObject FfiObject
···
1416
return res, err
1417
}
1418
1419
+
func (_self *Sender) AddPeer(addr *NodeAddr) *Error {
1420
+
_pointer := _self.ffiObject.incrementPointer("*Sender")
1421
+
defer _self.ffiObject.decrementPointer()
1422
+
_, err := uniffiRustCallAsync[Error](
1423
+
FfiConverterErrorINSTANCE,
1424
+
// completeFn
1425
+
func(handle C.uint64_t, status *C.RustCallStatus) struct{} {
1426
+
C.ffi_iroh_streamplace_rust_future_complete_void(handle, status)
1427
+
return struct{}{}
1428
+
},
1429
+
// liftFn
1430
+
func(_ struct{}) struct{} { return struct{}{} },
1431
+
C.uniffi_iroh_streamplace_fn_method_sender_add_peer(
1432
+
_pointer, FfiConverterNodeAddrINSTANCE.Lower(addr)),
1433
+
// pollFn
1434
+
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
1435
+
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
1436
+
},
1437
+
// freeFn
1438
+
func(handle C.uint64_t) {
1439
+
C.ffi_iroh_streamplace_rust_future_free_void(handle)
1440
+
},
1441
+
)
1442
+
1443
+
return err
1444
+
}
1445
+
1446
func (_self *Sender) NodeAddr() *NodeAddr {
1447
_pointer := _self.ffiObject.incrementPointer("*Sender")
1448
defer _self.ffiObject.decrementPointer()
···
1472
return res
1473
}
1474
1475
+
func (_self *Sender) Send(nodeId *PublicKey, data []byte) *Error {
0
1476
_pointer := _self.ffiObject.incrementPointer("*Sender")
1477
defer _self.ffiObject.decrementPointer()
1478
_, err := uniffiRustCallAsync[Error](
···
1485
// liftFn
1486
func(_ struct{}) struct{} { return struct{}{} },
1487
C.uniffi_iroh_streamplace_fn_method_sender_send(
1488
+
_pointer, FfiConverterPublicKeyINSTANCE.Lower(nodeId), FfiConverterBytesINSTANCE.Lower(data)),
1489
// pollFn
1490
func(handle C.uint64_t, continuation C.UniffiRustFutureContinuationCallback, data C.uint64_t) {
1491
C.ffi_iroh_streamplace_rust_future_poll_void(handle, continuation, data)
···
1575
var ErrErrorInvalidUrl = fmt.Errorf("ErrorInvalidUrl")
1576
var ErrErrorIrohConnect = fmt.Errorf("ErrorIrohConnect")
1577
var ErrErrorInvalidNetworkAddress = fmt.Errorf("ErrorInvalidNetworkAddress")
1578
+
var ErrErrorOpenStream = fmt.Errorf("ErrorOpenStream")
1579
+
var ErrErrorSendMessage = fmt.Errorf("ErrorSendMessage")
1580
+
var ErrErrorNewConnection = fmt.Errorf("ErrorNewConnection")
1581
var ErrErrorMissingConnection = fmt.Errorf("ErrorMissingConnection")
1582
var ErrErrorInvalidPublicKey = fmt.Errorf("ErrorInvalidPublicKey")
0
1583
1584
// Variant structs
1585
type ErrorIrohBind struct {
···
1658
return target == ErrErrorInvalidNetworkAddress
1659
}
1660
1661
+
type ErrorOpenStream struct {
1662
+
message string
1663
+
}
1664
+
1665
+
func NewErrorOpenStream() *Error {
1666
+
return &Error{err: &ErrorOpenStream{}}
1667
+
}
1668
+
1669
+
func (e ErrorOpenStream) destroy() {
1670
+
}
1671
+
1672
+
func (err ErrorOpenStream) Error() string {
1673
+
return fmt.Sprintf("OpenStream: %s", err.message)
1674
+
}
1675
+
1676
+
func (self ErrorOpenStream) Is(target error) bool {
1677
+
return target == ErrErrorOpenStream
1678
+
}
1679
+
1680
+
type ErrorSendMessage struct {
1681
+
message string
1682
+
}
1683
+
1684
+
func NewErrorSendMessage() *Error {
1685
+
return &Error{err: &ErrorSendMessage{}}
1686
+
}
1687
+
1688
+
func (e ErrorSendMessage) destroy() {
1689
+
}
1690
+
1691
+
func (err ErrorSendMessage) Error() string {
1692
+
return fmt.Sprintf("SendMessage: %s", err.message)
1693
+
}
1694
+
1695
+
func (self ErrorSendMessage) Is(target error) bool {
1696
+
return target == ErrErrorSendMessage
1697
+
}
1698
+
1699
+
type ErrorNewConnection struct {
1700
+
message string
1701
+
}
1702
+
1703
+
func NewErrorNewConnection() *Error {
1704
+
return &Error{err: &ErrorNewConnection{}}
1705
+
}
1706
+
1707
+
func (e ErrorNewConnection) destroy() {
1708
+
}
1709
+
1710
+
func (err ErrorNewConnection) Error() string {
1711
+
return fmt.Sprintf("NewConnection: %s", err.message)
1712
+
}
1713
+
1714
+
func (self ErrorNewConnection) Is(target error) bool {
1715
+
return target == ErrErrorNewConnection
1716
+
}
1717
+
1718
type ErrorMissingConnection struct {
1719
message string
1720
}
···
1753
return target == ErrErrorInvalidPublicKey
1754
}
1755
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1756
type FfiConverterError struct{}
1757
1758
var FfiConverterErrorINSTANCE = FfiConverterError{}
···
1779
case 4:
1780
return &Error{&ErrorInvalidNetworkAddress{message}}
1781
case 5:
1782
+
return &Error{&ErrorOpenStream{message}}
1783
+
case 6:
1784
+
return &Error{&ErrorSendMessage{message}}
1785
+
case 7:
1786
+
return &Error{&ErrorNewConnection{message}}
1787
+
case 8:
1788
return &Error{&ErrorMissingConnection{message}}
1789
+
case 9:
1790
return &Error{&ErrorInvalidPublicKey{message}}
0
0
1791
default:
1792
panic(fmt.Sprintf("Unknown error code %d in FfiConverterError.Read()", errorID))
1793
}
···
1804
writeInt32(writer, 3)
1805
case *ErrorInvalidNetworkAddress:
1806
writeInt32(writer, 4)
1807
+
case *ErrorOpenStream:
1808
writeInt32(writer, 5)
1809
+
case *ErrorSendMessage:
1810
writeInt32(writer, 6)
1811
+
case *ErrorNewConnection:
1812
writeInt32(writer, 7)
1813
+
case *ErrorMissingConnection:
1814
+
writeInt32(writer, 8)
1815
+
case *ErrorInvalidPublicKey:
1816
+
writeInt32(writer, 9)
1817
default:
1818
_ = variantValue
1819
panic(fmt.Sprintf("invalid error value `%v` in FfiConverterError.Write", value))
···
1832
variantValue.destroy()
1833
case ErrorInvalidNetworkAddress:
1834
variantValue.destroy()
1835
+
case ErrorOpenStream:
1836
+
variantValue.destroy()
1837
+
case ErrorSendMessage:
1838
+
variantValue.destroy()
1839
+
case ErrorNewConnection:
1840
+
variantValue.destroy()
1841
case ErrorMissingConnection:
1842
variantValue.destroy()
1843
case ErrorInvalidPublicKey:
0
0
1844
variantValue.destroy()
1845
default:
1846
_ = variantValue
+14
-25
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.h
···
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, 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, RustBuffer topic, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return)
389
{
390
-
return cb(uniffi_handle, topic, data, uniffi_future_callback, uniffi_callback_data, uniffi_out_return);
391
}
392
393
···
417
#endif
418
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA
419
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA
420
-
uint64_t uniffi_iroh_streamplace_fn_method_datahandler_handle_data(void* ptr, RustBuffer topic, RustBuffer data
421
);
422
#endif
423
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_ENDPOINT
···
536
uint64_t uniffi_iroh_streamplace_fn_method_receiver_node_addr(void* ptr
537
);
538
#endif
539
-
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_RECEIVER_SUBSCRIBE
540
-
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_RECEIVER_SUBSCRIBE
541
-
uint64_t uniffi_iroh_streamplace_fn_method_receiver_subscribe(void* ptr, void* remote_id, RustBuffer topic
542
-
);
543
-
#endif
544
-
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_RECEIVER_UNSUBSCRIBE
545
-
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_RECEIVER_UNSUBSCRIBE
546
-
uint64_t uniffi_iroh_streamplace_fn_method_receiver_unsubscribe(void* ptr, void* remote_id, RustBuffer topic
547
-
);
548
-
#endif
549
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SENDER
550
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SENDER
551
void* uniffi_iroh_streamplace_fn_clone_sender(void* ptr, RustCallStatus *out_status
···
561
uint64_t uniffi_iroh_streamplace_fn_constructor_sender_new(void* endpoint
562
);
563
#endif
0
0
0
0
0
564
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_NODE_ADDR
565
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_NODE_ADDR
566
uint64_t uniffi_iroh_streamplace_fn_method_sender_node_addr(void* ptr
···
568
#endif
569
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_SEND
570
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_SEND
571
-
uint64_t uniffi_iroh_streamplace_fn_method_sender_send(void* ptr, RustBuffer key, RustBuffer data
572
);
573
#endif
574
#ifndef UNIFFI_FFIDEF_FFI_IROH_STREAMPLACE_RUSTBUFFER_ALLOC
···
911
912
);
913
#endif
914
-
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_RECEIVER_SUBSCRIBE
915
-
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_RECEIVER_SUBSCRIBE
916
-
uint16_t uniffi_iroh_streamplace_checksum_method_receiver_subscribe(void
917
-
918
-
);
919
-
#endif
920
-
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_RECEIVER_UNSUBSCRIBE
921
-
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_RECEIVER_UNSUBSCRIBE
922
-
uint16_t uniffi_iroh_streamplace_checksum_method_receiver_unsubscribe(void
923
924
);
925
#endif
···
978
);
979
#endif
980
981
-
void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uint64_t uniffi_handle, RustBuffer topic, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return);
982
void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree(uint64_t handle);
983
984
void iroh_streamplace_uniffiFutureContinuationCallback(uint64_t, int8_t);
···
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* peer, 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* peer, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return)
389
{
390
+
return cb(uniffi_handle, peer, data, uniffi_future_callback, uniffi_callback_data, uniffi_out_return);
391
}
392
393
···
417
#endif
418
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA
419
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_DATAHANDLER_HANDLE_DATA
420
+
uint64_t uniffi_iroh_streamplace_fn_method_datahandler_handle_data(void* ptr, void* peer, RustBuffer data
421
);
422
#endif
423
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_ENDPOINT
···
536
uint64_t uniffi_iroh_streamplace_fn_method_receiver_node_addr(void* ptr
537
);
538
#endif
0
0
0
0
0
0
0
0
0
0
539
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SENDER
540
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_CLONE_SENDER
541
void* uniffi_iroh_streamplace_fn_clone_sender(void* ptr, RustCallStatus *out_status
···
551
uint64_t uniffi_iroh_streamplace_fn_constructor_sender_new(void* endpoint
552
);
553
#endif
554
+
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_ADD_PEER
555
+
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_ADD_PEER
556
+
uint64_t uniffi_iroh_streamplace_fn_method_sender_add_peer(void* ptr, void* addr
557
+
);
558
+
#endif
559
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_NODE_ADDR
560
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_NODE_ADDR
561
uint64_t uniffi_iroh_streamplace_fn_method_sender_node_addr(void* ptr
···
563
#endif
564
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_SEND
565
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_METHOD_SENDER_SEND
566
+
uint64_t uniffi_iroh_streamplace_fn_method_sender_send(void* ptr, void* node_id, RustBuffer data
567
);
568
#endif
569
#ifndef UNIFFI_FFIDEF_FFI_IROH_STREAMPLACE_RUSTBUFFER_ALLOC
···
906
907
);
908
#endif
909
+
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SENDER_ADD_PEER
910
+
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_CHECKSUM_METHOD_SENDER_ADD_PEER
911
+
uint16_t uniffi_iroh_streamplace_checksum_method_sender_add_peer(void
0
0
0
0
0
0
912
913
);
914
#endif
···
967
);
968
#endif
969
970
+
void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerMethod0(uint64_t uniffi_handle, void* peer, RustBuffer data, UniffiForeignFutureCompleteVoid uniffi_future_callback, uint64_t uniffi_callback_data, UniffiForeignFuture* uniffi_out_return);
971
void iroh_streamplace_cgo_dispatchCallbackInterfaceDataHandlerFree(uint64_t handle);
972
973
void iroh_streamplace_uniffiFutureContinuationCallback(uint64_t, int8_t);
-17
rust/iroh-streamplace/Makefile
···
1
-
.PHONY: all
2
-
all: rust go
3
-
4
-
.PHONY: rust
5
-
rust:
6
-
cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.3.0+v0.28.3
7
-
cargo build --release
8
-
9
-
.PHONY: go
10
-
go:
11
-
mkdir -p dist
12
-
uniffi-bindgen-go --out-dir ../../pkg/iroh/generated --library ./target/release/libiroh_streamplace.dylib
13
-
14
-
.PHONY: test
15
-
test:
16
-
cargo test
17
-
go test ./pkg/...
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0