@minip2p/react-native 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/android/CMakeLists.txt +1 -0
  2. package/android/src/main/jniLibs/arm64-v8a/libminip2p_ffi.so +0 -0
  3. package/android/src/main/jniLibs/x86_64/libminip2p_ffi.so +0 -0
  4. package/build/Minip2pFfi.xcframework/Info.plist +4 -4
  5. package/build/Minip2pFfi.xcframework/ios-arm64/libminip2p_ffi.a +2 -2
  6. package/build/Minip2pFfi.xcframework/ios-arm64-simulator/libminip2p_ffi.a +2 -2
  7. package/cpp/generated/minip2p_ffi_core.cpp +1999 -0
  8. package/cpp/generated/minip2p_ffi_core.hpp +51 -0
  9. package/cpp/react-native-minip2p.cpp +2 -0
  10. package/lib/module/adapter.js +64 -61
  11. package/lib/module/adapter.js.map +1 -1
  12. package/lib/module/generated/minip2p_ffi.js +47 -3284
  13. package/lib/module/generated/minip2p_ffi.js.map +1 -1
  14. package/lib/module/generated/minip2p_ffi_core-ffi.js +20 -0
  15. package/lib/module/generated/minip2p_ffi_core-ffi.js.map +1 -0
  16. package/lib/module/generated/minip2p_ffi_core.js +3342 -0
  17. package/lib/module/generated/minip2p_ffi_core.js.map +1 -0
  18. package/lib/module/low-level.js +1 -0
  19. package/lib/module/low-level.js.map +1 -1
  20. package/lib/module/native.js +5 -1
  21. package/lib/module/native.js.map +1 -1
  22. package/lib/typescript/src/adapter.d.ts.map +1 -1
  23. package/lib/typescript/src/generated/minip2p_ffi.d.ts +2 -3394
  24. package/lib/typescript/src/generated/minip2p_ffi.d.ts.map +1 -1
  25. package/lib/typescript/src/generated/minip2p_ffi_core-ffi.d.ts +67 -0
  26. package/lib/typescript/src/generated/minip2p_ffi_core-ffi.d.ts.map +1 -0
  27. package/lib/typescript/src/generated/minip2p_ffi_core.d.ts +3417 -0
  28. package/lib/typescript/src/generated/minip2p_ffi_core.d.ts.map +1 -0
  29. package/lib/typescript/src/low-level.d.ts +1 -0
  30. package/lib/typescript/src/low-level.d.ts.map +1 -1
  31. package/lib/typescript/src/native.d.ts +3 -0
  32. package/lib/typescript/src/native.d.ts.map +1 -1
  33. package/package.json +4 -4
  34. package/src/adapter.ts +85 -67
  35. package/src/generated/minip2p_ffi.ts +36 -3860
  36. package/src/generated/minip2p_ffi_core-ffi.ts +97 -0
  37. package/src/generated/minip2p_ffi_core.ts +3939 -0
  38. package/src/low-level.ts +1 -0
  39. package/src/native.tsx +4 -0
  40. package/lib/module/event-drain.js +0 -71
  41. package/lib/module/event-drain.js.map +0 -1
  42. package/lib/typescript/src/event-drain.d.ts +0 -10
  43. package/lib/typescript/src/event-drain.d.ts.map +0 -1
  44. package/src/event-drain.ts +0 -80
