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