@@ -0,0 +1,3342 @@
1
+ "use strict";
2
+
3
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
4
+ // Trust me, you don't want to mess with it!
5
+ /* tslint:disable */
6
+ /* eslint-disable */
7
+ // @ts-nocheck
8
+ import nativeModule from "./minip2p_ffi_core-ffi.js";
9
+ import { AbstractFfiConverterByteArray, FfiConverterArray, FfiConverterArrayBuffer, FfiConverterBool, FfiConverterOptional, FfiConverterUInt32, FfiConverterUInt64, UniffiEnum, UniffiError, UniffiInternalError, UniffiRustCaller, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiTypeNameSymbol } from "@ubjs/core";
10
+ const uniffiCaller = new UniffiRustCaller(() => ({
11
+ code: 0
12
+ }));
13
+ const uniffiIsDebug =
14
+ // @ts-ignore -- The process global might not be defined
15
+ typeof process !== "object" ||
16
+ // @ts-ignore -- The process global might not be defined
17
+ process?.env?.NODE_ENV !== "production" || false;
18
+
19
+ // Public interface members begin here.
20
+
21
+ // Hermes (React Native ≥ 0.74) ships TextEncoder and encodeInto, but not
22
+ // TextDecoder. For single-string decode (bytesToString), we polyfill via the
23
+ // C++ string_from_buffer helper using a duck-typed object matching the
24
+ // standard TextDecoder.decode signature. Once Hermes ships a real
25
+ // TextDecoder, the `typeof` check will pick it up automatically.
26
+ //
27
+ // For array-of-strings decode (readStringFromBuffer), we keep a dedicated C++
28
+ // helper: the polyfill path (new Uint8Array view + decode) measured ~40%
29
+ // slower on getStringArray benchmarks than a direct (buf, offset, length)
30
+ // call, due to the per-read view allocation and extra property lookups in
31
+ // string_from_buffer.
32
+ const stringConverter = (() => {
33
+ const encoder = new TextEncoder();
34
+ const decoder = typeof TextDecoder !== "undefined" ? new TextDecoder() : {
35
+ decode: bytes => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_from_buffer(bytes, undefined)
36
+ };
37
+ return {
38
+ // Single-string lower() uses the C++ helper — TextEncoder.encode
39
+ // measured ~43% slower on takeString benchmarks.
40
+ stringToBytes: s => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_buffer(s, undefined),
41
+ bytesToString: ab => decoder.decode(ab),
42
+ // Direct C++ call — bypasses uniffiCaller.rustCall() overhead.
43
+ // Matters for N-element arrays.
44
+ stringByteLength: s => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(s, undefined),
45
+ // Encode directly into the RustBuffer backing store via
46
+ // TextEncoder.encodeInto — zero intermediate allocation. Replaces
47
+ // the old C++ write_string_into_buffer helper.
48
+ writeStringIntoBuffer: (s, buf, offset) => {
49
+ const view = new Uint8Array(buf.arrayBuffer, offset, buf.arrayBuffer.byteLength - offset);
50
+ return encoder.encodeInto(s, view).written;
51
+ },
52
+ // Dedicated C++ helper — avoids per-read Uint8Array allocation and
53
+ // the double property-lookup in string_from_buffer.
54
+ readStringFromBuffer: (buf, offset, length) => nativeModule().ubrn_uniffi_internal_fn_func_ffi__read_string_from_buffer(buf, offset, length)
55
+ };
56
+ })();
57
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
58
+
59
+ /**
60
+ * State snapshot of the transport connection selected for a peer.
61
+ */
62
+
63
+ /**
64
+ * Generated factory for {@link ConnectionInfo} record objects.
65
+ */
66
+ export const ConnectionInfo = (() => {
67
+ const defaults = () => ({});
68
+ const create = (() => {
69
+ return uniffiCreateRecord(defaults);
70
+ })();
71
+ return Object.freeze({
72
+ create,
73
+ new: create,
74
+ defaults: () => Object.freeze(defaults())
75
+ });
76
+ })();
77
+ const FfiConverterTypeConnectionInfo = (() => {
78
+ class FFIConverter extends AbstractFfiConverterByteArray {
79
+ readFromCursor(c) {
80
+ return {
81
+ connId: FfiConverterUInt64.readFromCursor(c),
82
+ remoteAddr: FfiConverterOptionalString.readFromCursor(c),
83
+ readyProtocols: FfiConverterOptionalSequenceString.readFromCursor(c)
84
+ };
85
+ }
86
+ writeIntoCursor(value, c) {
87
+ FfiConverterUInt64.writeIntoCursor(value.connId, c);
88
+ FfiConverterOptionalString.writeIntoCursor(value.remoteAddr, c);
89
+ FfiConverterOptionalSequenceString.writeIntoCursor(value.readyProtocols, c);
90
+ }
91
+ allocationSize(value) {
92
+ return FfiConverterUInt64.allocationSize(value.connId) + FfiConverterOptionalString.allocationSize(value.remoteAddr) + FfiConverterOptionalSequenceString.allocationSize(value.readyProtocols);
93
+ }
94
+ }
95
+ ;
96
+ return new FFIConverter();
97
+ })();
98
+
99
+ /**
100
+ * Signed-discovery configuration.
101
+ */
102
+
103
+ /**
104
+ * Generated factory for {@link DiscoveryOptions} record objects.
105
+ */
106
+ export const DiscoveryOptions = (() => {
107
+ const defaults = () => ({});
108
+ const create = (() => {
109
+ return uniffiCreateRecord(defaults);
110
+ })();
111
+ return Object.freeze({
112
+ create,
113
+ new: create,
114
+ defaults: () => Object.freeze(defaults())
115
+ });
116
+ })();
117
+ const FfiConverterTypeDiscoveryOptions = (() => {
118
+ class FFIConverter extends AbstractFfiConverterByteArray {
119
+ readFromCursor(c) {
120
+ return {
121
+ topic: FfiConverterString.readFromCursor(c),
122
+ beaconIntervalMs: FfiConverterUInt64.readFromCursor(c),
123
+ peerTtlMs: FfiConverterUInt64.readFromCursor(c),
124
+ autoDial: FfiConverterBool.readFromCursor(c)
125
+ };
126
+ }
127
+ writeIntoCursor(value, c) {
128
+ FfiConverterString.writeIntoCursor(value.topic, c);
129
+ FfiConverterUInt64.writeIntoCursor(value.beaconIntervalMs, c);
130
+ FfiConverterUInt64.writeIntoCursor(value.peerTtlMs, c);
131
+ FfiConverterBool.writeIntoCursor(value.autoDial, c);
132
+ }
133
+ allocationSize(value) {
134
+ return FfiConverterString.allocationSize(value.topic) + FfiConverterUInt64.allocationSize(value.beaconIntervalMs) + FfiConverterUInt64.allocationSize(value.peerTtlMs) + FfiConverterBool.allocationSize(value.autoDial);
135
+ }
136
+ }
137
+ ;
138
+ return new FFIConverter();
139
+ })();
140
+
141
+ /**
142
+ * Local-link mDNS discovery configuration.
143
+ */
144
+
145
+ /**
146
+ * Generated factory for {@link MdnsOptions} record objects.
147
+ */
148
+ export const MdnsOptions = (() => {
149
+ const defaults = () => ({});
150
+ const create = (() => {
151
+ return uniffiCreateRecord(defaults);
152
+ })();
153
+ return Object.freeze({
154
+ create,
155
+ new: create,
156
+ defaults: () => Object.freeze(defaults())
157
+ });
158
+ })();
159
+ const FfiConverterTypeMdnsOptions = (() => {
160
+ class FFIConverter extends AbstractFfiConverterByteArray {
161
+ readFromCursor(c) {
162
+ return {
163
+ enableIpv6: FfiConverterBool.readFromCursor(c),
164
+ ttlMs: FfiConverterUInt64.readFromCursor(c),
165
+ queryIntervalMs: FfiConverterUInt64.readFromCursor(c),
166
+ maxPacketBytes: FfiConverterUInt32.readFromCursor(c),
167
+ maxAnnouncedAddrs: FfiConverterUInt32.readFromCursor(c),
168
+ interfaceRefreshMs: FfiConverterUInt64.readFromCursor(c),
169
+ socketPollIntervalMs: FfiConverterUInt64.readFromCursor(c),
170
+ autoDial: FfiConverterBool.readFromCursor(c)
171
+ };
172
+ }
173
+ writeIntoCursor(value, c) {
174
+ FfiConverterBool.writeIntoCursor(value.enableIpv6, c);
175
+ FfiConverterUInt64.writeIntoCursor(value.ttlMs, c);
176
+ FfiConverterUInt64.writeIntoCursor(value.queryIntervalMs, c);
177
+ FfiConverterUInt32.writeIntoCursor(value.maxPacketBytes, c);
178
+ FfiConverterUInt32.writeIntoCursor(value.maxAnnouncedAddrs, c);
179
+ FfiConverterUInt64.writeIntoCursor(value.interfaceRefreshMs, c);
180
+ FfiConverterUInt64.writeIntoCursor(value.socketPollIntervalMs, c);
181
+ FfiConverterBool.writeIntoCursor(value.autoDial, c);
182
+ }
183
+ allocationSize(value) {
184
+ return FfiConverterBool.allocationSize(value.enableIpv6) + FfiConverterUInt64.allocationSize(value.ttlMs) + FfiConverterUInt64.allocationSize(value.queryIntervalMs) + FfiConverterUInt32.allocationSize(value.maxPacketBytes) + FfiConverterUInt32.allocationSize(value.maxAnnouncedAddrs) + FfiConverterUInt64.allocationSize(value.interfaceRefreshMs) + FfiConverterUInt64.allocationSize(value.socketPollIntervalMs) + FfiConverterBool.allocationSize(value.autoDial);
185
+ }
186
+ }
187
+ ;
188
+ return new FFIConverter();
189
+ })();
190
+
191
+ /**
192
+ * Configuration used to construct an FFI endpoint.
193
+ */
194
+
195
+ /**
196
+ * Generated factory for {@link EndpointConfig} record objects.
197
+ */
198
+ export const EndpointConfig = (() => {
199
+ const defaults = () => ({});
200
+ const create = (() => {
201
+ return uniffiCreateRecord(defaults);
202
+ })();
203
+ return Object.freeze({
204
+ create,
205
+ new: create,
206
+ defaults: () => Object.freeze(defaults())
207
+ });
208
+ })();
209
+ const FfiConverterTypeEndpointConfig = (() => {
210
+ class FFIConverter extends AbstractFfiConverterByteArray {
211
+ readFromCursor(c) {
212
+ return {
213
+ agentVersion: FfiConverterOptionalString.readFromCursor(c),
214
+ relays: FfiConverterSequenceString.readFromCursor(c),
215
+ autonatServers: FfiConverterSequenceString.readFromCursor(c),
216
+ listen: FfiConverterOptionalSequenceString.readFromCursor(c),
217
+ forceRelay: FfiConverterBool.readFromCursor(c),
218
+ allowUnsigned: FfiConverterBool.readFromCursor(c),
219
+ protocols: FfiConverterSequenceString.readFromCursor(c),
220
+ discovery: FfiConverterOptionalTypeDiscoveryOptions.readFromCursor(c),
221
+ mdns: FfiConverterOptionalTypeMdnsOptions.readFromCursor(c)
222
+ };
223
+ }
224
+ writeIntoCursor(value, c) {
225
+ FfiConverterOptionalString.writeIntoCursor(value.agentVersion, c);
226
+ FfiConverterSequenceString.writeIntoCursor(value.relays, c);
227
+ FfiConverterSequenceString.writeIntoCursor(value.autonatServers, c);
228
+ FfiConverterOptionalSequenceString.writeIntoCursor(value.listen, c);
229
+ FfiConverterBool.writeIntoCursor(value.forceRelay, c);
230
+ FfiConverterBool.writeIntoCursor(value.allowUnsigned, c);
231
+ FfiConverterSequenceString.writeIntoCursor(value.protocols, c);
232
+ FfiConverterOptionalTypeDiscoveryOptions.writeIntoCursor(value.discovery, c);
233
+ FfiConverterOptionalTypeMdnsOptions.writeIntoCursor(value.mdns, c);
234
+ }
235
+ allocationSize(value) {
236
+ return FfiConverterOptionalString.allocationSize(value.agentVersion) + FfiConverterSequenceString.allocationSize(value.relays) + FfiConverterSequenceString.allocationSize(value.autonatServers) + FfiConverterOptionalSequenceString.allocationSize(value.listen) + FfiConverterBool.allocationSize(value.forceRelay) + FfiConverterBool.allocationSize(value.allowUnsigned) + FfiConverterSequenceString.allocationSize(value.protocols) + FfiConverterOptionalTypeDiscoveryOptions.allocationSize(value.discovery) + FfiConverterOptionalTypeMdnsOptions.allocationSize(value.mdns);
237
+ }
238
+ }
239
+ ;
240
+ return new FFIConverter();
241
+ })();
242
+
243
+ /**
244
+ * Foreign-friendly snapshot of a peer's Identify message.
245
+ */
246
+
247
+ /**
248
+ * Generated factory for {@link IdentifyInfo} record objects.
249
+ */
250
+ export const IdentifyInfo = (() => {
251
+ const defaults = () => ({});
252
+ const create = (() => {
253
+ return uniffiCreateRecord(defaults);
254
+ })();
255
+ return Object.freeze({
256
+ create,
257
+ new: create,
258
+ defaults: () => Object.freeze(defaults())
259
+ });
260
+ })();
261
+ const FfiConverterTypeIdentifyInfo = (() => {
262
+ class FFIConverter extends AbstractFfiConverterByteArray {
263
+ readFromCursor(c) {
264
+ return {
265
+ publicKey: FfiConverterOptionalBytes.readFromCursor(c),
266
+ listenAddrs: FfiConverterSequenceString.readFromCursor(c),
267
+ protocols: FfiConverterSequenceString.readFromCursor(c),
268
+ observedAddr: FfiConverterOptionalString.readFromCursor(c),
269
+ protocolVersion: FfiConverterOptionalString.readFromCursor(c),
270
+ agentVersion: FfiConverterOptionalString.readFromCursor(c)
271
+ };
272
+ }
273
+ writeIntoCursor(value, c) {
274
+ FfiConverterOptionalBytes.writeIntoCursor(value.publicKey, c);
275
+ FfiConverterSequenceString.writeIntoCursor(value.listenAddrs, c);
276
+ FfiConverterSequenceString.writeIntoCursor(value.protocols, c);
277
+ FfiConverterOptionalString.writeIntoCursor(value.observedAddr, c);
278
+ FfiConverterOptionalString.writeIntoCursor(value.protocolVersion, c);
279
+ FfiConverterOptionalString.writeIntoCursor(value.agentVersion, c);
280
+ }
281
+ allocationSize(value) {
282
+ return FfiConverterOptionalBytes.allocationSize(value.publicKey) + FfiConverterSequenceString.allocationSize(value.listenAddrs) + FfiConverterSequenceString.allocationSize(value.protocols) + FfiConverterOptionalString.allocationSize(value.observedAddr) + FfiConverterOptionalString.allocationSize(value.protocolVersion) + FfiConverterOptionalString.allocationSize(value.agentVersion);
283
+ }
284
+ }
285
+ ;
286
+ return new FFIConverter();
287
+ })();
288
+
289
+ /**
290
+ * One peer in the shared discovery address book.
291
+ */
292
+
293
+ /**
294
+ * Generated factory for {@link KnownPeerInfo} record objects.
295
+ */
296
+ export const KnownPeerInfo = (() => {
297
+ const defaults = () => ({});
298
+ const create = (() => {
299
+ return uniffiCreateRecord(defaults);
300
+ })();
301
+ return Object.freeze({
302
+ create,
303
+ new: create,
304
+ defaults: () => Object.freeze(defaults())
305
+ });
306
+ })();
307
+ const FfiConverterTypeKnownPeerInfo = (() => {
308
+ class FFIConverter extends AbstractFfiConverterByteArray {
309
+ readFromCursor(c) {
310
+ return {
311
+ peerId: FfiConverterString.readFromCursor(c),
312
+ addrs: FfiConverterSequenceString.readFromCursor(c),
313
+ beaconAddrs: FfiConverterSequenceString.readFromCursor(c),
314
+ mdnsAddrs: FfiConverterSequenceString.readFromCursor(c),
315
+ beaconLastSeenAgeMs: FfiConverterOptionalUInt64.readFromCursor(c),
316
+ mdnsLastSeenAgeMs: FfiConverterOptionalUInt64.readFromCursor(c),
317
+ connected: FfiConverterBool.readFromCursor(c)
318
+ };
319
+ }
320
+ writeIntoCursor(value, c) {
321
+ FfiConverterString.writeIntoCursor(value.peerId, c);
322
+ FfiConverterSequenceString.writeIntoCursor(value.addrs, c);
323
+ FfiConverterSequenceString.writeIntoCursor(value.beaconAddrs, c);
324
+ FfiConverterSequenceString.writeIntoCursor(value.mdnsAddrs, c);
325
+ FfiConverterOptionalUInt64.writeIntoCursor(value.beaconLastSeenAgeMs, c);
326
+ FfiConverterOptionalUInt64.writeIntoCursor(value.mdnsLastSeenAgeMs, c);
327
+ FfiConverterBool.writeIntoCursor(value.connected, c);
328
+ }
329
+ allocationSize(value) {
330
+ return FfiConverterString.allocationSize(value.peerId) + FfiConverterSequenceString.allocationSize(value.addrs) + FfiConverterSequenceString.allocationSize(value.beaconAddrs) + FfiConverterSequenceString.allocationSize(value.mdnsAddrs) + FfiConverterOptionalUInt64.allocationSize(value.beaconLastSeenAgeMs) + FfiConverterOptionalUInt64.allocationSize(value.mdnsLastSeenAgeMs) + FfiConverterBool.allocationSize(value.connected);
331
+ }
332
+ }
333
+ ;
334
+ return new FFIConverter();
335
+ })();
336
+
337
+ /**
338
+ * Full identity allocated for an outbound application stream.
339
+ */
340
+
341
+ /**
342
+ * Generated factory for {@link OpenStreamResult} record objects.
343
+ */
344
+ export const OpenStreamResult = (() => {
345
+ const defaults = () => ({});
346
+ const create = (() => {
347
+ return uniffiCreateRecord(defaults);
348
+ })();
349
+ return Object.freeze({
350
+ create,
351
+ new: create,
352
+ defaults: () => Object.freeze(defaults())
353
+ });
354
+ })();
355
+ const FfiConverterTypeOpenStreamResult = (() => {
356
+ class FFIConverter extends AbstractFfiConverterByteArray {
357
+ readFromCursor(c) {
358
+ return {
359
+ connId: FfiConverterUInt64.readFromCursor(c),
360
+ streamId: FfiConverterUInt64.readFromCursor(c)
361
+ };
362
+ }
363
+ writeIntoCursor(value, c) {
364
+ FfiConverterUInt64.writeIntoCursor(value.connId, c);
365
+ FfiConverterUInt64.writeIntoCursor(value.streamId, c);
366
+ }
367
+ allocationSize(value) {
368
+ return FfiConverterUInt64.allocationSize(value.connId) + FfiConverterUInt64.allocationSize(value.streamId);
369
+ }
370
+ }
371
+ ;
372
+ return new FFIConverter();
373
+ })();
374
+
375
+ /**
376
+ * Snapshot of the active inbound relay reservation.
377
+ */
378
+
379
+ /**
380
+ * Generated factory for {@link RelayReservationInfo} record objects.
381
+ */
382
+ export const RelayReservationInfo = (() => {
383
+ const defaults = () => ({});
384
+ const create = (() => {
385
+ return uniffiCreateRecord(defaults);
386
+ })();
387
+ return Object.freeze({
388
+ create,
389
+ new: create,
390
+ defaults: () => Object.freeze(defaults())
391
+ });
392
+ })();
393
+ const FfiConverterTypeRelayReservationInfo = (() => {
394
+ class FFIConverter extends AbstractFfiConverterByteArray {
395
+ readFromCursor(c) {
396
+ return {
397
+ relayPeerId: FfiConverterString.readFromCursor(c),
398
+ expiresUnixSecs: FfiConverterOptionalUInt64.readFromCursor(c)
399
+ };
400
+ }
401
+ writeIntoCursor(value, c) {
402
+ FfiConverterString.writeIntoCursor(value.relayPeerId, c);
403
+ FfiConverterOptionalUInt64.writeIntoCursor(value.expiresUnixSecs, c);
404
+ }
405
+ allocationSize(value) {
406
+ return FfiConverterString.allocationSize(value.relayPeerId) + FfiConverterOptionalUInt64.allocationSize(value.expiresUnixSecs);
407
+ }
408
+ }
409
+ ;
410
+ return new FFIConverter();
411
+ })();
412
+
413
+ // Enum: ConnectTarget
414
+ export let ConnectTarget_Tags = /*#__PURE__*/function (ConnectTarget_Tags) {
415
+ ConnectTarget_Tags["Peer"] = "Peer";
416
+ ConnectTarget_Tags["Addresses"] = "Addresses";
417
+ return ConnectTarget_Tags;
418
+ }({});
419
+ /**
420
+ * What a foreign runtime supplies to start one Connection attempt.
421
+ *
422
+ * Validation for every form lives in this module, once; binding shells only
423
+ * adapt the shape to their toolchain.
424
+ */
425
+ export const ConnectTarget = (() => {
426
+ /**
427
+ * Peer ID only: the endpoint applies its discovery-book and relay
428
+ * policy.
429
+ */
430
+ class Peer_ extends UniffiEnum {
431
+ /**
432
+ * @private
433
+ * This field is private and should not be used, use `tag` instead.
434
+ */
435
+ [uniffiTypeNameSymbol] = "ConnectTarget";
436
+ tag = ConnectTarget_Tags.Peer;
437
+ constructor(inner) {
438
+ super("ConnectTarget", "Peer");
439
+ this.inner = Object.freeze(inner);
440
+ }
441
+ static new(inner) {
442
+ return new Peer_(inner);
443
+ }
444
+ static instanceOf(obj) {
445
+ return obj.tag === ConnectTarget_Tags.Peer;
446
+ }
447
+ }
448
+ /**
449
+ * One or more complete direct peer addresses that all name the same
450
+ * peer. One address is the single-address form.
451
+ */
452
+ class Addresses_ extends UniffiEnum {
453
+ /**
454
+ * @private
455
+ * This field is private and should not be used, use `tag` instead.
456
+ */
457
+ [uniffiTypeNameSymbol] = "ConnectTarget";
458
+ tag = ConnectTarget_Tags.Addresses;
459
+ constructor(inner) {
460
+ super("ConnectTarget", "Addresses");
461
+ this.inner = Object.freeze(inner);
462
+ }
463
+ static new(inner) {
464
+ return new Addresses_(inner);
465
+ }
466
+ static instanceOf(obj) {
467
+ return obj.tag === ConnectTarget_Tags.Addresses;
468
+ }
469
+ }
470
+ function instanceOf(obj) {
471
+ return obj[uniffiTypeNameSymbol] === "ConnectTarget";
472
+ }
473
+ return Object.freeze({
474
+ instanceOf,
475
+ Peer: Peer_,
476
+ Addresses: Addresses_
477
+ });
478
+ })();
479
+ /**
480
+ * What a foreign runtime supplies to start one Connection attempt.
481
+ *
482
+ * Validation for every form lives in this module, once; binding shells only
483
+ * adapt the shape to their toolchain.
484
+ */
485
+
486
+ // FfiConverter for enum ConnectTarget
487
+ const FfiConverterTypeConnectTarget = (() => {
488
+ class FFIConverter extends AbstractFfiConverterByteArray {
489
+ readFromCursor(c) {
490
+ switch (c.readI32()) {
491
+ case 1:
492
+ return new ConnectTarget.Peer({
493
+ peerId: FfiConverterString.readFromCursor(c)
494
+ });
495
+ case 2:
496
+ return new ConnectTarget.Addresses({
497
+ addresses: FfiConverterSequenceString.readFromCursor(c)
498
+ });
499
+ default:
500
+ throw new UniffiInternalError.UnexpectedEnumCase();
501
+ }
502
+ }
503
+ writeIntoCursor(value, c) {
504
+ switch (value.tag) {
505
+ case ConnectTarget_Tags.Peer:
506
+ {
507
+ c.writeI32(1);
508
+ const inner = value.inner;
509
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
510
+ return;
511
+ }
512
+ case ConnectTarget_Tags.Addresses:
513
+ {
514
+ c.writeI32(2);
515
+ const inner = value.inner;
516
+ FfiConverterSequenceString.writeIntoCursor(inner.addresses, c);
517
+ return;
518
+ }
519
+ default:
520
+ // Throwing from here means that ConnectTarget_Tags hasn't matched an ordinal.
521
+ throw new UniffiInternalError.UnexpectedEnumCase();
522
+ }
523
+ }
524
+ allocationSize(value) {
525
+ switch (value.tag) {
526
+ case ConnectTarget_Tags.Peer:
527
+ {
528
+ const inner = value.inner;
529
+ let size = 4;
530
+ size += FfiConverterString.allocationSize(inner.peerId);
531
+ return size;
532
+ }
533
+ case ConnectTarget_Tags.Addresses:
534
+ {
535
+ const inner = value.inner;
536
+ let size = 4;
537
+ size += FfiConverterSequenceString.allocationSize(inner.addresses);
538
+ return size;
539
+ }
540
+ default:
541
+ throw new UniffiInternalError.UnexpectedEnumCase();
542
+ }
543
+ }
544
+ }
545
+ return new FFIConverter();
546
+ })();
547
+
548
+ /**
549
+ * Source that contributed a discovery observation.
550
+ */
551
+ export let DiscoverySource = /*#__PURE__*/function (DiscoverySource) {
552
+ /**
553
+ * Public-key-authenticated signed beacon.
554
+ */
555
+ DiscoverySource[DiscoverySource["SignedBeacon"] = 0] = "SignedBeacon";
556
+ /**
557
+ * Unauthenticated local-link mDNS observation.
558
+ */
559
+ DiscoverySource[DiscoverySource["Mdns"] = 1] = "Mdns";
560
+ return DiscoverySource;
561
+ }({});
562
+ const FfiConverterTypeDiscoverySource = (() => {
563
+ class FFIConverter extends AbstractFfiConverterByteArray {
564
+ readFromCursor(c) {
565
+ switch (c.readI32()) {
566
+ case 1:
567
+ return DiscoverySource.SignedBeacon;
568
+ case 2:
569
+ return DiscoverySource.Mdns;
570
+ default:
571
+ throw new UniffiInternalError.UnexpectedEnumCase();
572
+ }
573
+ }
574
+ writeIntoCursor(value, c) {
575
+ switch (value) {
576
+ case DiscoverySource.SignedBeacon:
577
+ return c.writeI32(1);
578
+ case DiscoverySource.Mdns:
579
+ return c.writeI32(2);
580
+ }
581
+ }
582
+ allocationSize(value) {
583
+ return 4;
584
+ }
585
+ }
586
+ return new FFIConverter();
587
+ })();
588
+
589
+ /**
590
+ * Category of a fatal background-driver failure.
591
+ */
592
+ export let DriverFailureKind = /*#__PURE__*/function (DriverFailureKind) {
593
+ /**
594
+ * The transport driver failed.
595
+ */
596
+ DriverFailureKind[DriverFailureKind["Transport"] = 0] = "Transport";
597
+ /**
598
+ * The swarm driver failed.
599
+ */
600
+ DriverFailureKind[DriverFailureKind["Swarm"] = 1] = "Swarm";
601
+ /**
602
+ * An internal driver invariant failed.
603
+ */
604
+ DriverFailureKind[DriverFailureKind["Invariant"] = 2] = "Invariant";
605
+ /**
606
+ * The background pump panicked.
607
+ */
608
+ DriverFailureKind[DriverFailureKind["Panic"] = 3] = "Panic";
609
+ return DriverFailureKind;
610
+ }({});
611
+ const FfiConverterTypeDriverFailureKind = (() => {
612
+ class FFIConverter extends AbstractFfiConverterByteArray {
613
+ readFromCursor(c) {
614
+ switch (c.readI32()) {
615
+ case 1:
616
+ return DriverFailureKind.Transport;
617
+ case 2:
618
+ return DriverFailureKind.Swarm;
619
+ case 3:
620
+ return DriverFailureKind.Invariant;
621
+ case 4:
622
+ return DriverFailureKind.Panic;
623
+ default:
624
+ throw new UniffiInternalError.UnexpectedEnumCase();
625
+ }
626
+ }
627
+ writeIntoCursor(value, c) {
628
+ switch (value) {
629
+ case DriverFailureKind.Transport:
630
+ return c.writeI32(1);
631
+ case DriverFailureKind.Swarm:
632
+ return c.writeI32(2);
633
+ case DriverFailureKind.Invariant:
634
+ return c.writeI32(3);
635
+ case DriverFailureKind.Panic:
636
+ return c.writeI32(4);
637
+ }
638
+ }
639
+ allocationSize(value) {
640
+ return 4;
641
+ }
642
+ }
643
+ return new FFIConverter();
644
+ })();
645
+
646
+ /**
647
+ * Category of a non-fatal endpoint runtime error.
648
+ */
649
+ export let EndpointErrorKind = /*#__PURE__*/function (EndpointErrorKind) {
650
+ /**
651
+ * Underlying transport operation failed.
652
+ */
653
+ EndpointErrorKind[EndpointErrorKind["Transport"] = 0] = "Transport";
654
+ /**
655
+ * Multistream negotiation failed.
656
+ */
657
+ EndpointErrorKind[EndpointErrorKind["Multistream"] = 1] = "Multistream";
658
+ /**
659
+ * Identify protocol failed.
660
+ */
661
+ EndpointErrorKind[EndpointErrorKind["Identify"] = 2] = "Identify";
662
+ /**
663
+ * Ping protocol failed.
664
+ */
665
+ EndpointErrorKind[EndpointErrorKind["Ping"] = 3] = "Ping";
666
+ /**
667
+ * Identify stream setup was rejected.
668
+ */
669
+ EndpointErrorKind[EndpointErrorKind["IdentifyStreamRejected"] = 4] = "IdentifyStreamRejected";
670
+ /**
671
+ * Outbound stream opening failed.
672
+ */
673
+ EndpointErrorKind[EndpointErrorKind["OpenStreamFailed"] = 5] = "OpenStreamFailed";
674
+ /**
675
+ * The remote does not support a requested protocol.
676
+ */
677
+ EndpointErrorKind[EndpointErrorKind["UnsupportedProtocol"] = 6] = "UnsupportedProtocol";
678
+ /**
679
+ * The swarm driver contract failed.
680
+ */
681
+ EndpointErrorKind[EndpointErrorKind["Driver"] = 7] = "Driver";
682
+ return EndpointErrorKind;
683
+ }({});
684
+ const FfiConverterTypeEndpointErrorKind = (() => {
685
+ class FFIConverter extends AbstractFfiConverterByteArray {
686
+ readFromCursor(c) {
687
+ switch (c.readI32()) {
688
+ case 1:
689
+ return EndpointErrorKind.Transport;
690
+ case 2:
691
+ return EndpointErrorKind.Multistream;
692
+ case 3:
693
+ return EndpointErrorKind.Identify;
694
+ case 4:
695
+ return EndpointErrorKind.Ping;
696
+ case 5:
697
+ return EndpointErrorKind.IdentifyStreamRejected;
698
+ case 6:
699
+ return EndpointErrorKind.OpenStreamFailed;
700
+ case 7:
701
+ return EndpointErrorKind.UnsupportedProtocol;
702
+ case 8:
703
+ return EndpointErrorKind.Driver;
704
+ default:
705
+ throw new UniffiInternalError.UnexpectedEnumCase();
706
+ }
707
+ }
708
+ writeIntoCursor(value, c) {
709
+ switch (value) {
710
+ case EndpointErrorKind.Transport:
711
+ return c.writeI32(1);
712
+ case EndpointErrorKind.Multistream:
713
+ return c.writeI32(2);
714
+ case EndpointErrorKind.Identify:
715
+ return c.writeI32(3);
716
+ case EndpointErrorKind.Ping:
717
+ return c.writeI32(4);
718
+ case EndpointErrorKind.IdentifyStreamRejected:
719
+ return c.writeI32(5);
720
+ case EndpointErrorKind.OpenStreamFailed:
721
+ return c.writeI32(6);
722
+ case EndpointErrorKind.UnsupportedProtocol:
723
+ return c.writeI32(7);
724
+ case EndpointErrorKind.Driver:
725
+ return c.writeI32(8);
726
+ }
727
+ }
728
+ allocationSize(value) {
729
+ return 4;
730
+ }
731
+ }
732
+ return new FFIConverter();
733
+ })();
734
+
735
+ // Error type: FfiError
736
+ export let FfiError_Tags = /*#__PURE__*/function (FfiError_Tags) {
737
+ FfiError_Tags["AlreadyStarted"] = "AlreadyStarted";
738
+ FfiError_Tags["Stopped"] = "Stopped";
739
+ FfiError_Tags["InvalidConfig"] = "InvalidConfig";
740
+ FfiError_Tags["InvalidKey"] = "InvalidKey";
741
+ FfiError_Tags["InvalidPeerId"] = "InvalidPeerId";
742
+ FfiError_Tags["InvalidAddress"] = "InvalidAddress";
743
+ FfiError_Tags["InvalidTopic"] = "InvalidTopic";
744
+ FfiError_Tags["NotPermitted"] = "NotPermitted";
745
+ FfiError_Tags["Backpressure"] = "Backpressure";
746
+ FfiError_Tags["MessageTooLarge"] = "MessageTooLarge";
747
+ FfiError_Tags["Transport"] = "Transport";
748
+ FfiError_Tags["InvalidState"] = "InvalidState";
749
+ FfiError_Tags["Internal"] = "Internal";
750
+ return FfiError_Tags;
751
+ }({});
752
+ /**
753
+ * An error returned by a synchronous FFI operation.
754
+ */
755
+ export const FfiError = (() => {
756
+ /**
757
+ * The endpoint's background driver was already started.
758
+ */
759
+ class AlreadyStarted_ extends UniffiError {
760
+ /**
761
+ * @private
762
+ * This field is private and should not be used, use `tag` instead.
763
+ */
764
+ [uniffiTypeNameSymbol] = "FfiError";
765
+ tag = FfiError_Tags.AlreadyStarted;
766
+ constructor() {
767
+ super("FfiError", "AlreadyStarted");
768
+ }
769
+ static new() {
770
+ return new AlreadyStarted_();
771
+ }
772
+ static instanceOf(obj) {
773
+ return obj.tag === FfiError_Tags.AlreadyStarted;
774
+ }
775
+ static hasInner(obj) {
776
+ return false;
777
+ }
778
+ }
779
+ /**
780
+ * The endpoint has stopped and cannot be restarted.
781
+ */
782
+ class Stopped_ extends UniffiError {
783
+ /**
784
+ * @private
785
+ * This field is private and should not be used, use `tag` instead.
786
+ */
787
+ [uniffiTypeNameSymbol] = "FfiError";
788
+ tag = FfiError_Tags.Stopped;
789
+ constructor() {
790
+ super("FfiError", "Stopped");
791
+ }
792
+ static new() {
793
+ return new Stopped_();
794
+ }
795
+ static instanceOf(obj) {
796
+ return obj.tag === FfiError_Tags.Stopped;
797
+ }
798
+ static hasInner(obj) {
799
+ return false;
800
+ }
801
+ }
802
+ /**
803
+ * Endpoint configuration was internally inconsistent.
804
+ */
805
+ class InvalidConfig_ extends UniffiError {
806
+ /**
807
+ * @private
808
+ * This field is private and should not be used, use `tag` instead.
809
+ */
810
+ [uniffiTypeNameSymbol] = "FfiError";
811
+ tag = FfiError_Tags.InvalidConfig;
812
+ constructor(inner) {
813
+ super("FfiError", "InvalidConfig");
814
+ this.inner = Object.freeze(inner);
815
+ }
816
+ static new(inner) {
817
+ return new InvalidConfig_(inner);
818
+ }
819
+ static instanceOf(obj) {
820
+ return obj.tag === FfiError_Tags.InvalidConfig;
821
+ }
822
+ static hasInner(obj) {
823
+ return InvalidConfig_.instanceOf(obj);
824
+ }
825
+ static getInner(obj) {
826
+ return obj.inner;
827
+ }
828
+ }
829
+ /**
830
+ * Secret key material was not exactly 32 bytes.
831
+ */
832
+ class InvalidKey_ extends UniffiError {
833
+ /**
834
+ * @private
835
+ * This field is private and should not be used, use `tag` instead.
836
+ */
837
+ [uniffiTypeNameSymbol] = "FfiError";
838
+ tag = FfiError_Tags.InvalidKey;
839
+ constructor(inner) {
840
+ super("FfiError", "InvalidKey");
841
+ this.inner = Object.freeze(inner);
842
+ }
843
+ static new(inner) {
844
+ return new InvalidKey_(inner);
845
+ }
846
+ static instanceOf(obj) {
847
+ return obj.tag === FfiError_Tags.InvalidKey;
848
+ }
849
+ static hasInner(obj) {
850
+ return InvalidKey_.instanceOf(obj);
851
+ }
852
+ static getInner(obj) {
853
+ return obj.inner;
854
+ }
855
+ }
856
+ /**
857
+ * A peer ID could not be parsed.
858
+ */
859
+ class InvalidPeerId_ extends UniffiError {
860
+ /**
861
+ * @private
862
+ * This field is private and should not be used, use `tag` instead.
863
+ */
864
+ [uniffiTypeNameSymbol] = "FfiError";
865
+ tag = FfiError_Tags.InvalidPeerId;
866
+ constructor(inner) {
867
+ super("FfiError", "InvalidPeerId");
868
+ this.inner = Object.freeze(inner);
869
+ }
870
+ static new(inner) {
871
+ return new InvalidPeerId_(inner);
872
+ }
873
+ static instanceOf(obj) {
874
+ return obj.tag === FfiError_Tags.InvalidPeerId;
875
+ }
876
+ static hasInner(obj) {
877
+ return InvalidPeerId_.instanceOf(obj);
878
+ }
879
+ static getInner(obj) {
880
+ return obj.inner;
881
+ }
882
+ }
883
+ /**
884
+ * A multiaddress or peer address could not be parsed.
885
+ */
886
+ class InvalidAddress_ extends UniffiError {
887
+ /**
888
+ * @private
889
+ * This field is private and should not be used, use `tag` instead.
890
+ */
891
+ [uniffiTypeNameSymbol] = "FfiError";
892
+ tag = FfiError_Tags.InvalidAddress;
893
+ constructor(inner) {
894
+ super("FfiError", "InvalidAddress");
895
+ this.inner = Object.freeze(inner);
896
+ }
897
+ static new(inner) {
898
+ return new InvalidAddress_(inner);
899
+ }
900
+ static instanceOf(obj) {
901
+ return obj.tag === FfiError_Tags.InvalidAddress;
902
+ }
903
+ static hasInner(obj) {
904
+ return InvalidAddress_.instanceOf(obj);
905
+ }
906
+ static getInner(obj) {
907
+ return obj.inner;
908
+ }
909
+ }
910
+ /**
911
+ * A pubsub topic failed validation.
912
+ */
913
+ class InvalidTopic_ extends UniffiError {
914
+ /**
915
+ * @private
916
+ * This field is private and should not be used, use `tag` instead.
917
+ */
918
+ [uniffiTypeNameSymbol] = "FfiError";
919
+ tag = FfiError_Tags.InvalidTopic;
920
+ constructor(inner) {
921
+ super("FfiError", "InvalidTopic");
922
+ this.inner = Object.freeze(inner);
923
+ }
924
+ static new(inner) {
925
+ return new InvalidTopic_(inner);
926
+ }
927
+ static instanceOf(obj) {
928
+ return obj.tag === FfiError_Tags.InvalidTopic;
929
+ }
930
+ static hasInner(obj) {
931
+ return InvalidTopic_.instanceOf(obj);
932
+ }
933
+ static getInner(obj) {
934
+ return obj.inner;
935
+ }
936
+ }
937
+ /**
938
+ * The operation is valid but reserved by another endpoint subsystem.
939
+ */
940
+ class NotPermitted_ extends UniffiError {
941
+ /**
942
+ * @private
943
+ * This field is private and should not be used, use `tag` instead.
944
+ */
945
+ [uniffiTypeNameSymbol] = "FfiError";
946
+ tag = FfiError_Tags.NotPermitted;
947
+ constructor(inner) {
948
+ super("FfiError", "NotPermitted");
949
+ this.inner = Object.freeze(inner);
950
+ }
951
+ static new(inner) {
952
+ return new NotPermitted_(inner);
953
+ }
954
+ static instanceOf(obj) {
955
+ return obj.tag === FfiError_Tags.NotPermitted;
956
+ }
957
+ static hasInner(obj) {
958
+ return NotPermitted_.instanceOf(obj);
959
+ }
960
+ static getInner(obj) {
961
+ return obj.inner;
962
+ }
963
+ }
964
+ /**
965
+ * A bounded outbound queue is full.
966
+ */
967
+ class Backpressure_ extends UniffiError {
968
+ /**
969
+ * @private
970
+ * This field is private and should not be used, use `tag` instead.
971
+ */
972
+ [uniffiTypeNameSymbol] = "FfiError";
973
+ tag = FfiError_Tags.Backpressure;
974
+ constructor() {
975
+ super("FfiError", "Backpressure");
976
+ }
977
+ static new() {
978
+ return new Backpressure_();
979
+ }
980
+ static instanceOf(obj) {
981
+ return obj.tag === FfiError_Tags.Backpressure;
982
+ }
983
+ static hasInner(obj) {
984
+ return false;
985
+ }
986
+ }
987
+ /**
988
+ * A pubsub message exceeds the protocol limit.
989
+ */
990
+ class MessageTooLarge_ extends UniffiError {
991
+ /**
992
+ * @private
993
+ * This field is private and should not be used, use `tag` instead.
994
+ */
995
+ [uniffiTypeNameSymbol] = "FfiError";
996
+ tag = FfiError_Tags.MessageTooLarge;
997
+ constructor() {
998
+ super("FfiError", "MessageTooLarge");
999
+ }
1000
+ static new() {
1001
+ return new MessageTooLarge_();
1002
+ }
1003
+ static instanceOf(obj) {
1004
+ return obj.tag === FfiError_Tags.MessageTooLarge;
1005
+ }
1006
+ static hasInner(obj) {
1007
+ return false;
1008
+ }
1009
+ }
1010
+ /**
1011
+ * A synchronous transport operation failed.
1012
+ */
1013
+ class Transport_ extends UniffiError {
1014
+ /**
1015
+ * @private
1016
+ * This field is private and should not be used, use `tag` instead.
1017
+ */
1018
+ [uniffiTypeNameSymbol] = "FfiError";
1019
+ tag = FfiError_Tags.Transport;
1020
+ constructor(inner) {
1021
+ super("FfiError", "Transport");
1022
+ this.inner = Object.freeze(inner);
1023
+ }
1024
+ static new(inner) {
1025
+ return new Transport_(inner);
1026
+ }
1027
+ static instanceOf(obj) {
1028
+ return obj.tag === FfiError_Tags.Transport;
1029
+ }
1030
+ static hasInner(obj) {
1031
+ return Transport_.instanceOf(obj);
1032
+ }
1033
+ static getInner(obj) {
1034
+ return obj.inner;
1035
+ }
1036
+ }
1037
+ /**
1038
+ * The operation is unavailable in the endpoint's current lifecycle state.
1039
+ */
1040
+ class InvalidState_ extends UniffiError {
1041
+ /**
1042
+ * @private
1043
+ * This field is private and should not be used, use `tag` instead.
1044
+ */
1045
+ [uniffiTypeNameSymbol] = "FfiError";
1046
+ tag = FfiError_Tags.InvalidState;
1047
+ constructor(inner) {
1048
+ super("FfiError", "InvalidState");
1049
+ this.inner = Object.freeze(inner);
1050
+ }
1051
+ static new(inner) {
1052
+ return new InvalidState_(inner);
1053
+ }
1054
+ static instanceOf(obj) {
1055
+ return obj.tag === FfiError_Tags.InvalidState;
1056
+ }
1057
+ static hasInner(obj) {
1058
+ return InvalidState_.instanceOf(obj);
1059
+ }
1060
+ static getInner(obj) {
1061
+ return obj.inner;
1062
+ }
1063
+ }
1064
+ /**
1065
+ * An internal invariant or unexpected construction path failed.
1066
+ */
1067
+ class Internal_ extends UniffiError {
1068
+ /**
1069
+ * @private
1070
+ * This field is private and should not be used, use `tag` instead.
1071
+ */
1072
+ [uniffiTypeNameSymbol] = "FfiError";
1073
+ tag = FfiError_Tags.Internal;
1074
+ constructor(inner) {
1075
+ super("FfiError", "Internal");
1076
+ this.inner = Object.freeze(inner);
1077
+ }
1078
+ static new(inner) {
1079
+ return new Internal_(inner);
1080
+ }
1081
+ static instanceOf(obj) {
1082
+ return obj.tag === FfiError_Tags.Internal;
1083
+ }
1084
+ static hasInner(obj) {
1085
+ return Internal_.instanceOf(obj);
1086
+ }
1087
+ static getInner(obj) {
1088
+ return obj.inner;
1089
+ }
1090
+ }
1091
+ function instanceOf(obj) {
1092
+ return obj[uniffiTypeNameSymbol] === "FfiError";
1093
+ }
1094
+ return Object.freeze({
1095
+ instanceOf,
1096
+ AlreadyStarted: AlreadyStarted_,
1097
+ Stopped: Stopped_,
1098
+ InvalidConfig: InvalidConfig_,
1099
+ InvalidKey: InvalidKey_,
1100
+ InvalidPeerId: InvalidPeerId_,
1101
+ InvalidAddress: InvalidAddress_,
1102
+ InvalidTopic: InvalidTopic_,
1103
+ NotPermitted: NotPermitted_,
1104
+ Backpressure: Backpressure_,
1105
+ MessageTooLarge: MessageTooLarge_,
1106
+ Transport: Transport_,
1107
+ InvalidState: InvalidState_,
1108
+ Internal: Internal_
1109
+ });
1110
+ })();
1111
+ /**
1112
+ * An error returned by a synchronous FFI operation.
1113
+ */
1114
+
1115
+ // FfiConverter for enum FfiError
1116
+ const FfiConverterTypeFfiError = (() => {
1117
+ class FFIConverter extends AbstractFfiConverterByteArray {
1118
+ readFromCursor(c) {
1119
+ switch (c.readI32()) {
1120
+ case 1:
1121
+ return new FfiError.AlreadyStarted();
1122
+ case 2:
1123
+ return new FfiError.Stopped();
1124
+ case 3:
1125
+ return new FfiError.InvalidConfig({
1126
+ detail: FfiConverterString.readFromCursor(c)
1127
+ });
1128
+ case 4:
1129
+ return new FfiError.InvalidKey({
1130
+ detail: FfiConverterString.readFromCursor(c)
1131
+ });
1132
+ case 5:
1133
+ return new FfiError.InvalidPeerId({
1134
+ detail: FfiConverterString.readFromCursor(c)
1135
+ });
1136
+ case 6:
1137
+ return new FfiError.InvalidAddress({
1138
+ detail: FfiConverterString.readFromCursor(c)
1139
+ });
1140
+ case 7:
1141
+ return new FfiError.InvalidTopic({
1142
+ detail: FfiConverterString.readFromCursor(c)
1143
+ });
1144
+ case 8:
1145
+ return new FfiError.NotPermitted({
1146
+ detail: FfiConverterString.readFromCursor(c)
1147
+ });
1148
+ case 9:
1149
+ return new FfiError.Backpressure();
1150
+ case 10:
1151
+ return new FfiError.MessageTooLarge();
1152
+ case 11:
1153
+ return new FfiError.Transport({
1154
+ detail: FfiConverterString.readFromCursor(c)
1155
+ });
1156
+ case 12:
1157
+ return new FfiError.InvalidState({
1158
+ detail: FfiConverterString.readFromCursor(c)
1159
+ });
1160
+ case 13:
1161
+ return new FfiError.Internal({
1162
+ detail: FfiConverterString.readFromCursor(c)
1163
+ });
1164
+ default:
1165
+ throw new UniffiInternalError.UnexpectedEnumCase();
1166
+ }
1167
+ }
1168
+ writeIntoCursor(value, c) {
1169
+ switch (value.tag) {
1170
+ case FfiError_Tags.AlreadyStarted:
1171
+ {
1172
+ c.writeI32(1);
1173
+ return;
1174
+ }
1175
+ case FfiError_Tags.Stopped:
1176
+ {
1177
+ c.writeI32(2);
1178
+ return;
1179
+ }
1180
+ case FfiError_Tags.InvalidConfig:
1181
+ {
1182
+ c.writeI32(3);
1183
+ const inner = value.inner;
1184
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1185
+ return;
1186
+ }
1187
+ case FfiError_Tags.InvalidKey:
1188
+ {
1189
+ c.writeI32(4);
1190
+ const inner = value.inner;
1191
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1192
+ return;
1193
+ }
1194
+ case FfiError_Tags.InvalidPeerId:
1195
+ {
1196
+ c.writeI32(5);
1197
+ const inner = value.inner;
1198
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1199
+ return;
1200
+ }
1201
+ case FfiError_Tags.InvalidAddress:
1202
+ {
1203
+ c.writeI32(6);
1204
+ const inner = value.inner;
1205
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1206
+ return;
1207
+ }
1208
+ case FfiError_Tags.InvalidTopic:
1209
+ {
1210
+ c.writeI32(7);
1211
+ const inner = value.inner;
1212
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1213
+ return;
1214
+ }
1215
+ case FfiError_Tags.NotPermitted:
1216
+ {
1217
+ c.writeI32(8);
1218
+ const inner = value.inner;
1219
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1220
+ return;
1221
+ }
1222
+ case FfiError_Tags.Backpressure:
1223
+ {
1224
+ c.writeI32(9);
1225
+ return;
1226
+ }
1227
+ case FfiError_Tags.MessageTooLarge:
1228
+ {
1229
+ c.writeI32(10);
1230
+ return;
1231
+ }
1232
+ case FfiError_Tags.Transport:
1233
+ {
1234
+ c.writeI32(11);
1235
+ const inner = value.inner;
1236
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1237
+ return;
1238
+ }
1239
+ case FfiError_Tags.InvalidState:
1240
+ {
1241
+ c.writeI32(12);
1242
+ const inner = value.inner;
1243
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1244
+ return;
1245
+ }
1246
+ case FfiError_Tags.Internal:
1247
+ {
1248
+ c.writeI32(13);
1249
+ const inner = value.inner;
1250
+ FfiConverterString.writeIntoCursor(inner.detail, c);
1251
+ return;
1252
+ }
1253
+ default:
1254
+ // Throwing from here means that FfiError_Tags hasn't matched an ordinal.
1255
+ throw new UniffiInternalError.UnexpectedEnumCase();
1256
+ }
1257
+ }
1258
+ allocationSize(value) {
1259
+ switch (value.tag) {
1260
+ case FfiError_Tags.AlreadyStarted:
1261
+ {
1262
+ return 4;
1263
+ }
1264
+ case FfiError_Tags.Stopped:
1265
+ {
1266
+ return 4;
1267
+ }
1268
+ case FfiError_Tags.InvalidConfig:
1269
+ {
1270
+ const inner = value.inner;
1271
+ let size = 4;
1272
+ size += FfiConverterString.allocationSize(inner.detail);
1273
+ return size;
1274
+ }
1275
+ case FfiError_Tags.InvalidKey:
1276
+ {
1277
+ const inner = value.inner;
1278
+ let size = 4;
1279
+ size += FfiConverterString.allocationSize(inner.detail);
1280
+ return size;
1281
+ }
1282
+ case FfiError_Tags.InvalidPeerId:
1283
+ {
1284
+ const inner = value.inner;
1285
+ let size = 4;
1286
+ size += FfiConverterString.allocationSize(inner.detail);
1287
+ return size;
1288
+ }
1289
+ case FfiError_Tags.InvalidAddress:
1290
+ {
1291
+ const inner = value.inner;
1292
+ let size = 4;
1293
+ size += FfiConverterString.allocationSize(inner.detail);
1294
+ return size;
1295
+ }
1296
+ case FfiError_Tags.InvalidTopic:
1297
+ {
1298
+ const inner = value.inner;
1299
+ let size = 4;
1300
+ size += FfiConverterString.allocationSize(inner.detail);
1301
+ return size;
1302
+ }
1303
+ case FfiError_Tags.NotPermitted:
1304
+ {
1305
+ const inner = value.inner;
1306
+ let size = 4;
1307
+ size += FfiConverterString.allocationSize(inner.detail);
1308
+ return size;
1309
+ }
1310
+ case FfiError_Tags.Backpressure:
1311
+ {
1312
+ return 4;
1313
+ }
1314
+ case FfiError_Tags.MessageTooLarge:
1315
+ {
1316
+ return 4;
1317
+ }
1318
+ case FfiError_Tags.Transport:
1319
+ {
1320
+ const inner = value.inner;
1321
+ let size = 4;
1322
+ size += FfiConverterString.allocationSize(inner.detail);
1323
+ return size;
1324
+ }
1325
+ case FfiError_Tags.InvalidState:
1326
+ {
1327
+ const inner = value.inner;
1328
+ let size = 4;
1329
+ size += FfiConverterString.allocationSize(inner.detail);
1330
+ return size;
1331
+ }
1332
+ case FfiError_Tags.Internal:
1333
+ {
1334
+ const inner = value.inner;
1335
+ let size = 4;
1336
+ size += FfiConverterString.allocationSize(inner.detail);
1337
+ return size;
1338
+ }
1339
+ default:
1340
+ throw new UniffiInternalError.UnexpectedEnumCase();
1341
+ }
1342
+ }
1343
+ }
1344
+ return new FFIConverter();
1345
+ })();
1346
+
1347
+ /**
1348
+ * Category of a failed NAT connection attempt.
1349
+ */
1350
+ export let NatErrorKind = /*#__PURE__*/function (NatErrorKind) {
1351
+ /**
1352
+ * No usable direct or relayed path exists.
1353
+ */
1354
+ NatErrorKind[NatErrorKind["NoPathAvailable"] = 0] = "NoPathAvailable";
1355
+ /**
1356
+ * The connection attempt timed out.
1357
+ */
1358
+ NatErrorKind[NatErrorKind["Timeout"] = 1] = "Timeout";
1359
+ /**
1360
+ * A transport dial failed.
1361
+ */
1362
+ NatErrorKind[NatErrorKind["DialFailed"] = 2] = "DialFailed";
1363
+ /**
1364
+ * A traversal protocol exchange failed.
1365
+ */
1366
+ NatErrorKind[NatErrorKind["Protocol"] = 3] = "Protocol";
1367
+ /**
1368
+ * A relay refused the circuit.
1369
+ */
1370
+ NatErrorKind[NatErrorKind["RelayRefused"] = 4] = "RelayRefused";
1371
+ return NatErrorKind;
1372
+ }({});
1373
+ const FfiConverterTypeNatErrorKind = (() => {
1374
+ class FFIConverter extends AbstractFfiConverterByteArray {
1375
+ readFromCursor(c) {
1376
+ switch (c.readI32()) {
1377
+ case 1:
1378
+ return NatErrorKind.NoPathAvailable;
1379
+ case 2:
1380
+ return NatErrorKind.Timeout;
1381
+ case 3:
1382
+ return NatErrorKind.DialFailed;
1383
+ case 4:
1384
+ return NatErrorKind.Protocol;
1385
+ case 5:
1386
+ return NatErrorKind.RelayRefused;
1387
+ default:
1388
+ throw new UniffiInternalError.UnexpectedEnumCase();
1389
+ }
1390
+ }
1391
+ writeIntoCursor(value, c) {
1392
+ switch (value) {
1393
+ case NatErrorKind.NoPathAvailable:
1394
+ return c.writeI32(1);
1395
+ case NatErrorKind.Timeout:
1396
+ return c.writeI32(2);
1397
+ case NatErrorKind.DialFailed:
1398
+ return c.writeI32(3);
1399
+ case NatErrorKind.Protocol:
1400
+ return c.writeI32(4);
1401
+ case NatErrorKind.RelayRefused:
1402
+ return c.writeI32(5);
1403
+ }
1404
+ }
1405
+ allocationSize(value) {
1406
+ return 4;
1407
+ }
1408
+ }
1409
+ return new FFIConverter();
1410
+ })();
1411
+
1412
+ /**
1413
+ * Coarse local reachability state.
1414
+ */
1415
+ export let Reachability = /*#__PURE__*/function (Reachability) {
1416
+ /**
1417
+ * Not enough evidence is available.
1418
+ */
1419
+ Reachability[Reachability["Unknown"] = 0] = "Unknown";
1420
+ /**
1421
+ * The endpoint is directly reachable.
1422
+ */
1423
+ Reachability[Reachability["Public"] = 1] = "Public";
1424
+ /**
1425
+ * The endpoint needs traversal or relay assistance.
1426
+ */
1427
+ Reachability[Reachability["Private"] = 2] = "Private";
1428
+ return Reachability;
1429
+ }({});
1430
+ const FfiConverterTypeReachability = (() => {
1431
+ class FFIConverter extends AbstractFfiConverterByteArray {
1432
+ readFromCursor(c) {
1433
+ switch (c.readI32()) {
1434
+ case 1:
1435
+ return Reachability.Unknown;
1436
+ case 2:
1437
+ return Reachability.Public;
1438
+ case 3:
1439
+ return Reachability.Private;
1440
+ default:
1441
+ throw new UniffiInternalError.UnexpectedEnumCase();
1442
+ }
1443
+ }
1444
+ writeIntoCursor(value, c) {
1445
+ switch (value) {
1446
+ case Reachability.Unknown:
1447
+ return c.writeI32(1);
1448
+ case Reachability.Public:
1449
+ return c.writeI32(2);
1450
+ case Reachability.Private:
1451
+ return c.writeI32(3);
1452
+ }
1453
+ }
1454
+ allocationSize(value) {
1455
+ return 4;
1456
+ }
1457
+ }
1458
+ return new FFIConverter();
1459
+ })();
1460
+
1461
+ // Enum: PathKind
1462
+ export let PathKind_Tags = /*#__PURE__*/function (PathKind_Tags) {
1463
+ PathKind_Tags["DirectDialed"] = "DirectDialed";
1464
+ PathKind_Tags["DirectPunched"] = "DirectPunched";
1465
+ PathKind_Tags["Relayed"] = "Relayed";
1466
+ return PathKind_Tags;
1467
+ }({});
1468
+ /**
1469
+ * Kind of usable connection path.
1470
+ */
1471
+ export const PathKind = (() => {
1472
+ /**
1473
+ * A known address was dialed directly.
1474
+ */
1475
+ class DirectDialed_ extends UniffiEnum {
1476
+ /**
1477
+ * @private
1478
+ * This field is private and should not be used, use `tag` instead.
1479
+ */
1480
+ [uniffiTypeNameSymbol] = "PathKind";
1481
+ tag = PathKind_Tags.DirectDialed;
1482
+ constructor() {
1483
+ super("PathKind", "DirectDialed");
1484
+ }
1485
+ static new() {
1486
+ return new DirectDialed_();
1487
+ }
1488
+ static instanceOf(obj) {
1489
+ return obj.tag === PathKind_Tags.DirectDialed;
1490
+ }
1491
+ }
1492
+ /**
1493
+ * A direct path was established by hole punching.
1494
+ */
1495
+ class DirectPunched_ extends UniffiEnum {
1496
+ /**
1497
+ * @private
1498
+ * This field is private and should not be used, use `tag` instead.
1499
+ */
1500
+ [uniffiTypeNameSymbol] = "PathKind";
1501
+ tag = PathKind_Tags.DirectPunched;
1502
+ constructor() {
1503
+ super("PathKind", "DirectPunched");
1504
+ }
1505
+ static new() {
1506
+ return new DirectPunched_();
1507
+ }
1508
+ static instanceOf(obj) {
1509
+ return obj.tag === PathKind_Tags.DirectPunched;
1510
+ }
1511
+ }
1512
+ /**
1513
+ * Traffic is carried through a relay.
1514
+ */
1515
+ class Relayed_ extends UniffiEnum {
1516
+ /**
1517
+ * @private
1518
+ * This field is private and should not be used, use `tag` instead.
1519
+ */
1520
+ [uniffiTypeNameSymbol] = "PathKind";
1521
+ tag = PathKind_Tags.Relayed;
1522
+ constructor(inner) {
1523
+ super("PathKind", "Relayed");
1524
+ this.inner = Object.freeze(inner);
1525
+ }
1526
+ static new(inner) {
1527
+ return new Relayed_(inner);
1528
+ }
1529
+ static instanceOf(obj) {
1530
+ return obj.tag === PathKind_Tags.Relayed;
1531
+ }
1532
+ }
1533
+ function instanceOf(obj) {
1534
+ return obj[uniffiTypeNameSymbol] === "PathKind";
1535
+ }
1536
+ return Object.freeze({
1537
+ instanceOf,
1538
+ DirectDialed: DirectDialed_,
1539
+ DirectPunched: DirectPunched_,
1540
+ Relayed: Relayed_
1541
+ });
1542
+ })();
1543
+ /**
1544
+ * Kind of usable connection path.
1545
+ */
1546
+
1547
+ // FfiConverter for enum PathKind
1548
+ const FfiConverterTypePathKind = (() => {
1549
+ class FFIConverter extends AbstractFfiConverterByteArray {
1550
+ readFromCursor(c) {
1551
+ switch (c.readI32()) {
1552
+ case 1:
1553
+ return new PathKind.DirectDialed();
1554
+ case 2:
1555
+ return new PathKind.DirectPunched();
1556
+ case 3:
1557
+ return new PathKind.Relayed({
1558
+ relayPeerId: FfiConverterString.readFromCursor(c)
1559
+ });
1560
+ default:
1561
+ throw new UniffiInternalError.UnexpectedEnumCase();
1562
+ }
1563
+ }
1564
+ writeIntoCursor(value, c) {
1565
+ switch (value.tag) {
1566
+ case PathKind_Tags.DirectDialed:
1567
+ {
1568
+ c.writeI32(1);
1569
+ return;
1570
+ }
1571
+ case PathKind_Tags.DirectPunched:
1572
+ {
1573
+ c.writeI32(2);
1574
+ return;
1575
+ }
1576
+ case PathKind_Tags.Relayed:
1577
+ {
1578
+ c.writeI32(3);
1579
+ const inner = value.inner;
1580
+ FfiConverterString.writeIntoCursor(inner.relayPeerId, c);
1581
+ return;
1582
+ }
1583
+ default:
1584
+ // Throwing from here means that PathKind_Tags hasn't matched an ordinal.
1585
+ throw new UniffiInternalError.UnexpectedEnumCase();
1586
+ }
1587
+ }
1588
+ allocationSize(value) {
1589
+ switch (value.tag) {
1590
+ case PathKind_Tags.DirectDialed:
1591
+ {
1592
+ return 4;
1593
+ }
1594
+ case PathKind_Tags.DirectPunched:
1595
+ {
1596
+ return 4;
1597
+ }
1598
+ case PathKind_Tags.Relayed:
1599
+ {
1600
+ const inner = value.inner;
1601
+ let size = 4;
1602
+ size += FfiConverterString.allocationSize(inner.relayPeerId);
1603
+ return size;
1604
+ }
1605
+ default:
1606
+ throw new UniffiInternalError.UnexpectedEnumCase();
1607
+ }
1608
+ }
1609
+ }
1610
+ return new FFIConverter();
1611
+ })();
1612
+
1613
+ // Enum: P2pEvent
1614
+ export let P2pEvent_Tags = /*#__PURE__*/function (P2pEvent_Tags) {
1615
+ P2pEvent_Tags["EventsDropped"] = "EventsDropped";
1616
+ P2pEvent_Tags["DriverFailed"] = "DriverFailed";
1617
+ P2pEvent_Tags["ConnectionEstablished"] = "ConnectionEstablished";
1618
+ P2pEvent_Tags["ConnectionClosed"] = "ConnectionClosed";
1619
+ P2pEvent_Tags["ConnectionReplaced"] = "ConnectionReplaced";
1620
+ P2pEvent_Tags["PeerReady"] = "PeerReady";
1621
+ P2pEvent_Tags["IdentifyReceived"] = "IdentifyReceived";
1622
+ P2pEvent_Tags["PingRttMeasured"] = "PingRttMeasured";
1623
+ P2pEvent_Tags["PingTimeout"] = "PingTimeout";
1624
+ P2pEvent_Tags["StreamReady"] = "StreamReady";
1625
+ P2pEvent_Tags["StreamData"] = "StreamData";
1626
+ P2pEvent_Tags["StreamRemoteWriteClosed"] = "StreamRemoteWriteClosed";
1627
+ P2pEvent_Tags["StreamClosed"] = "StreamClosed";
1628
+ P2pEvent_Tags["EndpointError"] = "EndpointError";
1629
+ P2pEvent_Tags["ReachabilityChanged"] = "ReachabilityChanged";
1630
+ P2pEvent_Tags["PublicAddressesChanged"] = "PublicAddressesChanged";
1631
+ P2pEvent_Tags["RelayReserved"] = "RelayReserved";
1632
+ P2pEvent_Tags["RelayReservationLost"] = "RelayReservationLost";
1633
+ P2pEvent_Tags["PathEstablished"] = "PathEstablished";
1634
+ P2pEvent_Tags["InboundPathEstablished"] = "InboundPathEstablished";
1635
+ P2pEvent_Tags["PathUpgraded"] = "PathUpgraded";
1636
+ P2pEvent_Tags["HolePunchFailed"] = "HolePunchFailed";
1637
+ P2pEvent_Tags["ConnectFailed"] = "ConnectFailed";
1638
+ P2pEvent_Tags["ConnectCancelled"] = "ConnectCancelled";
1639
+ P2pEvent_Tags["InboundDirectUpgrade"] = "InboundDirectUpgrade";
1640
+ P2pEvent_Tags["Message"] = "Message";
1641
+ P2pEvent_Tags["PeerSubscribed"] = "PeerSubscribed";
1642
+ P2pEvent_Tags["PeerUnsubscribed"] = "PeerUnsubscribed";
1643
+ P2pEvent_Tags["GossipsubOutboundFailure"] = "GossipsubOutboundFailure";
1644
+ P2pEvent_Tags["GossipsubProtocolViolation"] = "GossipsubProtocolViolation";
1645
+ P2pEvent_Tags["PeerDiscovered"] = "PeerDiscovered";
1646
+ P2pEvent_Tags["PeerUpdated"] = "PeerUpdated";
1647
+ P2pEvent_Tags["PeerExpired"] = "PeerExpired";
1648
+ P2pEvent_Tags["DiscoveryDialFailed"] = "DiscoveryDialFailed";
1649
+ P2pEvent_Tags["DiscoveryProtocolViolation"] = "DiscoveryProtocolViolation";
1650
+ return P2pEvent_Tags;
1651
+ }({});
1652
+ /**
1653
+ * Event delivered by the native endpoint driver.
1654
+ */
1655
+ export const P2pEvent = (() => {
1656
+ /**
1657
+ * Native event carry overflow discarded source events.
1658
+ */
1659
+ class EventsDropped_ extends UniffiEnum {
1660
+ /**
1661
+ * @private
1662
+ * This field is private and should not be used, use `tag` instead.
1663
+ */
1664
+ [uniffiTypeNameSymbol] = "P2pEvent";
1665
+ tag = P2pEvent_Tags.EventsDropped;
1666
+ constructor(inner) {
1667
+ super("P2pEvent", "EventsDropped");
1668
+ this.inner = Object.freeze(inner);
1669
+ }
1670
+ static new(inner) {
1671
+ return new EventsDropped_(inner);
1672
+ }
1673
+ static instanceOf(obj) {
1674
+ return obj.tag === P2pEvent_Tags.EventsDropped;
1675
+ }
1676
+ }
1677
+ /**
1678
+ * The background driver terminated after a fatal failure.
1679
+ */
1680
+ class DriverFailed_ extends UniffiEnum {
1681
+ /**
1682
+ * @private
1683
+ * This field is private and should not be used, use `tag` instead.
1684
+ */
1685
+ [uniffiTypeNameSymbol] = "P2pEvent";
1686
+ tag = P2pEvent_Tags.DriverFailed;
1687
+ constructor(inner) {
1688
+ super("P2pEvent", "DriverFailed");
1689
+ this.inner = Object.freeze(inner);
1690
+ }
1691
+ static new(inner) {
1692
+ return new DriverFailed_(inner);
1693
+ }
1694
+ static instanceOf(obj) {
1695
+ return obj.tag === P2pEvent_Tags.DriverFailed;
1696
+ }
1697
+ }
1698
+ /**
1699
+ * A peer went from disconnected to connected over a verified connection.
1700
+ */
1701
+ class ConnectionEstablished_ extends UniffiEnum {
1702
+ /**
1703
+ * @private
1704
+ * This field is private and should not be used, use `tag` instead.
1705
+ */
1706
+ [uniffiTypeNameSymbol] = "P2pEvent";
1707
+ tag = P2pEvent_Tags.ConnectionEstablished;
1708
+ constructor(inner) {
1709
+ super("P2pEvent", "ConnectionEstablished");
1710
+ this.inner = Object.freeze(inner);
1711
+ }
1712
+ static new(inner) {
1713
+ return new ConnectionEstablished_(inner);
1714
+ }
1715
+ static instanceOf(obj) {
1716
+ return obj.tag === P2pEvent_Tags.ConnectionEstablished;
1717
+ }
1718
+ }
1719
+ /**
1720
+ * The peer's last connection closed; the peer is now disconnected.
1721
+ */
1722
+ class ConnectionClosed_ extends UniffiEnum {
1723
+ /**
1724
+ * @private
1725
+ * This field is private and should not be used, use `tag` instead.
1726
+ */
1727
+ [uniffiTypeNameSymbol] = "P2pEvent";
1728
+ tag = P2pEvent_Tags.ConnectionClosed;
1729
+ constructor(inner) {
1730
+ super("P2pEvent", "ConnectionClosed");
1731
+ this.inner = Object.freeze(inner);
1732
+ }
1733
+ static new(inner) {
1734
+ return new ConnectionClosed_(inner);
1735
+ }
1736
+ static instanceOf(obj) {
1737
+ return obj.tag === P2pEvent_Tags.ConnectionClosed;
1738
+ }
1739
+ }
1740
+ /**
1741
+ * A newer connection took the peer's single connection slot from
1742
+ * `old_conn_id`.
1743
+ * The peer stays connected; every stream on `old_conn_id` ended with
1744
+ * it, and a fresh `PeerReady` follows for `new_conn_id`.
1745
+ */
1746
+ class ConnectionReplaced_ extends UniffiEnum {
1747
+ /**
1748
+ * @private
1749
+ * This field is private and should not be used, use `tag` instead.
1750
+ */
1751
+ [uniffiTypeNameSymbol] = "P2pEvent";
1752
+ tag = P2pEvent_Tags.ConnectionReplaced;
1753
+ constructor(inner) {
1754
+ super("P2pEvent", "ConnectionReplaced");
1755
+ this.inner = Object.freeze(inner);
1756
+ }
1757
+ static new(inner) {
1758
+ return new ConnectionReplaced_(inner);
1759
+ }
1760
+ static instanceOf(obj) {
1761
+ return obj.tag === P2pEvent_Tags.ConnectionReplaced;
1762
+ }
1763
+ }
1764
+ /**
1765
+ * A peer's connection completed Identify and is ready for application
1766
+ * protocols. Fires once per connection; one whose `conn_id` is no longer
1767
+ * the peer's current connection is stale.
1768
+ */
1769
+ class PeerReady_ extends UniffiEnum {
1770
+ /**
1771
+ * @private
1772
+ * This field is private and should not be used, use `tag` instead.
1773
+ */
1774
+ [uniffiTypeNameSymbol] = "P2pEvent";
1775
+ tag = P2pEvent_Tags.PeerReady;
1776
+ constructor(inner) {
1777
+ super("P2pEvent", "PeerReady");
1778
+ this.inner = Object.freeze(inner);
1779
+ }
1780
+ static new(inner) {
1781
+ return new PeerReady_(inner);
1782
+ }
1783
+ static instanceOf(obj) {
1784
+ return obj.tag === P2pEvent_Tags.PeerReady;
1785
+ }
1786
+ }
1787
+ /**
1788
+ * A peer supplied a new Identify snapshot.
1789
+ */
1790
+ class IdentifyReceived_ extends UniffiEnum {
1791
+ /**
1792
+ * @private
1793
+ * This field is private and should not be used, use `tag` instead.
1794
+ */
1795
+ [uniffiTypeNameSymbol] = "P2pEvent";
1796
+ tag = P2pEvent_Tags.IdentifyReceived;
1797
+ constructor(inner) {
1798
+ super("P2pEvent", "IdentifyReceived");
1799
+ this.inner = Object.freeze(inner);
1800
+ }
1801
+ static new(inner) {
1802
+ return new IdentifyReceived_(inner);
1803
+ }
1804
+ static instanceOf(obj) {
1805
+ return obj.tag === P2pEvent_Tags.IdentifyReceived;
1806
+ }
1807
+ }
1808
+ /**
1809
+ * A ping round-trip measurement completed.
1810
+ */
1811
+ class PingRttMeasured_ extends UniffiEnum {
1812
+ /**
1813
+ * @private
1814
+ * This field is private and should not be used, use `tag` instead.
1815
+ */
1816
+ [uniffiTypeNameSymbol] = "P2pEvent";
1817
+ tag = P2pEvent_Tags.PingRttMeasured;
1818
+ constructor(inner) {
1819
+ super("P2pEvent", "PingRttMeasured");
1820
+ this.inner = Object.freeze(inner);
1821
+ }
1822
+ static new(inner) {
1823
+ return new PingRttMeasured_(inner);
1824
+ }
1825
+ static instanceOf(obj) {
1826
+ return obj.tag === P2pEvent_Tags.PingRttMeasured;
1827
+ }
1828
+ }
1829
+ /**
1830
+ * A ping timed out.
1831
+ */
1832
+ class PingTimeout_ extends UniffiEnum {
1833
+ /**
1834
+ * @private
1835
+ * This field is private and should not be used, use `tag` instead.
1836
+ */
1837
+ [uniffiTypeNameSymbol] = "P2pEvent";
1838
+ tag = P2pEvent_Tags.PingTimeout;
1839
+ constructor(inner) {
1840
+ super("P2pEvent", "PingTimeout");
1841
+ this.inner = Object.freeze(inner);
1842
+ }
1843
+ static new(inner) {
1844
+ return new PingTimeout_(inner);
1845
+ }
1846
+ static instanceOf(obj) {
1847
+ return obj.tag === P2pEvent_Tags.PingTimeout;
1848
+ }
1849
+ }
1850
+ /**
1851
+ * A custom application stream completed protocol negotiation.
1852
+ */
1853
+ class StreamReady_ extends UniffiEnum {
1854
+ /**
1855
+ * @private
1856
+ * This field is private and should not be used, use `tag` instead.
1857
+ */
1858
+ [uniffiTypeNameSymbol] = "P2pEvent";
1859
+ tag = P2pEvent_Tags.StreamReady;
1860
+ constructor(inner) {
1861
+ super("P2pEvent", "StreamReady");
1862
+ this.inner = Object.freeze(inner);
1863
+ }
1864
+ static new(inner) {
1865
+ return new StreamReady_(inner);
1866
+ }
1867
+ static instanceOf(obj) {
1868
+ return obj.tag === P2pEvent_Tags.StreamReady;
1869
+ }
1870
+ }
1871
+ /**
1872
+ * Bytes arrived on a custom application stream.
1873
+ */
1874
+ class StreamData_ extends UniffiEnum {
1875
+ /**
1876
+ * @private
1877
+ * This field is private and should not be used, use `tag` instead.
1878
+ */
1879
+ [uniffiTypeNameSymbol] = "P2pEvent";
1880
+ tag = P2pEvent_Tags.StreamData;
1881
+ constructor(inner) {
1882
+ super("P2pEvent", "StreamData");
1883
+ this.inner = Object.freeze(inner);
1884
+ }
1885
+ static new(inner) {
1886
+ return new StreamData_(inner);
1887
+ }
1888
+ static instanceOf(obj) {
1889
+ return obj.tag === P2pEvent_Tags.StreamData;
1890
+ }
1891
+ }
1892
+ /**
1893
+ * The remote peer half-closed its stream write side.
1894
+ */
1895
+ class StreamRemoteWriteClosed_ extends UniffiEnum {
1896
+ /**
1897
+ * @private
1898
+ * This field is private and should not be used, use `tag` instead.
1899
+ */
1900
+ [uniffiTypeNameSymbol] = "P2pEvent";
1901
+ tag = P2pEvent_Tags.StreamRemoteWriteClosed;
1902
+ constructor(inner) {
1903
+ super("P2pEvent", "StreamRemoteWriteClosed");
1904
+ this.inner = Object.freeze(inner);
1905
+ }
1906
+ static new(inner) {
1907
+ return new StreamRemoteWriteClosed_(inner);
1908
+ }
1909
+ static instanceOf(obj) {
1910
+ return obj.tag === P2pEvent_Tags.StreamRemoteWriteClosed;
1911
+ }
1912
+ }
1913
+ /**
1914
+ * A custom application stream fully closed.
1915
+ */
1916
+ class StreamClosed_ extends UniffiEnum {
1917
+ /**
1918
+ * @private
1919
+ * This field is private and should not be used, use `tag` instead.
1920
+ */
1921
+ [uniffiTypeNameSymbol] = "P2pEvent";
1922
+ tag = P2pEvent_Tags.StreamClosed;
1923
+ constructor(inner) {
1924
+ super("P2pEvent", "StreamClosed");
1925
+ this.inner = Object.freeze(inner);
1926
+ }
1927
+ static new(inner) {
1928
+ return new StreamClosed_(inner);
1929
+ }
1930
+ static instanceOf(obj) {
1931
+ return obj.tag === P2pEvent_Tags.StreamClosed;
1932
+ }
1933
+ }
1934
+ /**
1935
+ * A non-fatal endpoint error occurred.
1936
+ */
1937
+ class EndpointError_ extends UniffiEnum {
1938
+ /**
1939
+ * @private
1940
+ * This field is private and should not be used, use `tag` instead.
1941
+ */
1942
+ [uniffiTypeNameSymbol] = "P2pEvent";
1943
+ tag = P2pEvent_Tags.EndpointError;
1944
+ constructor(inner) {
1945
+ super("P2pEvent", "EndpointError");
1946
+ this.inner = Object.freeze(inner);
1947
+ }
1948
+ static new(inner) {
1949
+ return new EndpointError_(inner);
1950
+ }
1951
+ static instanceOf(obj) {
1952
+ return obj.tag === P2pEvent_Tags.EndpointError;
1953
+ }
1954
+ }
1955
+ /**
1956
+ * The local reachability verdict changed.
1957
+ */
1958
+ class ReachabilityChanged_ extends UniffiEnum {
1959
+ /**
1960
+ * @private
1961
+ * This field is private and should not be used, use `tag` instead.
1962
+ */
1963
+ [uniffiTypeNameSymbol] = "P2pEvent";
1964
+ tag = P2pEvent_Tags.ReachabilityChanged;
1965
+ constructor(inner) {
1966
+ super("P2pEvent", "ReachabilityChanged");
1967
+ this.inner = Object.freeze(inner);
1968
+ }
1969
+ static new(inner) {
1970
+ return new ReachabilityChanged_(inner);
1971
+ }
1972
+ static instanceOf(obj) {
1973
+ return obj.tag === P2pEvent_Tags.ReachabilityChanged;
1974
+ }
1975
+ }
1976
+ /**
1977
+ * AutoNAT confirmed a changed public address set.
1978
+ */
1979
+ class PublicAddressesChanged_ extends UniffiEnum {
1980
+ /**
1981
+ * @private
1982
+ * This field is private and should not be used, use `tag` instead.
1983
+ */
1984
+ [uniffiTypeNameSymbol] = "P2pEvent";
1985
+ tag = P2pEvent_Tags.PublicAddressesChanged;
1986
+ constructor(inner) {
1987
+ super("P2pEvent", "PublicAddressesChanged");
1988
+ this.inner = Object.freeze(inner);
1989
+ }
1990
+ static new(inner) {
1991
+ return new PublicAddressesChanged_(inner);
1992
+ }
1993
+ static instanceOf(obj) {
1994
+ return obj.tag === P2pEvent_Tags.PublicAddressesChanged;
1995
+ }
1996
+ }
1997
+ /**
1998
+ * A relay reservation was acquired or renewed.
1999
+ */
2000
+ class RelayReserved_ extends UniffiEnum {
2001
+ /**
2002
+ * @private
2003
+ * This field is private and should not be used, use `tag` instead.
2004
+ */
2005
+ [uniffiTypeNameSymbol] = "P2pEvent";
2006
+ tag = P2pEvent_Tags.RelayReserved;
2007
+ constructor(inner) {
2008
+ super("P2pEvent", "RelayReserved");
2009
+ this.inner = Object.freeze(inner);
2010
+ }
2011
+ static new(inner) {
2012
+ return new RelayReserved_(inner);
2013
+ }
2014
+ static instanceOf(obj) {
2015
+ return obj.tag === P2pEvent_Tags.RelayReserved;
2016
+ }
2017
+ }
2018
+ /**
2019
+ * A relay reservation was lost.
2020
+ */
2021
+ class RelayReservationLost_ extends UniffiEnum {
2022
+ /**
2023
+ * @private
2024
+ * This field is private and should not be used, use `tag` instead.
2025
+ */
2026
+ [uniffiTypeNameSymbol] = "P2pEvent";
2027
+ tag = P2pEvent_Tags.RelayReservationLost;
2028
+ constructor(inner) {
2029
+ super("P2pEvent", "RelayReservationLost");
2030
+ this.inner = Object.freeze(inner);
2031
+ }
2032
+ static new(inner) {
2033
+ return new RelayReservationLost_(inner);
2034
+ }
2035
+ static instanceOf(obj) {
2036
+ return obj.tag === P2pEvent_Tags.RelayReservationLost;
2037
+ }
2038
+ }
2039
+ /**
2040
+ * The first usable path for an attempt became available.
2041
+ */
2042
+ class PathEstablished_ extends UniffiEnum {
2043
+ /**
2044
+ * @private
2045
+ * This field is private and should not be used, use `tag` instead.
2046
+ */
2047
+ [uniffiTypeNameSymbol] = "P2pEvent";
2048
+ tag = P2pEvent_Tags.PathEstablished;
2049
+ constructor(inner) {
2050
+ super("P2pEvent", "PathEstablished");
2051
+ this.inner = Object.freeze(inner);
2052
+ }
2053
+ static new(inner) {
2054
+ return new PathEstablished_(inner);
2055
+ }
2056
+ static instanceOf(obj) {
2057
+ return obj.tag === P2pEvent_Tags.PathEstablished;
2058
+ }
2059
+ }
2060
+ /**
2061
+ * An inbound relay circuit became a usable path.
2062
+ */
2063
+ class InboundPathEstablished_ extends UniffiEnum {
2064
+ /**
2065
+ * @private
2066
+ * This field is private and should not be used, use `tag` instead.
2067
+ */
2068
+ [uniffiTypeNameSymbol] = "P2pEvent";
2069
+ tag = P2pEvent_Tags.InboundPathEstablished;
2070
+ constructor(inner) {
2071
+ super("P2pEvent", "InboundPathEstablished");
2072
+ this.inner = Object.freeze(inner);
2073
+ }
2074
+ static new(inner) {
2075
+ return new InboundPathEstablished_(inner);
2076
+ }
2077
+ static instanceOf(obj) {
2078
+ return obj.tag === P2pEvent_Tags.InboundPathEstablished;
2079
+ }
2080
+ }
2081
+ /**
2082
+ * A better path replaced an earlier path.
2083
+ */
2084
+ class PathUpgraded_ extends UniffiEnum {
2085
+ /**
2086
+ * @private
2087
+ * This field is private and should not be used, use `tag` instead.
2088
+ */
2089
+ [uniffiTypeNameSymbol] = "P2pEvent";
2090
+ tag = P2pEvent_Tags.PathUpgraded;
2091
+ constructor(inner) {
2092
+ super("P2pEvent", "PathUpgraded");
2093
+ this.inner = Object.freeze(inner);
2094
+ }
2095
+ static new(inner) {
2096
+ return new PathUpgraded_(inner);
2097
+ }
2098
+ static instanceOf(obj) {
2099
+ return obj.tag === P2pEvent_Tags.PathUpgraded;
2100
+ }
2101
+ }
2102
+ /**
2103
+ * One hole-punch window failed.
2104
+ */
2105
+ class HolePunchFailed_ extends UniffiEnum {
2106
+ /**
2107
+ * @private
2108
+ * This field is private and should not be used, use `tag` instead.
2109
+ */
2110
+ [uniffiTypeNameSymbol] = "P2pEvent";
2111
+ tag = P2pEvent_Tags.HolePunchFailed;
2112
+ constructor(inner) {
2113
+ super("P2pEvent", "HolePunchFailed");
2114
+ this.inner = Object.freeze(inner);
2115
+ }
2116
+ static new(inner) {
2117
+ return new HolePunchFailed_(inner);
2118
+ }
2119
+ static instanceOf(obj) {
2120
+ return obj.tag === P2pEvent_Tags.HolePunchFailed;
2121
+ }
2122
+ }
2123
+ /**
2124
+ * A connection attempt ended without a usable path.
2125
+ */
2126
+ class ConnectFailed_ extends UniffiEnum {
2127
+ /**
2128
+ * @private
2129
+ * This field is private and should not be used, use `tag` instead.
2130
+ */
2131
+ [uniffiTypeNameSymbol] = "P2pEvent";
2132
+ tag = P2pEvent_Tags.ConnectFailed;
2133
+ constructor(inner) {
2134
+ super("P2pEvent", "ConnectFailed");
2135
+ this.inner = Object.freeze(inner);
2136
+ }
2137
+ static new(inner) {
2138
+ return new ConnectFailed_(inner);
2139
+ }
2140
+ static instanceOf(obj) {
2141
+ return obj.tag === P2pEvent_Tags.ConnectFailed;
2142
+ }
2143
+ }
2144
+ /**
2145
+ * A Connection attempt was cancelled by `cancel_connect` before it
2146
+ * settled. Terminal for that Connect ID.
2147
+ */
2148
+ class ConnectCancelled_ extends UniffiEnum {
2149
+ /**
2150
+ * @private
2151
+ * This field is private and should not be used, use `tag` instead.
2152
+ */
2153
+ [uniffiTypeNameSymbol] = "P2pEvent";
2154
+ tag = P2pEvent_Tags.ConnectCancelled;
2155
+ constructor(inner) {
2156
+ super("P2pEvent", "ConnectCancelled");
2157
+ this.inner = Object.freeze(inner);
2158
+ }
2159
+ static new(inner) {
2160
+ return new ConnectCancelled_(inner);
2161
+ }
2162
+ static instanceOf(obj) {
2163
+ return obj.tag === P2pEvent_Tags.ConnectCancelled;
2164
+ }
2165
+ }
2166
+ /**
2167
+ * An inbound circuit upgraded to a direct connection.
2168
+ */
2169
+ class InboundDirectUpgrade_ extends UniffiEnum {
2170
+ /**
2171
+ * @private
2172
+ * This field is private and should not be used, use `tag` instead.
2173
+ */
2174
+ [uniffiTypeNameSymbol] = "P2pEvent";
2175
+ tag = P2pEvent_Tags.InboundDirectUpgrade;
2176
+ constructor(inner) {
2177
+ super("P2pEvent", "InboundDirectUpgrade");
2178
+ this.inner = Object.freeze(inner);
2179
+ }
2180
+ static new(inner) {
2181
+ return new InboundDirectUpgrade_(inner);
2182
+ }
2183
+ static instanceOf(obj) {
2184
+ return obj.tag === P2pEvent_Tags.InboundDirectUpgrade;
2185
+ }
2186
+ }
2187
+ /**
2188
+ * An accepted pubsub message arrived.
2189
+ *
2190
+ * When unsigned messages are enabled, `signed` can be `false`; hosts
2191
+ * must treat both `from_peer_id` and `data` as unauthenticated unless
2192
+ * `signed` is `true`.
2193
+ */
2194
+ class Message_ extends UniffiEnum {
2195
+ /**
2196
+ * @private
2197
+ * This field is private and should not be used, use `tag` instead.
2198
+ */
2199
+ [uniffiTypeNameSymbol] = "P2pEvent";
2200
+ tag = P2pEvent_Tags.Message;
2201
+ constructor(inner) {
2202
+ super("P2pEvent", "Message");
2203
+ this.inner = Object.freeze(inner);
2204
+ }
2205
+ static new(inner) {
2206
+ return new Message_(inner);
2207
+ }
2208
+ static instanceOf(obj) {
2209
+ return obj.tag === P2pEvent_Tags.Message;
2210
+ }
2211
+ }
2212
+ /**
2213
+ * A peer announced a subscription.
2214
+ */
2215
+ class PeerSubscribed_ extends UniffiEnum {
2216
+ /**
2217
+ * @private
2218
+ * This field is private and should not be used, use `tag` instead.
2219
+ */
2220
+ [uniffiTypeNameSymbol] = "P2pEvent";
2221
+ tag = P2pEvent_Tags.PeerSubscribed;
2222
+ constructor(inner) {
2223
+ super("P2pEvent", "PeerSubscribed");
2224
+ this.inner = Object.freeze(inner);
2225
+ }
2226
+ static new(inner) {
2227
+ return new PeerSubscribed_(inner);
2228
+ }
2229
+ static instanceOf(obj) {
2230
+ return obj.tag === P2pEvent_Tags.PeerSubscribed;
2231
+ }
2232
+ }
2233
+ /**
2234
+ * A peer's subscription ended: withdrawn, or its connection closed or was replaced.
2235
+ */
2236
+ class PeerUnsubscribed_ extends UniffiEnum {
2237
+ /**
2238
+ * @private
2239
+ * This field is private and should not be used, use `tag` instead.
2240
+ */
2241
+ [uniffiTypeNameSymbol] = "P2pEvent";
2242
+ tag = P2pEvent_Tags.PeerUnsubscribed;
2243
+ constructor(inner) {
2244
+ super("P2pEvent", "PeerUnsubscribed");
2245
+ this.inner = Object.freeze(inner);
2246
+ }
2247
+ static new(inner) {
2248
+ return new PeerUnsubscribed_(inner);
2249
+ }
2250
+ static instanceOf(obj) {
2251
+ return obj.tag === P2pEvent_Tags.PeerUnsubscribed;
2252
+ }
2253
+ }
2254
+ /**
2255
+ * Gossipsub outbound work was discarded.
2256
+ */
2257
+ class GossipsubOutboundFailure_ extends UniffiEnum {
2258
+ /**
2259
+ * @private
2260
+ * This field is private and should not be used, use `tag` instead.
2261
+ */
2262
+ [uniffiTypeNameSymbol] = "P2pEvent";
2263
+ tag = P2pEvent_Tags.GossipsubOutboundFailure;
2264
+ constructor(inner) {
2265
+ super("P2pEvent", "GossipsubOutboundFailure");
2266
+ this.inner = Object.freeze(inner);
2267
+ }
2268
+ static new(inner) {
2269
+ return new GossipsubOutboundFailure_(inner);
2270
+ }
2271
+ static instanceOf(obj) {
2272
+ return obj.tag === P2pEvent_Tags.GossipsubOutboundFailure;
2273
+ }
2274
+ }
2275
+ /**
2276
+ * A peer violated the gossipsub protocol.
2277
+ */
2278
+ class GossipsubProtocolViolation_ extends UniffiEnum {
2279
+ /**
2280
+ * @private
2281
+ * This field is private and should not be used, use `tag` instead.
2282
+ */
2283
+ [uniffiTypeNameSymbol] = "P2pEvent";
2284
+ tag = P2pEvent_Tags.GossipsubProtocolViolation;
2285
+ constructor(inner) {
2286
+ super("P2pEvent", "GossipsubProtocolViolation");
2287
+ this.inner = Object.freeze(inner);
2288
+ }
2289
+ static new(inner) {
2290
+ return new GossipsubProtocolViolation_(inner);
2291
+ }
2292
+ static instanceOf(obj) {
2293
+ return obj.tag === P2pEvent_Tags.GossipsubProtocolViolation;
2294
+ }
2295
+ }
2296
+ /**
2297
+ * Discovery introduced a peer.
2298
+ */
2299
+ class PeerDiscovered_ extends UniffiEnum {
2300
+ /**
2301
+ * @private
2302
+ * This field is private and should not be used, use `tag` instead.
2303
+ */
2304
+ [uniffiTypeNameSymbol] = "P2pEvent";
2305
+ tag = P2pEvent_Tags.PeerDiscovered;
2306
+ constructor(inner) {
2307
+ super("P2pEvent", "PeerDiscovered");
2308
+ this.inner = Object.freeze(inner);
2309
+ }
2310
+ static new(inner) {
2311
+ return new PeerDiscovered_(inner);
2312
+ }
2313
+ static instanceOf(obj) {
2314
+ return obj.tag === P2pEvent_Tags.PeerDiscovered;
2315
+ }
2316
+ }
2317
+ /**
2318
+ * Discovery updated a peer.
2319
+ */
2320
+ class PeerUpdated_ extends UniffiEnum {
2321
+ /**
2322
+ * @private
2323
+ * This field is private and should not be used, use `tag` instead.
2324
+ */
2325
+ [uniffiTypeNameSymbol] = "P2pEvent";
2326
+ tag = P2pEvent_Tags.PeerUpdated;
2327
+ constructor(inner) {
2328
+ super("P2pEvent", "PeerUpdated");
2329
+ this.inner = Object.freeze(inner);
2330
+ }
2331
+ static new(inner) {
2332
+ return new PeerUpdated_(inner);
2333
+ }
2334
+ static instanceOf(obj) {
2335
+ return obj.tag === P2pEvent_Tags.PeerUpdated;
2336
+ }
2337
+ }
2338
+ /**
2339
+ * A discovered peer expired or was evicted.
2340
+ */
2341
+ class PeerExpired_ extends UniffiEnum {
2342
+ /**
2343
+ * @private
2344
+ * This field is private and should not be used, use `tag` instead.
2345
+ */
2346
+ [uniffiTypeNameSymbol] = "P2pEvent";
2347
+ tag = P2pEvent_Tags.PeerExpired;
2348
+ constructor(inner) {
2349
+ super("P2pEvent", "PeerExpired");
2350
+ this.inner = Object.freeze(inner);
2351
+ }
2352
+ static new(inner) {
2353
+ return new PeerExpired_(inner);
2354
+ }
2355
+ static instanceOf(obj) {
2356
+ return obj.tag === P2pEvent_Tags.PeerExpired;
2357
+ }
2358
+ }
2359
+ /**
2360
+ * An automatic discovery dial failed.
2361
+ */
2362
+ class DiscoveryDialFailed_ extends UniffiEnum {
2363
+ /**
2364
+ * @private
2365
+ * This field is private and should not be used, use `tag` instead.
2366
+ */
2367
+ [uniffiTypeNameSymbol] = "P2pEvent";
2368
+ tag = P2pEvent_Tags.DiscoveryDialFailed;
2369
+ constructor(inner) {
2370
+ super("P2pEvent", "DiscoveryDialFailed");
2371
+ this.inner = Object.freeze(inner);
2372
+ }
2373
+ static new(inner) {
2374
+ return new DiscoveryDialFailed_(inner);
2375
+ }
2376
+ static instanceOf(obj) {
2377
+ return obj.tag === P2pEvent_Tags.DiscoveryDialFailed;
2378
+ }
2379
+ }
2380
+ /**
2381
+ * A discovery source supplied an invalid claim.
2382
+ */
2383
+ class DiscoveryProtocolViolation_ extends UniffiEnum {
2384
+ /**
2385
+ * @private
2386
+ * This field is private and should not be used, use `tag` instead.
2387
+ */
2388
+ [uniffiTypeNameSymbol] = "P2pEvent";
2389
+ tag = P2pEvent_Tags.DiscoveryProtocolViolation;
2390
+ constructor(inner) {
2391
+ super("P2pEvent", "DiscoveryProtocolViolation");
2392
+ this.inner = Object.freeze(inner);
2393
+ }
2394
+ static new(inner) {
2395
+ return new DiscoveryProtocolViolation_(inner);
2396
+ }
2397
+ static instanceOf(obj) {
2398
+ return obj.tag === P2pEvent_Tags.DiscoveryProtocolViolation;
2399
+ }
2400
+ }
2401
+ function instanceOf(obj) {
2402
+ return obj[uniffiTypeNameSymbol] === "P2pEvent";
2403
+ }
2404
+ return Object.freeze({
2405
+ instanceOf,
2406
+ EventsDropped: EventsDropped_,
2407
+ DriverFailed: DriverFailed_,
2408
+ ConnectionEstablished: ConnectionEstablished_,
2409
+ ConnectionClosed: ConnectionClosed_,
2410
+ ConnectionReplaced: ConnectionReplaced_,
2411
+ PeerReady: PeerReady_,
2412
+ IdentifyReceived: IdentifyReceived_,
2413
+ PingRttMeasured: PingRttMeasured_,
2414
+ PingTimeout: PingTimeout_,
2415
+ StreamReady: StreamReady_,
2416
+ StreamData: StreamData_,
2417
+ StreamRemoteWriteClosed: StreamRemoteWriteClosed_,
2418
+ StreamClosed: StreamClosed_,
2419
+ EndpointError: EndpointError_,
2420
+ ReachabilityChanged: ReachabilityChanged_,
2421
+ PublicAddressesChanged: PublicAddressesChanged_,
2422
+ RelayReserved: RelayReserved_,
2423
+ RelayReservationLost: RelayReservationLost_,
2424
+ PathEstablished: PathEstablished_,
2425
+ InboundPathEstablished: InboundPathEstablished_,
2426
+ PathUpgraded: PathUpgraded_,
2427
+ HolePunchFailed: HolePunchFailed_,
2428
+ ConnectFailed: ConnectFailed_,
2429
+ ConnectCancelled: ConnectCancelled_,
2430
+ InboundDirectUpgrade: InboundDirectUpgrade_,
2431
+ Message: Message_,
2432
+ PeerSubscribed: PeerSubscribed_,
2433
+ PeerUnsubscribed: PeerUnsubscribed_,
2434
+ GossipsubOutboundFailure: GossipsubOutboundFailure_,
2435
+ GossipsubProtocolViolation: GossipsubProtocolViolation_,
2436
+ PeerDiscovered: PeerDiscovered_,
2437
+ PeerUpdated: PeerUpdated_,
2438
+ PeerExpired: PeerExpired_,
2439
+ DiscoveryDialFailed: DiscoveryDialFailed_,
2440
+ DiscoveryProtocolViolation: DiscoveryProtocolViolation_
2441
+ });
2442
+ })();
2443
+ /**
2444
+ * Event delivered by the native endpoint driver.
2445
+ */
2446
+
2447
+ // FfiConverter for enum P2pEvent
2448
+ const FfiConverterTypeP2pEvent = (() => {
2449
+ class FFIConverter extends AbstractFfiConverterByteArray {
2450
+ readFromCursor(c) {
2451
+ switch (c.readI32()) {
2452
+ case 1:
2453
+ return new P2pEvent.EventsDropped({
2454
+ dropped: FfiConverterUInt64.readFromCursor(c),
2455
+ totalDropped: FfiConverterUInt64.readFromCursor(c),
2456
+ terminalConnectIds: FfiConverterSequenceUInt64.readFromCursor(c)
2457
+ });
2458
+ case 2:
2459
+ return new P2pEvent.DriverFailed({
2460
+ kind: FfiConverterTypeDriverFailureKind.readFromCursor(c),
2461
+ detail: FfiConverterString.readFromCursor(c)
2462
+ });
2463
+ case 3:
2464
+ return new P2pEvent.ConnectionEstablished({
2465
+ peerId: FfiConverterString.readFromCursor(c),
2466
+ connId: FfiConverterUInt64.readFromCursor(c)
2467
+ });
2468
+ case 4:
2469
+ return new P2pEvent.ConnectionClosed({
2470
+ peerId: FfiConverterString.readFromCursor(c),
2471
+ connId: FfiConverterUInt64.readFromCursor(c)
2472
+ });
2473
+ case 5:
2474
+ return new P2pEvent.ConnectionReplaced({
2475
+ peerId: FfiConverterString.readFromCursor(c),
2476
+ oldConnId: FfiConverterUInt64.readFromCursor(c),
2477
+ newConnId: FfiConverterUInt64.readFromCursor(c)
2478
+ });
2479
+ case 6:
2480
+ return new P2pEvent.PeerReady({
2481
+ peerId: FfiConverterString.readFromCursor(c),
2482
+ connId: FfiConverterUInt64.readFromCursor(c),
2483
+ protocols: FfiConverterSequenceString.readFromCursor(c)
2484
+ });
2485
+ case 7:
2486
+ return new P2pEvent.IdentifyReceived({
2487
+ peerId: FfiConverterString.readFromCursor(c),
2488
+ info: FfiConverterTypeIdentifyInfo.readFromCursor(c)
2489
+ });
2490
+ case 8:
2491
+ return new P2pEvent.PingRttMeasured({
2492
+ peerId: FfiConverterString.readFromCursor(c),
2493
+ rttMs: FfiConverterUInt64.readFromCursor(c)
2494
+ });
2495
+ case 9:
2496
+ return new P2pEvent.PingTimeout({
2497
+ peerId: FfiConverterString.readFromCursor(c)
2498
+ });
2499
+ case 10:
2500
+ return new P2pEvent.StreamReady({
2501
+ peerId: FfiConverterString.readFromCursor(c),
2502
+ connId: FfiConverterUInt64.readFromCursor(c),
2503
+ streamId: FfiConverterUInt64.readFromCursor(c),
2504
+ protocolId: FfiConverterString.readFromCursor(c),
2505
+ initiatedLocally: FfiConverterBool.readFromCursor(c)
2506
+ });
2507
+ case 11:
2508
+ return new P2pEvent.StreamData({
2509
+ peerId: FfiConverterString.readFromCursor(c),
2510
+ connId: FfiConverterUInt64.readFromCursor(c),
2511
+ streamId: FfiConverterUInt64.readFromCursor(c),
2512
+ data: FfiConverterArrayBuffer.readFromCursor(c)
2513
+ });
2514
+ case 12:
2515
+ return new P2pEvent.StreamRemoteWriteClosed({
2516
+ peerId: FfiConverterString.readFromCursor(c),
2517
+ connId: FfiConverterUInt64.readFromCursor(c),
2518
+ streamId: FfiConverterUInt64.readFromCursor(c)
2519
+ });
2520
+ case 13:
2521
+ return new P2pEvent.StreamClosed({
2522
+ peerId: FfiConverterString.readFromCursor(c),
2523
+ connId: FfiConverterUInt64.readFromCursor(c),
2524
+ streamId: FfiConverterUInt64.readFromCursor(c)
2525
+ });
2526
+ case 14:
2527
+ return new P2pEvent.EndpointError({
2528
+ kind: FfiConverterTypeEndpointErrorKind.readFromCursor(c),
2529
+ peerId: FfiConverterOptionalString.readFromCursor(c),
2530
+ connId: FfiConverterOptionalUInt64.readFromCursor(c),
2531
+ streamId: FfiConverterOptionalUInt64.readFromCursor(c),
2532
+ detail: FfiConverterString.readFromCursor(c)
2533
+ });
2534
+ case 15:
2535
+ return new P2pEvent.ReachabilityChanged({
2536
+ previous: FfiConverterTypeReachability.readFromCursor(c),
2537
+ current: FfiConverterTypeReachability.readFromCursor(c),
2538
+ confirmedAddrs: FfiConverterSequenceString.readFromCursor(c)
2539
+ });
2540
+ case 16:
2541
+ return new P2pEvent.PublicAddressesChanged({
2542
+ addrs: FfiConverterSequenceString.readFromCursor(c)
2543
+ });
2544
+ case 17:
2545
+ return new P2pEvent.RelayReserved({
2546
+ relayPeerId: FfiConverterString.readFromCursor(c),
2547
+ expiresUnixSecs: FfiConverterOptionalUInt64.readFromCursor(c)
2548
+ });
2549
+ case 18:
2550
+ return new P2pEvent.RelayReservationLost({
2551
+ relayPeerId: FfiConverterString.readFromCursor(c)
2552
+ });
2553
+ case 19:
2554
+ return new P2pEvent.PathEstablished({
2555
+ connectId: FfiConverterUInt64.readFromCursor(c),
2556
+ peerId: FfiConverterString.readFromCursor(c),
2557
+ connId: FfiConverterUInt64.readFromCursor(c),
2558
+ path: FfiConverterTypePathKind.readFromCursor(c)
2559
+ });
2560
+ case 20:
2561
+ return new P2pEvent.InboundPathEstablished({
2562
+ peerId: FfiConverterString.readFromCursor(c),
2563
+ path: FfiConverterTypePathKind.readFromCursor(c)
2564
+ });
2565
+ case 21:
2566
+ return new P2pEvent.PathUpgraded({
2567
+ connectId: FfiConverterUInt64.readFromCursor(c),
2568
+ peerId: FfiConverterString.readFromCursor(c),
2569
+ from: FfiConverterTypePathKind.readFromCursor(c),
2570
+ to: FfiConverterTypePathKind.readFromCursor(c)
2571
+ });
2572
+ case 22:
2573
+ return new P2pEvent.HolePunchFailed({
2574
+ connectId: FfiConverterUInt64.readFromCursor(c),
2575
+ attempt: FfiConverterUInt32.readFromCursor(c),
2576
+ reason: FfiConverterString.readFromCursor(c)
2577
+ });
2578
+ case 23:
2579
+ return new P2pEvent.ConnectFailed({
2580
+ connectId: FfiConverterUInt64.readFromCursor(c),
2581
+ peerId: FfiConverterString.readFromCursor(c),
2582
+ kind: FfiConverterTypeNatErrorKind.readFromCursor(c),
2583
+ detail: FfiConverterString.readFromCursor(c)
2584
+ });
2585
+ case 24:
2586
+ return new P2pEvent.ConnectCancelled({
2587
+ connectId: FfiConverterUInt64.readFromCursor(c),
2588
+ peerId: FfiConverterString.readFromCursor(c)
2589
+ });
2590
+ case 25:
2591
+ return new P2pEvent.InboundDirectUpgrade({
2592
+ peerId: FfiConverterString.readFromCursor(c)
2593
+ });
2594
+ case 26:
2595
+ return new P2pEvent.Message({
2596
+ fromPeerId: FfiConverterString.readFromCursor(c),
2597
+ topics: FfiConverterSequenceString.readFromCursor(c),
2598
+ data: FfiConverterArrayBuffer.readFromCursor(c),
2599
+ seqno: FfiConverterArrayBuffer.readFromCursor(c),
2600
+ signed: FfiConverterBool.readFromCursor(c)
2601
+ });
2602
+ case 27:
2603
+ return new P2pEvent.PeerSubscribed({
2604
+ peerId: FfiConverterString.readFromCursor(c),
2605
+ topic: FfiConverterString.readFromCursor(c)
2606
+ });
2607
+ case 28:
2608
+ return new P2pEvent.PeerUnsubscribed({
2609
+ peerId: FfiConverterString.readFromCursor(c),
2610
+ topic: FfiConverterString.readFromCursor(c)
2611
+ });
2612
+ case 29:
2613
+ return new P2pEvent.GossipsubOutboundFailure({
2614
+ peerId: FfiConverterString.readFromCursor(c),
2615
+ reason: FfiConverterString.readFromCursor(c)
2616
+ });
2617
+ case 30:
2618
+ return new P2pEvent.GossipsubProtocolViolation({
2619
+ peerId: FfiConverterString.readFromCursor(c),
2620
+ reason: FfiConverterString.readFromCursor(c)
2621
+ });
2622
+ case 31:
2623
+ return new P2pEvent.PeerDiscovered({
2624
+ peerId: FfiConverterString.readFromCursor(c),
2625
+ addrs: FfiConverterSequenceString.readFromCursor(c),
2626
+ source: FfiConverterTypeDiscoverySource.readFromCursor(c)
2627
+ });
2628
+ case 32:
2629
+ return new P2pEvent.PeerUpdated({
2630
+ peerId: FfiConverterString.readFromCursor(c),
2631
+ addrs: FfiConverterSequenceString.readFromCursor(c),
2632
+ source: FfiConverterTypeDiscoverySource.readFromCursor(c)
2633
+ });
2634
+ case 33:
2635
+ return new P2pEvent.PeerExpired({
2636
+ peerId: FfiConverterString.readFromCursor(c)
2637
+ });
2638
+ case 34:
2639
+ return new P2pEvent.DiscoveryDialFailed({
2640
+ peerId: FfiConverterString.readFromCursor(c),
2641
+ reason: FfiConverterString.readFromCursor(c)
2642
+ });
2643
+ case 35:
2644
+ return new P2pEvent.DiscoveryProtocolViolation({
2645
+ peerId: FfiConverterOptionalString.readFromCursor(c),
2646
+ source: FfiConverterTypeDiscoverySource.readFromCursor(c),
2647
+ reason: FfiConverterString.readFromCursor(c),
2648
+ suppressed: FfiConverterUInt32.readFromCursor(c)
2649
+ });
2650
+ default:
2651
+ throw new UniffiInternalError.UnexpectedEnumCase();
2652
+ }
2653
+ }
2654
+ writeIntoCursor(value, c) {
2655
+ switch (value.tag) {
2656
+ case P2pEvent_Tags.EventsDropped:
2657
+ {
2658
+ c.writeI32(1);
2659
+ const inner = value.inner;
2660
+ FfiConverterUInt64.writeIntoCursor(inner.dropped, c);
2661
+ FfiConverterUInt64.writeIntoCursor(inner.totalDropped, c);
2662
+ FfiConverterSequenceUInt64.writeIntoCursor(inner.terminalConnectIds, c);
2663
+ return;
2664
+ }
2665
+ case P2pEvent_Tags.DriverFailed:
2666
+ {
2667
+ c.writeI32(2);
2668
+ const inner = value.inner;
2669
+ FfiConverterTypeDriverFailureKind.writeIntoCursor(inner.kind, c);
2670
+ FfiConverterString.writeIntoCursor(inner.detail, c);
2671
+ return;
2672
+ }
2673
+ case P2pEvent_Tags.ConnectionEstablished:
2674
+ {
2675
+ c.writeI32(3);
2676
+ const inner = value.inner;
2677
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2678
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2679
+ return;
2680
+ }
2681
+ case P2pEvent_Tags.ConnectionClosed:
2682
+ {
2683
+ c.writeI32(4);
2684
+ const inner = value.inner;
2685
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2686
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2687
+ return;
2688
+ }
2689
+ case P2pEvent_Tags.ConnectionReplaced:
2690
+ {
2691
+ c.writeI32(5);
2692
+ const inner = value.inner;
2693
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2694
+ FfiConverterUInt64.writeIntoCursor(inner.oldConnId, c);
2695
+ FfiConverterUInt64.writeIntoCursor(inner.newConnId, c);
2696
+ return;
2697
+ }
2698
+ case P2pEvent_Tags.PeerReady:
2699
+ {
2700
+ c.writeI32(6);
2701
+ const inner = value.inner;
2702
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2703
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2704
+ FfiConverterSequenceString.writeIntoCursor(inner.protocols, c);
2705
+ return;
2706
+ }
2707
+ case P2pEvent_Tags.IdentifyReceived:
2708
+ {
2709
+ c.writeI32(7);
2710
+ const inner = value.inner;
2711
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2712
+ FfiConverterTypeIdentifyInfo.writeIntoCursor(inner.info, c);
2713
+ return;
2714
+ }
2715
+ case P2pEvent_Tags.PingRttMeasured:
2716
+ {
2717
+ c.writeI32(8);
2718
+ const inner = value.inner;
2719
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2720
+ FfiConverterUInt64.writeIntoCursor(inner.rttMs, c);
2721
+ return;
2722
+ }
2723
+ case P2pEvent_Tags.PingTimeout:
2724
+ {
2725
+ c.writeI32(9);
2726
+ const inner = value.inner;
2727
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2728
+ return;
2729
+ }
2730
+ case P2pEvent_Tags.StreamReady:
2731
+ {
2732
+ c.writeI32(10);
2733
+ const inner = value.inner;
2734
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2735
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2736
+ FfiConverterUInt64.writeIntoCursor(inner.streamId, c);
2737
+ FfiConverterString.writeIntoCursor(inner.protocolId, c);
2738
+ FfiConverterBool.writeIntoCursor(inner.initiatedLocally, c);
2739
+ return;
2740
+ }
2741
+ case P2pEvent_Tags.StreamData:
2742
+ {
2743
+ c.writeI32(11);
2744
+ const inner = value.inner;
2745
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2746
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2747
+ FfiConverterUInt64.writeIntoCursor(inner.streamId, c);
2748
+ FfiConverterArrayBuffer.writeIntoCursor(inner.data, c);
2749
+ return;
2750
+ }
2751
+ case P2pEvent_Tags.StreamRemoteWriteClosed:
2752
+ {
2753
+ c.writeI32(12);
2754
+ const inner = value.inner;
2755
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2756
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2757
+ FfiConverterUInt64.writeIntoCursor(inner.streamId, c);
2758
+ return;
2759
+ }
2760
+ case P2pEvent_Tags.StreamClosed:
2761
+ {
2762
+ c.writeI32(13);
2763
+ const inner = value.inner;
2764
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2765
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2766
+ FfiConverterUInt64.writeIntoCursor(inner.streamId, c);
2767
+ return;
2768
+ }
2769
+ case P2pEvent_Tags.EndpointError:
2770
+ {
2771
+ c.writeI32(14);
2772
+ const inner = value.inner;
2773
+ FfiConverterTypeEndpointErrorKind.writeIntoCursor(inner.kind, c);
2774
+ FfiConverterOptionalString.writeIntoCursor(inner.peerId, c);
2775
+ FfiConverterOptionalUInt64.writeIntoCursor(inner.connId, c);
2776
+ FfiConverterOptionalUInt64.writeIntoCursor(inner.streamId, c);
2777
+ FfiConverterString.writeIntoCursor(inner.detail, c);
2778
+ return;
2779
+ }
2780
+ case P2pEvent_Tags.ReachabilityChanged:
2781
+ {
2782
+ c.writeI32(15);
2783
+ const inner = value.inner;
2784
+ FfiConverterTypeReachability.writeIntoCursor(inner.previous, c);
2785
+ FfiConverterTypeReachability.writeIntoCursor(inner.current, c);
2786
+ FfiConverterSequenceString.writeIntoCursor(inner.confirmedAddrs, c);
2787
+ return;
2788
+ }
2789
+ case P2pEvent_Tags.PublicAddressesChanged:
2790
+ {
2791
+ c.writeI32(16);
2792
+ const inner = value.inner;
2793
+ FfiConverterSequenceString.writeIntoCursor(inner.addrs, c);
2794
+ return;
2795
+ }
2796
+ case P2pEvent_Tags.RelayReserved:
2797
+ {
2798
+ c.writeI32(17);
2799
+ const inner = value.inner;
2800
+ FfiConverterString.writeIntoCursor(inner.relayPeerId, c);
2801
+ FfiConverterOptionalUInt64.writeIntoCursor(inner.expiresUnixSecs, c);
2802
+ return;
2803
+ }
2804
+ case P2pEvent_Tags.RelayReservationLost:
2805
+ {
2806
+ c.writeI32(18);
2807
+ const inner = value.inner;
2808
+ FfiConverterString.writeIntoCursor(inner.relayPeerId, c);
2809
+ return;
2810
+ }
2811
+ case P2pEvent_Tags.PathEstablished:
2812
+ {
2813
+ c.writeI32(19);
2814
+ const inner = value.inner;
2815
+ FfiConverterUInt64.writeIntoCursor(inner.connectId, c);
2816
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2817
+ FfiConverterUInt64.writeIntoCursor(inner.connId, c);
2818
+ FfiConverterTypePathKind.writeIntoCursor(inner.path, c);
2819
+ return;
2820
+ }
2821
+ case P2pEvent_Tags.InboundPathEstablished:
2822
+ {
2823
+ c.writeI32(20);
2824
+ const inner = value.inner;
2825
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2826
+ FfiConverterTypePathKind.writeIntoCursor(inner.path, c);
2827
+ return;
2828
+ }
2829
+ case P2pEvent_Tags.PathUpgraded:
2830
+ {
2831
+ c.writeI32(21);
2832
+ const inner = value.inner;
2833
+ FfiConverterUInt64.writeIntoCursor(inner.connectId, c);
2834
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2835
+ FfiConverterTypePathKind.writeIntoCursor(inner.from, c);
2836
+ FfiConverterTypePathKind.writeIntoCursor(inner.to, c);
2837
+ return;
2838
+ }
2839
+ case P2pEvent_Tags.HolePunchFailed:
2840
+ {
2841
+ c.writeI32(22);
2842
+ const inner = value.inner;
2843
+ FfiConverterUInt64.writeIntoCursor(inner.connectId, c);
2844
+ FfiConverterUInt32.writeIntoCursor(inner.attempt, c);
2845
+ FfiConverterString.writeIntoCursor(inner.reason, c);
2846
+ return;
2847
+ }
2848
+ case P2pEvent_Tags.ConnectFailed:
2849
+ {
2850
+ c.writeI32(23);
2851
+ const inner = value.inner;
2852
+ FfiConverterUInt64.writeIntoCursor(inner.connectId, c);
2853
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2854
+ FfiConverterTypeNatErrorKind.writeIntoCursor(inner.kind, c);
2855
+ FfiConverterString.writeIntoCursor(inner.detail, c);
2856
+ return;
2857
+ }
2858
+ case P2pEvent_Tags.ConnectCancelled:
2859
+ {
2860
+ c.writeI32(24);
2861
+ const inner = value.inner;
2862
+ FfiConverterUInt64.writeIntoCursor(inner.connectId, c);
2863
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2864
+ return;
2865
+ }
2866
+ case P2pEvent_Tags.InboundDirectUpgrade:
2867
+ {
2868
+ c.writeI32(25);
2869
+ const inner = value.inner;
2870
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2871
+ return;
2872
+ }
2873
+ case P2pEvent_Tags.Message:
2874
+ {
2875
+ c.writeI32(26);
2876
+ const inner = value.inner;
2877
+ FfiConverterString.writeIntoCursor(inner.fromPeerId, c);
2878
+ FfiConverterSequenceString.writeIntoCursor(inner.topics, c);
2879
+ FfiConverterArrayBuffer.writeIntoCursor(inner.data, c);
2880
+ FfiConverterArrayBuffer.writeIntoCursor(inner.seqno, c);
2881
+ FfiConverterBool.writeIntoCursor(inner.signed, c);
2882
+ return;
2883
+ }
2884
+ case P2pEvent_Tags.PeerSubscribed:
2885
+ {
2886
+ c.writeI32(27);
2887
+ const inner = value.inner;
2888
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2889
+ FfiConverterString.writeIntoCursor(inner.topic, c);
2890
+ return;
2891
+ }
2892
+ case P2pEvent_Tags.PeerUnsubscribed:
2893
+ {
2894
+ c.writeI32(28);
2895
+ const inner = value.inner;
2896
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2897
+ FfiConverterString.writeIntoCursor(inner.topic, c);
2898
+ return;
2899
+ }
2900
+ case P2pEvent_Tags.GossipsubOutboundFailure:
2901
+ {
2902
+ c.writeI32(29);
2903
+ const inner = value.inner;
2904
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2905
+ FfiConverterString.writeIntoCursor(inner.reason, c);
2906
+ return;
2907
+ }
2908
+ case P2pEvent_Tags.GossipsubProtocolViolation:
2909
+ {
2910
+ c.writeI32(30);
2911
+ const inner = value.inner;
2912
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2913
+ FfiConverterString.writeIntoCursor(inner.reason, c);
2914
+ return;
2915
+ }
2916
+ case P2pEvent_Tags.PeerDiscovered:
2917
+ {
2918
+ c.writeI32(31);
2919
+ const inner = value.inner;
2920
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2921
+ FfiConverterSequenceString.writeIntoCursor(inner.addrs, c);
2922
+ FfiConverterTypeDiscoverySource.writeIntoCursor(inner.source, c);
2923
+ return;
2924
+ }
2925
+ case P2pEvent_Tags.PeerUpdated:
2926
+ {
2927
+ c.writeI32(32);
2928
+ const inner = value.inner;
2929
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2930
+ FfiConverterSequenceString.writeIntoCursor(inner.addrs, c);
2931
+ FfiConverterTypeDiscoverySource.writeIntoCursor(inner.source, c);
2932
+ return;
2933
+ }
2934
+ case P2pEvent_Tags.PeerExpired:
2935
+ {
2936
+ c.writeI32(33);
2937
+ const inner = value.inner;
2938
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2939
+ return;
2940
+ }
2941
+ case P2pEvent_Tags.DiscoveryDialFailed:
2942
+ {
2943
+ c.writeI32(34);
2944
+ const inner = value.inner;
2945
+ FfiConverterString.writeIntoCursor(inner.peerId, c);
2946
+ FfiConverterString.writeIntoCursor(inner.reason, c);
2947
+ return;
2948
+ }
2949
+ case P2pEvent_Tags.DiscoveryProtocolViolation:
2950
+ {
2951
+ c.writeI32(35);
2952
+ const inner = value.inner;
2953
+ FfiConverterOptionalString.writeIntoCursor(inner.peerId, c);
2954
+ FfiConverterTypeDiscoverySource.writeIntoCursor(inner.source, c);
2955
+ FfiConverterString.writeIntoCursor(inner.reason, c);
2956
+ FfiConverterUInt32.writeIntoCursor(inner.suppressed, c);
2957
+ return;
2958
+ }
2959
+ default:
2960
+ // Throwing from here means that P2pEvent_Tags hasn't matched an ordinal.
2961
+ throw new UniffiInternalError.UnexpectedEnumCase();
2962
+ }
2963
+ }
2964
+ allocationSize(value) {
2965
+ switch (value.tag) {
2966
+ case P2pEvent_Tags.EventsDropped:
2967
+ {
2968
+ const inner = value.inner;
2969
+ let size = 4;
2970
+ size += FfiConverterUInt64.allocationSize(inner.dropped);
2971
+ size += FfiConverterUInt64.allocationSize(inner.totalDropped);
2972
+ size += FfiConverterSequenceUInt64.allocationSize(inner.terminalConnectIds);
2973
+ return size;
2974
+ }
2975
+ case P2pEvent_Tags.DriverFailed:
2976
+ {
2977
+ const inner = value.inner;
2978
+ let size = 4;
2979
+ size += FfiConverterTypeDriverFailureKind.allocationSize(inner.kind);
2980
+ size += FfiConverterString.allocationSize(inner.detail);
2981
+ return size;
2982
+ }
2983
+ case P2pEvent_Tags.ConnectionEstablished:
2984
+ {
2985
+ const inner = value.inner;
2986
+ let size = 4;
2987
+ size += FfiConverterString.allocationSize(inner.peerId);
2988
+ size += FfiConverterUInt64.allocationSize(inner.connId);
2989
+ return size;
2990
+ }
2991
+ case P2pEvent_Tags.ConnectionClosed:
2992
+ {
2993
+ const inner = value.inner;
2994
+ let size = 4;
2995
+ size += FfiConverterString.allocationSize(inner.peerId);
2996
+ size += FfiConverterUInt64.allocationSize(inner.connId);
2997
+ return size;
2998
+ }
2999
+ case P2pEvent_Tags.ConnectionReplaced:
3000
+ {
3001
+ const inner = value.inner;
3002
+ let size = 4;
3003
+ size += FfiConverterString.allocationSize(inner.peerId);
3004
+ size += FfiConverterUInt64.allocationSize(inner.oldConnId);
3005
+ size += FfiConverterUInt64.allocationSize(inner.newConnId);
3006
+ return size;
3007
+ }
3008
+ case P2pEvent_Tags.PeerReady:
3009
+ {
3010
+ const inner = value.inner;
3011
+ let size = 4;
3012
+ size += FfiConverterString.allocationSize(inner.peerId);
3013
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3014
+ size += FfiConverterSequenceString.allocationSize(inner.protocols);
3015
+ return size;
3016
+ }
3017
+ case P2pEvent_Tags.IdentifyReceived:
3018
+ {
3019
+ const inner = value.inner;
3020
+ let size = 4;
3021
+ size += FfiConverterString.allocationSize(inner.peerId);
3022
+ size += FfiConverterTypeIdentifyInfo.allocationSize(inner.info);
3023
+ return size;
3024
+ }
3025
+ case P2pEvent_Tags.PingRttMeasured:
3026
+ {
3027
+ const inner = value.inner;
3028
+ let size = 4;
3029
+ size += FfiConverterString.allocationSize(inner.peerId);
3030
+ size += FfiConverterUInt64.allocationSize(inner.rttMs);
3031
+ return size;
3032
+ }
3033
+ case P2pEvent_Tags.PingTimeout:
3034
+ {
3035
+ const inner = value.inner;
3036
+ let size = 4;
3037
+ size += FfiConverterString.allocationSize(inner.peerId);
3038
+ return size;
3039
+ }
3040
+ case P2pEvent_Tags.StreamReady:
3041
+ {
3042
+ const inner = value.inner;
3043
+ let size = 4;
3044
+ size += FfiConverterString.allocationSize(inner.peerId);
3045
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3046
+ size += FfiConverterUInt64.allocationSize(inner.streamId);
3047
+ size += FfiConverterString.allocationSize(inner.protocolId);
3048
+ size += FfiConverterBool.allocationSize(inner.initiatedLocally);
3049
+ return size;
3050
+ }
3051
+ case P2pEvent_Tags.StreamData:
3052
+ {
3053
+ const inner = value.inner;
3054
+ let size = 4;
3055
+ size += FfiConverterString.allocationSize(inner.peerId);
3056
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3057
+ size += FfiConverterUInt64.allocationSize(inner.streamId);
3058
+ size += FfiConverterArrayBuffer.allocationSize(inner.data);
3059
+ return size;
3060
+ }
3061
+ case P2pEvent_Tags.StreamRemoteWriteClosed:
3062
+ {
3063
+ const inner = value.inner;
3064
+ let size = 4;
3065
+ size += FfiConverterString.allocationSize(inner.peerId);
3066
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3067
+ size += FfiConverterUInt64.allocationSize(inner.streamId);
3068
+ return size;
3069
+ }
3070
+ case P2pEvent_Tags.StreamClosed:
3071
+ {
3072
+ const inner = value.inner;
3073
+ let size = 4;
3074
+ size += FfiConverterString.allocationSize(inner.peerId);
3075
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3076
+ size += FfiConverterUInt64.allocationSize(inner.streamId);
3077
+ return size;
3078
+ }
3079
+ case P2pEvent_Tags.EndpointError:
3080
+ {
3081
+ const inner = value.inner;
3082
+ let size = 4;
3083
+ size += FfiConverterTypeEndpointErrorKind.allocationSize(inner.kind);
3084
+ size += FfiConverterOptionalString.allocationSize(inner.peerId);
3085
+ size += FfiConverterOptionalUInt64.allocationSize(inner.connId);
3086
+ size += FfiConverterOptionalUInt64.allocationSize(inner.streamId);
3087
+ size += FfiConverterString.allocationSize(inner.detail);
3088
+ return size;
3089
+ }
3090
+ case P2pEvent_Tags.ReachabilityChanged:
3091
+ {
3092
+ const inner = value.inner;
3093
+ let size = 4;
3094
+ size += FfiConverterTypeReachability.allocationSize(inner.previous);
3095
+ size += FfiConverterTypeReachability.allocationSize(inner.current);
3096
+ size += FfiConverterSequenceString.allocationSize(inner.confirmedAddrs);
3097
+ return size;
3098
+ }
3099
+ case P2pEvent_Tags.PublicAddressesChanged:
3100
+ {
3101
+ const inner = value.inner;
3102
+ let size = 4;
3103
+ size += FfiConverterSequenceString.allocationSize(inner.addrs);
3104
+ return size;
3105
+ }
3106
+ case P2pEvent_Tags.RelayReserved:
3107
+ {
3108
+ const inner = value.inner;
3109
+ let size = 4;
3110
+ size += FfiConverterString.allocationSize(inner.relayPeerId);
3111
+ size += FfiConverterOptionalUInt64.allocationSize(inner.expiresUnixSecs);
3112
+ return size;
3113
+ }
3114
+ case P2pEvent_Tags.RelayReservationLost:
3115
+ {
3116
+ const inner = value.inner;
3117
+ let size = 4;
3118
+ size += FfiConverterString.allocationSize(inner.relayPeerId);
3119
+ return size;
3120
+ }
3121
+ case P2pEvent_Tags.PathEstablished:
3122
+ {
3123
+ const inner = value.inner;
3124
+ let size = 4;
3125
+ size += FfiConverterUInt64.allocationSize(inner.connectId);
3126
+ size += FfiConverterString.allocationSize(inner.peerId);
3127
+ size += FfiConverterUInt64.allocationSize(inner.connId);
3128
+ size += FfiConverterTypePathKind.allocationSize(inner.path);
3129
+ return size;
3130
+ }
3131
+ case P2pEvent_Tags.InboundPathEstablished:
3132
+ {
3133
+ const inner = value.inner;
3134
+ let size = 4;
3135
+ size += FfiConverterString.allocationSize(inner.peerId);
3136
+ size += FfiConverterTypePathKind.allocationSize(inner.path);
3137
+ return size;
3138
+ }
3139
+ case P2pEvent_Tags.PathUpgraded:
3140
+ {
3141
+ const inner = value.inner;
3142
+ let size = 4;
3143
+ size += FfiConverterUInt64.allocationSize(inner.connectId);
3144
+ size += FfiConverterString.allocationSize(inner.peerId);
3145
+ size += FfiConverterTypePathKind.allocationSize(inner.from);
3146
+ size += FfiConverterTypePathKind.allocationSize(inner.to);
3147
+ return size;
3148
+ }
3149
+ case P2pEvent_Tags.HolePunchFailed:
3150
+ {
3151
+ const inner = value.inner;
3152
+ let size = 4;
3153
+ size += FfiConverterUInt64.allocationSize(inner.connectId);
3154
+ size += FfiConverterUInt32.allocationSize(inner.attempt);
3155
+ size += FfiConverterString.allocationSize(inner.reason);
3156
+ return size;
3157
+ }
3158
+ case P2pEvent_Tags.ConnectFailed:
3159
+ {
3160
+ const inner = value.inner;
3161
+ let size = 4;
3162
+ size += FfiConverterUInt64.allocationSize(inner.connectId);
3163
+ size += FfiConverterString.allocationSize(inner.peerId);
3164
+ size += FfiConverterTypeNatErrorKind.allocationSize(inner.kind);
3165
+ size += FfiConverterString.allocationSize(inner.detail);
3166
+ return size;
3167
+ }
3168
+ case P2pEvent_Tags.ConnectCancelled:
3169
+ {
3170
+ const inner = value.inner;
3171
+ let size = 4;
3172
+ size += FfiConverterUInt64.allocationSize(inner.connectId);
3173
+ size += FfiConverterString.allocationSize(inner.peerId);
3174
+ return size;
3175
+ }
3176
+ case P2pEvent_Tags.InboundDirectUpgrade:
3177
+ {
3178
+ const inner = value.inner;
3179
+ let size = 4;
3180
+ size += FfiConverterString.allocationSize(inner.peerId);
3181
+ return size;
3182
+ }
3183
+ case P2pEvent_Tags.Message:
3184
+ {
3185
+ const inner = value.inner;
3186
+ let size = 4;
3187
+ size += FfiConverterString.allocationSize(inner.fromPeerId);
3188
+ size += FfiConverterSequenceString.allocationSize(inner.topics);
3189
+ size += FfiConverterArrayBuffer.allocationSize(inner.data);
3190
+ size += FfiConverterArrayBuffer.allocationSize(inner.seqno);
3191
+ size += FfiConverterBool.allocationSize(inner.signed);
3192
+ return size;
3193
+ }
3194
+ case P2pEvent_Tags.PeerSubscribed:
3195
+ {
3196
+ const inner = value.inner;
3197
+ let size = 4;
3198
+ size += FfiConverterString.allocationSize(inner.peerId);
3199
+ size += FfiConverterString.allocationSize(inner.topic);
3200
+ return size;
3201
+ }
3202
+ case P2pEvent_Tags.PeerUnsubscribed:
3203
+ {
3204
+ const inner = value.inner;
3205
+ let size = 4;
3206
+ size += FfiConverterString.allocationSize(inner.peerId);
3207
+ size += FfiConverterString.allocationSize(inner.topic);
3208
+ return size;
3209
+ }
3210
+ case P2pEvent_Tags.GossipsubOutboundFailure:
3211
+ {
3212
+ const inner = value.inner;
3213
+ let size = 4;
3214
+ size += FfiConverterString.allocationSize(inner.peerId);
3215
+ size += FfiConverterString.allocationSize(inner.reason);
3216
+ return size;
3217
+ }
3218
+ case P2pEvent_Tags.GossipsubProtocolViolation:
3219
+ {
3220
+ const inner = value.inner;
3221
+ let size = 4;
3222
+ size += FfiConverterString.allocationSize(inner.peerId);
3223
+ size += FfiConverterString.allocationSize(inner.reason);
3224
+ return size;
3225
+ }
3226
+ case P2pEvent_Tags.PeerDiscovered:
3227
+ {
3228
+ const inner = value.inner;
3229
+ let size = 4;
3230
+ size += FfiConverterString.allocationSize(inner.peerId);
3231
+ size += FfiConverterSequenceString.allocationSize(inner.addrs);
3232
+ size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
3233
+ return size;
3234
+ }
3235
+ case P2pEvent_Tags.PeerUpdated:
3236
+ {
3237
+ const inner = value.inner;
3238
+ let size = 4;
3239
+ size += FfiConverterString.allocationSize(inner.peerId);
3240
+ size += FfiConverterSequenceString.allocationSize(inner.addrs);
3241
+ size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
3242
+ return size;
3243
+ }
3244
+ case P2pEvent_Tags.PeerExpired:
3245
+ {
3246
+ const inner = value.inner;
3247
+ let size = 4;
3248
+ size += FfiConverterString.allocationSize(inner.peerId);
3249
+ return size;
3250
+ }
3251
+ case P2pEvent_Tags.DiscoveryDialFailed:
3252
+ {
3253
+ const inner = value.inner;
3254
+ let size = 4;
3255
+ size += FfiConverterString.allocationSize(inner.peerId);
3256
+ size += FfiConverterString.allocationSize(inner.reason);
3257
+ return size;
3258
+ }
3259
+ case P2pEvent_Tags.DiscoveryProtocolViolation:
3260
+ {
3261
+ const inner = value.inner;
3262
+ let size = 4;
3263
+ size += FfiConverterOptionalString.allocationSize(inner.peerId);
3264
+ size += FfiConverterTypeDiscoverySource.allocationSize(inner.source);
3265
+ size += FfiConverterString.allocationSize(inner.reason);
3266
+ size += FfiConverterUInt32.allocationSize(inner.suppressed);
3267
+ return size;
3268
+ }
3269
+ default:
3270
+ throw new UniffiInternalError.UnexpectedEnumCase();
3271
+ }
3272
+ }
3273
+ }
3274
+ return new FFIConverter();
3275
+ })();
3276
+
3277
+ // FfiConverter for string | undefined
3278
+ const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
3279
+
3280
+ // FfiConverter for Array<string>
3281
+ const FfiConverterSequenceString = new FfiConverterArray(FfiConverterString);
3282
+
3283
+ // FfiConverter for Array<string> | undefined
3284
+ const FfiConverterOptionalSequenceString = new FfiConverterOptional(FfiConverterSequenceString);
3285
+
3286
+ // FfiConverter for DiscoveryOptions | undefined
3287
+ const FfiConverterOptionalTypeDiscoveryOptions = new FfiConverterOptional(FfiConverterTypeDiscoveryOptions);
3288
+
3289
+ // FfiConverter for MdnsOptions | undefined
3290
+ const FfiConverterOptionalTypeMdnsOptions = new FfiConverterOptional(FfiConverterTypeMdnsOptions);
3291
+
3292
+ // FfiConverter for ArrayBuffer | undefined
3293
+ const FfiConverterOptionalBytes = new FfiConverterOptional(FfiConverterArrayBuffer);
3294
+
3295
+ // FfiConverter for bigint | undefined
3296
+ const FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);
3297
+
3298
+ // FfiConverter for Array<bigint>
3299
+ const FfiConverterSequenceUInt64 = new FfiConverterArray(FfiConverterUInt64);
3300
+
3301
+ /**
3302
+ * This should be called before anything else.
3303
+ *
3304
+ * It is likely that this is being done for you by the library's `index.ts`.
3305
+ *
3306
+ * It checks versions of uniffi between when the Rust scaffolding was generated
3307
+ * and when the bindings were generated.
3308
+ *
3309
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
3310
+ */
3311
+ function uniffiEnsureInitialized() {
3312
+ // Get the bindings contract version from our ComponentInterface
3313
+ const bindingsContractVersion = 30;
3314
+ // Get the scaffolding contract version by calling the into the dylib
3315
+ const scaffoldingContractVersion = nativeModule().ubrn_ffi_minip2p_ffi_core_uniffi_contract_version();
3316
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
3317
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
3318
+ }
3319
+ }
3320
+ export default Object.freeze({
3321
+ initialize: uniffiEnsureInitialized,
3322
+ converters: {
3323
+ FfiConverterTypeConnectTarget,
3324
+ FfiConverterTypeConnectionInfo,
3325
+ FfiConverterTypeDiscoveryOptions,
3326
+ FfiConverterTypeDiscoverySource,
3327
+ FfiConverterTypeDriverFailureKind,
3328
+ FfiConverterTypeEndpointConfig,
3329
+ FfiConverterTypeEndpointErrorKind,
3330
+ FfiConverterTypeFfiError,
3331
+ FfiConverterTypeIdentifyInfo,
3332
+ FfiConverterTypeKnownPeerInfo,
3333
+ FfiConverterTypeMdnsOptions,
3334
+ FfiConverterTypeNatErrorKind,
3335
+ FfiConverterTypeOpenStreamResult,
3336
+ FfiConverterTypeP2pEvent,
3337
+ FfiConverterTypePathKind,
3338
+ FfiConverterTypeReachability,
3339
+ FfiConverterTypeRelayReservationInfo
3340
+ }
3341
+ });
3342
+ //# sourceMappingURL=minip2p_ffi_core.js.map