@stryke/capnp 0.8.3 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4393 @@
1
+ import { MessagePort as MessagePort$1 } from 'node:worker_threads';
2
+ import { ParsedCommandLine } from 'typescript';
3
+
4
+ export declare enum ListElementSize {
5
+ VOID = 0,
6
+ BIT = 1,
7
+ BYTE = 2,
8
+ BYTE_2 = 3,
9
+ BYTE_4 = 4,
10
+ BYTE_8 = 5,
11
+ POINTER = 6,
12
+ COMPOSITE = 7
13
+ }
14
+ /**
15
+ * A simple object that describes the size of a struct.
16
+ */
17
+ export declare class ObjectSize {
18
+ readonly dataByteLength: number;
19
+ readonly pointerLength: number;
20
+ /**
21
+ * Creates a new ObjectSize instance.
22
+ *
23
+ * @param dataByteLength - The number of bytes in the data section of the struct
24
+ * @param pointerLength - The number of pointers in the pointer section of the struct
25
+ */
26
+ constructor(dataByteLength: number, pointerLength: number);
27
+ toString(): string;
28
+ }
29
+ export interface _PointerCtor {
30
+ readonly displayName: string;
31
+ }
32
+ export interface PointerCtor<T extends Pointer> {
33
+ readonly _capnp: _PointerCtor;
34
+ new (segment: Segment, byteOffset: number, depthLimit?: number): T;
35
+ }
36
+ export declare enum PointerType {
37
+ STRUCT = 0,
38
+ LIST = 1,
39
+ FAR = 2,
40
+ OTHER = 3
41
+ }
42
+ export interface _Pointer {
43
+ compositeIndex?: number;
44
+ compositeList: boolean;
45
+ /**
46
+ * A number that is decremented as nested pointers are traversed. When this hits zero errors will be thrown.
47
+ */
48
+ depthLimit: number;
49
+ }
50
+ /**
51
+ * A pointer referencing a single byte location in a segment. This is typically used for Cap'n Proto pointers, but is
52
+ * also sometimes used to reference an offset to a pointer's content or tag words.
53
+ */
54
+ export declare class Pointer<T extends _Pointer = _Pointer> {
55
+ static readonly _capnp: _PointerCtor;
56
+ readonly _capnp: T;
57
+ /** Offset, in bytes, from the start of the segment to the beginning of this pointer. */
58
+ byteOffset: number;
59
+ /**
60
+ * The starting segment for this pointer's data. In the case of a far pointer, the actual content this pointer is
61
+ * referencing will be in another segment within the same message.
62
+ */
63
+ segment: Segment;
64
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
65
+ [Symbol.toStringTag](): string;
66
+ toString(): string;
67
+ }
68
+ export interface _ListCtor {
69
+ readonly compositeSize?: ObjectSize;
70
+ readonly displayName: string;
71
+ readonly size: ListElementSize;
72
+ }
73
+ export interface ListCtor<T> {
74
+ readonly _capnp: _ListCtor;
75
+ new (segment: Segment, byteOffset: number, depthLimit?: number): List<T>;
76
+ }
77
+ export type ArrayCb<T, RT = boolean> = (this: any, value: T, index: number, array: T[]) => RT;
78
+ /**
79
+ * A generic list class. Implements Filterable,
80
+ */
81
+ export declare class List<T> extends Pointer implements Array<T> {
82
+ #private;
83
+ static readonly _capnp: _ListCtor;
84
+ [n: number]: T;
85
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
86
+ get length(): number;
87
+ toArray(): T[];
88
+ get(_index: number): T;
89
+ set(_index: number, _value: T): void;
90
+ at(index: number): T;
91
+ concat(other: T[]): T[];
92
+ some(cb: ArrayCb<T>, _this?: any): boolean;
93
+ filter(cb: ArrayCb<T>, _this?: any): T[];
94
+ find(cb: ArrayCb<T>, _this?: any): T | undefined;
95
+ findIndex(cb: (v: T, i: number, arr: T[]) => boolean, _this?: any): number;
96
+ forEach(cb: ArrayCb<T, void>, _this?: any): void;
97
+ map<U>(cb: ArrayCb<T, U>, _this?: any): U[];
98
+ flatMap<U>(cb: ArrayCb<T, U | U[]>, _this?: any): U[];
99
+ every<S extends T>(cb: (v: T, i: number) => v is S, t?: any): this is S[];
100
+ reduce(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T;
101
+ reduceRight(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T;
102
+ slice(start?: number, end?: number): T[];
103
+ join(separator?: string): string;
104
+ toReversed(): T[];
105
+ toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
106
+ toSpliced(start: number, deleteCount: number, ...items: T[]): T[];
107
+ fill(value: T, start?: number, end?: number): this;
108
+ copyWithin(target: number, start: number, end?: number): this;
109
+ keys(): ArrayIterator<number>;
110
+ values(): ArrayIterator<T>;
111
+ entries(): ArrayIterator<[
112
+ number,
113
+ T
114
+ ]>;
115
+ flat<A, D extends number = 1>(this: A, depth?: D): FlatArray<A, D>[];
116
+ with(index: number, value: T): T[];
117
+ includes(_searchElement: T, _fromIndex?: number): boolean;
118
+ findLast(_cb: unknown, _thisArg?: unknown): T | undefined;
119
+ findLastIndex(_cb: (v: T, i: number, a: T[]) => unknown, _t?: any): number;
120
+ indexOf(_searchElement: T, _fromIndex?: number): number;
121
+ lastIndexOf(_searchElement: T, _fromIndex?: number): number;
122
+ pop(): T | undefined;
123
+ push(..._items: T[]): number;
124
+ reverse(): T[];
125
+ shift(): T | undefined;
126
+ unshift(..._items: T[]): number;
127
+ splice(_start: unknown, _deleteCount?: unknown, ..._rest: unknown[]): T[];
128
+ sort(_fn?: ((a: T, b: T) => number) | undefined): this;
129
+ get [Symbol.unscopables](): {
130
+ [x: number]: boolean | undefined;
131
+ length?: boolean | undefined;
132
+ toString?: boolean | undefined;
133
+ toLocaleString?: boolean | undefined;
134
+ pop?: boolean | undefined;
135
+ push?: boolean | undefined;
136
+ concat?: boolean | undefined;
137
+ join?: boolean | undefined;
138
+ reverse?: boolean | undefined;
139
+ shift?: boolean | undefined;
140
+ slice?: boolean | undefined;
141
+ sort?: boolean | undefined;
142
+ splice?: boolean | undefined;
143
+ unshift?: boolean | undefined;
144
+ indexOf?: boolean | undefined;
145
+ lastIndexOf?: boolean | undefined;
146
+ every?: boolean | undefined;
147
+ some?: boolean | undefined;
148
+ forEach?: boolean | undefined;
149
+ map?: boolean | undefined;
150
+ filter?: boolean | undefined;
151
+ reduce?: boolean | undefined;
152
+ reduceRight?: boolean | undefined;
153
+ find?: boolean | undefined;
154
+ findIndex?: boolean | undefined;
155
+ fill?: boolean | undefined;
156
+ copyWithin?: boolean | undefined;
157
+ entries?: boolean | undefined;
158
+ keys?: boolean | undefined;
159
+ values?: boolean | undefined;
160
+ includes?: boolean | undefined;
161
+ flatMap?: boolean | undefined;
162
+ flat?: boolean | undefined;
163
+ at?: boolean | undefined;
164
+ findLast?: boolean | undefined;
165
+ findLastIndex?: boolean | undefined;
166
+ toReversed?: boolean | undefined;
167
+ toSorted?: boolean | undefined;
168
+ toSpliced?: boolean | undefined;
169
+ with?: boolean | undefined;
170
+ [Symbol.iterator]?: boolean | undefined;
171
+ readonly [Symbol.unscopables]?: boolean | undefined;
172
+ };
173
+ [Symbol.iterator](): ArrayIterator<T>;
174
+ toJSON(): unknown;
175
+ toString(): string;
176
+ toLocaleString(_locales?: unknown, _options?: unknown): string;
177
+ [Symbol.toStringTag](): string;
178
+ static [Symbol.toStringTag](): string;
179
+ }
180
+ declare const Message_Which: {
181
+ /**
182
+ * The sender previously received this message from the peer but didn't understand it or doesn't
183
+ * yet implement the functionality that was requested. So, the sender is echoing the message
184
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
185
+ * had taken some appropriate "null" action.
186
+ *
187
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
188
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
189
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
190
+ * had resolved, thus avoiding a leak.
191
+ *
192
+ * For any message type that introduces a question, if the message comes back unimplemented,
193
+ * the original sender may simply treat it as if the question failed with an exception.
194
+ *
195
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
196
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
197
+ * a gray area; different implementations may take different approaches.
198
+ *
199
+ */
200
+ readonly UNIMPLEMENTED: 0;
201
+ /**
202
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
203
+ * because the sender received an invalid or nonsensical message or because the sender had an
204
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
205
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
206
+ * of a time buffer they want to offer for the client to receive the `abort` before the
207
+ * connection is reset).
208
+ *
209
+ */
210
+ readonly ABORT: 1;
211
+ /**
212
+ * Request the peer's bootstrap interface.
213
+ *
214
+ */
215
+ readonly BOOTSTRAP: 8;
216
+ /**
217
+ * Begin a method call.
218
+ *
219
+ */
220
+ readonly CALL: 2;
221
+ /**
222
+ * Complete a method call.
223
+ *
224
+ */
225
+ readonly RETURN: 3;
226
+ /**
227
+ * Release a returned answer / cancel a call.
228
+ *
229
+ */
230
+ readonly FINISH: 4;
231
+ /**
232
+ * Resolve a previously-sent promise.
233
+ *
234
+ */
235
+ readonly RESOLVE: 5;
236
+ /**
237
+ * Release a capability so that the remote object can be deallocated.
238
+ *
239
+ */
240
+ readonly RELEASE: 6;
241
+ /**
242
+ * Lift an embargo used to enforce E-order over promise resolution.
243
+ *
244
+ */
245
+ readonly DISEMBARGO: 13;
246
+ /**
247
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
248
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
249
+ * implemented.
250
+ *
251
+ */
252
+ readonly OBSOLETE_SAVE: 7;
253
+ /**
254
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
255
+ *
256
+ */
257
+ readonly OBSOLETE_DELETE: 9;
258
+ /**
259
+ * Provide a capability to a third party.
260
+ *
261
+ */
262
+ readonly PROVIDE: 10;
263
+ /**
264
+ * Accept a capability provided by a third party.
265
+ *
266
+ */
267
+ readonly ACCEPT: 11;
268
+ /**
269
+ * Directly connect to the common root of two or more proxied caps.
270
+ *
271
+ */
272
+ readonly JOIN: 12;
273
+ };
274
+ export type Message_Which = (typeof Message_Which)[keyof typeof Message_Which];
275
+ declare class Message$1 extends Struct {
276
+ static readonly UNIMPLEMENTED: 0;
277
+ static readonly ABORT: 1;
278
+ static readonly BOOTSTRAP: 8;
279
+ static readonly CALL: 2;
280
+ static readonly RETURN: 3;
281
+ static readonly FINISH: 4;
282
+ static readonly RESOLVE: 5;
283
+ static readonly RELEASE: 6;
284
+ static readonly DISEMBARGO: 13;
285
+ static readonly OBSOLETE_SAVE: 7;
286
+ static readonly OBSOLETE_DELETE: 9;
287
+ static readonly PROVIDE: 10;
288
+ static readonly ACCEPT: 11;
289
+ static readonly JOIN: 12;
290
+ static readonly _capnp: {
291
+ displayName: string;
292
+ id: string;
293
+ size: ObjectSize;
294
+ };
295
+ _adoptUnimplemented(value: Orphan<Message$1>): void;
296
+ _disownUnimplemented(): Orphan<Message$1>;
297
+ /**
298
+ * The sender previously received this message from the peer but didn't understand it or doesn't
299
+ * yet implement the functionality that was requested. So, the sender is echoing the message
300
+ * back. In some cases, the receiver may be able to recover from this by pretending the sender
301
+ * had taken some appropriate "null" action.
302
+ *
303
+ * For example, say `resolve` is received by a level 0 implementation (because a previous call
304
+ * or return happened to contain a promise). The level 0 implementation will echo it back as
305
+ * `unimplemented`. The original sender can then simply release the cap to which the promise
306
+ * had resolved, thus avoiding a leak.
307
+ *
308
+ * For any message type that introduces a question, if the message comes back unimplemented,
309
+ * the original sender may simply treat it as if the question failed with an exception.
310
+ *
311
+ * In cases where there is no sensible way to react to an `unimplemented` message (without
312
+ * resource leaks or other serious problems), the connection may need to be aborted. This is
313
+ * a gray area; different implementations may take different approaches.
314
+ *
315
+ */
316
+ get unimplemented(): Message$1;
317
+ _hasUnimplemented(): boolean;
318
+ _initUnimplemented(): Message$1;
319
+ get _isUnimplemented(): boolean;
320
+ set unimplemented(value: Message$1);
321
+ _adoptAbort(value: Orphan<Exception>): void;
322
+ _disownAbort(): Orphan<Exception>;
323
+ /**
324
+ * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g.
325
+ * because the sender received an invalid or nonsensical message or because the sender had an
326
+ * internal error. The sender will shut down the outgoing half of the connection after `abort`
327
+ * and will completely close the connection shortly thereafter (it's up to the sender how much
328
+ * of a time buffer they want to offer for the client to receive the `abort` before the
329
+ * connection is reset).
330
+ *
331
+ */
332
+ get abort(): Exception;
333
+ _hasAbort(): boolean;
334
+ _initAbort(): Exception;
335
+ get _isAbort(): boolean;
336
+ set abort(value: Exception);
337
+ _adoptBootstrap(value: Orphan<Bootstrap>): void;
338
+ _disownBootstrap(): Orphan<Bootstrap>;
339
+ /**
340
+ * Request the peer's bootstrap interface.
341
+ *
342
+ */
343
+ get bootstrap(): Bootstrap;
344
+ _hasBootstrap(): boolean;
345
+ _initBootstrap(): Bootstrap;
346
+ get _isBootstrap(): boolean;
347
+ set bootstrap(value: Bootstrap);
348
+ _adoptCall(value: Orphan<Call$1>): void;
349
+ _disownCall(): Orphan<Call$1>;
350
+ /**
351
+ * Begin a method call.
352
+ *
353
+ */
354
+ get call(): Call$1;
355
+ _hasCall(): boolean;
356
+ _initCall(): Call$1;
357
+ get _isCall(): boolean;
358
+ set call(value: Call$1);
359
+ _adoptReturn(value: Orphan<Return>): void;
360
+ _disownReturn(): Orphan<Return>;
361
+ /**
362
+ * Complete a method call.
363
+ *
364
+ */
365
+ get return(): Return;
366
+ _hasReturn(): boolean;
367
+ _initReturn(): Return;
368
+ get _isReturn(): boolean;
369
+ set return(value: Return);
370
+ _adoptFinish(value: Orphan<Finish>): void;
371
+ _disownFinish(): Orphan<Finish>;
372
+ /**
373
+ * Release a returned answer / cancel a call.
374
+ *
375
+ */
376
+ get finish(): Finish;
377
+ _hasFinish(): boolean;
378
+ _initFinish(): Finish;
379
+ get _isFinish(): boolean;
380
+ set finish(value: Finish);
381
+ _adoptResolve(value: Orphan<Resolve>): void;
382
+ _disownResolve(): Orphan<Resolve>;
383
+ /**
384
+ * Resolve a previously-sent promise.
385
+ *
386
+ */
387
+ get resolve(): Resolve;
388
+ _hasResolve(): boolean;
389
+ _initResolve(): Resolve;
390
+ get _isResolve(): boolean;
391
+ set resolve(value: Resolve);
392
+ _adoptRelease(value: Orphan<Release>): void;
393
+ _disownRelease(): Orphan<Release>;
394
+ /**
395
+ * Release a capability so that the remote object can be deallocated.
396
+ *
397
+ */
398
+ get release(): Release;
399
+ _hasRelease(): boolean;
400
+ _initRelease(): Release;
401
+ get _isRelease(): boolean;
402
+ set release(value: Release);
403
+ _adoptDisembargo(value: Orphan<Disembargo>): void;
404
+ _disownDisembargo(): Orphan<Disembargo>;
405
+ /**
406
+ * Lift an embargo used to enforce E-order over promise resolution.
407
+ *
408
+ */
409
+ get disembargo(): Disembargo;
410
+ _hasDisembargo(): boolean;
411
+ _initDisembargo(): Disembargo;
412
+ get _isDisembargo(): boolean;
413
+ set disembargo(value: Disembargo);
414
+ _adoptObsoleteSave(value: Orphan<Pointer>): void;
415
+ _disownObsoleteSave(): Orphan<Pointer>;
416
+ /**
417
+ * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced
418
+ * by the `Persistent` interface defined in `persistent.capnp`. This operation was never
419
+ * implemented.
420
+ *
421
+ */
422
+ get obsoleteSave(): Pointer;
423
+ _hasObsoleteSave(): boolean;
424
+ get _isObsoleteSave(): boolean;
425
+ set obsoleteSave(value: Pointer);
426
+ _adoptObsoleteDelete(value: Orphan<Pointer>): void;
427
+ _disownObsoleteDelete(): Orphan<Pointer>;
428
+ /**
429
+ * Obsolete way to delete a SturdyRef. This operation was never implemented.
430
+ *
431
+ */
432
+ get obsoleteDelete(): Pointer;
433
+ _hasObsoleteDelete(): boolean;
434
+ get _isObsoleteDelete(): boolean;
435
+ set obsoleteDelete(value: Pointer);
436
+ _adoptProvide(value: Orphan<Provide>): void;
437
+ _disownProvide(): Orphan<Provide>;
438
+ /**
439
+ * Provide a capability to a third party.
440
+ *
441
+ */
442
+ get provide(): Provide;
443
+ _hasProvide(): boolean;
444
+ _initProvide(): Provide;
445
+ get _isProvide(): boolean;
446
+ set provide(value: Provide);
447
+ _adoptAccept(value: Orphan<Accept>): void;
448
+ _disownAccept(): Orphan<Accept>;
449
+ /**
450
+ * Accept a capability provided by a third party.
451
+ *
452
+ */
453
+ get accept(): Accept;
454
+ _hasAccept(): boolean;
455
+ _initAccept(): Accept;
456
+ get _isAccept(): boolean;
457
+ set accept(value: Accept);
458
+ _adoptJoin(value: Orphan<Join>): void;
459
+ _disownJoin(): Orphan<Join>;
460
+ /**
461
+ * Directly connect to the common root of two or more proxied caps.
462
+ *
463
+ */
464
+ get join(): Join;
465
+ _hasJoin(): boolean;
466
+ _initJoin(): Join;
467
+ get _isJoin(): boolean;
468
+ set join(value: Join);
469
+ toString(): string;
470
+ which(): Message_Which;
471
+ }
472
+ declare class Bootstrap extends Struct {
473
+ static readonly _capnp: {
474
+ displayName: string;
475
+ id: string;
476
+ size: ObjectSize;
477
+ };
478
+ /**
479
+ * A new question ID identifying this request, which will eventually receive a Return message
480
+ * containing the restored capability.
481
+ *
482
+ */
483
+ get questionId(): number;
484
+ set questionId(value: number);
485
+ _adoptDeprecatedObjectId(value: Orphan<Pointer>): void;
486
+ _disownDeprecatedObjectId(): Orphan<Pointer>;
487
+ /**
488
+ * ** DEPRECATED **
489
+ *
490
+ * A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies
491
+ * which one to return. If this pointer is null, then the default bootstrap interface is returned.
492
+ *
493
+ * As of version 0.5, use of this field is deprecated. If a service wants to export multiple
494
+ * bootstrap interfaces, it should instead define a single bootstrap interface that has methods
495
+ * that return each of the other interfaces.
496
+ *
497
+ * **History**
498
+ *
499
+ * In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`.
500
+ * At the time, it was thought that this would eventually serve as the way to restore SturdyRefs
501
+ * (level 2). Meanwhile, an application could offer its "main" interface on a well-known
502
+ * (non-secret) SturdyRef.
503
+ *
504
+ * Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only
505
+ * used to obtain the main interface. Since most applications had only one main interface that
506
+ * they wanted to restore, they tended to designate this with a null `objectId`.
507
+ *
508
+ * Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting
509
+ * multiple main interfaces by allowing them to be exported under string names. In this case,
510
+ * `objectId` was a Text value specifying the name.
511
+ *
512
+ * All of this proved problematic for several reasons:
513
+ *
514
+ * - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what
515
+ * machine to connect to and would be able to immediately restore a SturdyRef on connection.
516
+ * However, in practice, the ability to restore SturdyRefs is itself a capability that may
517
+ * require going through an authentication process to obtain. Thus, it makes more sense to
518
+ * define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is
519
+ * offered as the vat's bootstrap interface, then this is equivalent to the old arrangement.
520
+ *
521
+ * - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the
522
+ * practice of exporting singleton services with string names. If singleton services are desired,
523
+ * it is better to have one main interface that has methods that can be used to obtain each
524
+ * service, in order to get all the usual benefits of schemas and type checking.
525
+ *
526
+ * - Overloading "Restore" also had a security problem: Often, "main" or "well-known"
527
+ * capabilities exported by a vat are in fact not public: they are intended to be accessed only
528
+ * by clients who are capable of forming a connection to the vat. This can lead to trouble if
529
+ * the client itself has other clients and wishes to forward some `Restore` requests from those
530
+ * external clients -- it has to be very careful not to allow through `Restore` requests
531
+ * addressing the default capability.
532
+ *
533
+ * For example, consider the case of a sandboxed Sandstorm application and its supervisor. The
534
+ * application exports a default capability to its supervisor that provides access to
535
+ * functionality that only the supervisor is supposed to access. Meanwhile, though, applications
536
+ * may publish other capabilities that may be persistent, in which case the application needs
537
+ * to field `Restore` requests that could come from anywhere. These requests of course have to
538
+ * pass through the supervisor, as all communications with the outside world must. But, the
539
+ * supervisor has to be careful not to honor an external request addressing the application's
540
+ * default capability, since this capability is privileged. Unfortunately, the default
541
+ * capability cannot be given an unguessable name, because then the supervisor itself would not
542
+ * be able to address it!
543
+ *
544
+ * As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for
545
+ * use in restoring SturdyRefs.
546
+ *
547
+ * Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a
548
+ * SturdyRef, but indicated that the client would not restore the ref again in the future. This
549
+ * operation was never implemented, so it was removed entirely. If a "delete" operation is desired,
550
+ * it should exist as a method on the same interface that handles restoring SturdyRefs. However,
551
+ * the utility of such an operation is questionable. You wouldn't be able to rely on it for
552
+ * garbage collection since a client could always disappear permanently without remembering to
553
+ * delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to
554
+ * design systems such that SturdyRefs never represent "owned" pointers.
555
+ *
556
+ * For example, say a SturdyRef points to an image file hosted on some server. That image file
557
+ * should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by
558
+ * a user who can delete the image at any time. If the user deletes the image, the SturdyRef
559
+ * stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the
560
+ * existence of the image in its collection.
561
+ *
562
+ */
563
+ get deprecatedObjectId(): Pointer;
564
+ _hasDeprecatedObjectId(): boolean;
565
+ set deprecatedObjectId(value: Pointer);
566
+ toString(): string;
567
+ }
568
+ declare const Call_SendResultsTo_Which: {
569
+ /**
570
+ * Send the return message back to the caller (the usual).
571
+ *
572
+ */
573
+ readonly CALLER: 0;
574
+ /**
575
+ * **(level 1)**
576
+ *
577
+ * Don't actually return the results to the sender. Instead, hold on to them and await
578
+ * instructions from the sender regarding what to do with them. In particular, the sender
579
+ * may subsequently send a `Return` for some other call (which the receiver had previously made
580
+ * to the sender) with `takeFromOtherQuestion` set. The results from this call are then used
581
+ * as the results of the other call.
582
+ *
583
+ * When `yourself` is used, the receiver must still send a `Return` for the call, but sets the
584
+ * field `resultsSentElsewhere` in that `Return` rather than including the results.
585
+ *
586
+ * This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up
587
+ * returning the result of a call from Vat B back to Vat A.
588
+ *
589
+ * In particular, the most common use case for this feature is when Vat A makes a call to a
590
+ * promise in Vat B, and then that promise ends up resolving to a capability back in Vat A.
591
+ * Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself`
592
+ * in the calls so that the results need not pass back through Vat B.
593
+ *
594
+ * For example:
595
+ * - Alice, in Vat A, calls foo() on Bob in Vat B.
596
+ * - Alice makes a pipelined call bar() on the promise returned by foo().
597
+ * - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next
598
+ * to Alice).
599
+ * - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'().
600
+ * Notice that bar() and bar'() are travelling in opposite directions on the same network
601
+ * link.
602
+ * - The `Call` for bar'() has `sendResultsTo` set to `yourself`.
603
+ * - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results,
604
+ * with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return,
605
+ * as doing so would introduce unnecessary round trip latency.
606
+ * - Vat A receives bar'() and delivers it to Carol.
607
+ * - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere`
608
+ * set in place of results.
609
+ * - Vat A sends a `Finish` for the bar() call to Vat B.
610
+ * - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'().
611
+ *
612
+ */
613
+ readonly YOURSELF: 1;
614
+ /**
615
+ * **(level 3)**
616
+ *
617
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
618
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
619
+ * to it, rather than to the sender of the `Call`.
620
+ *
621
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
622
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
623
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
624
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
625
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
626
+ *
627
+ */
628
+ readonly THIRD_PARTY: 2;
629
+ };
630
+ export type Call_SendResultsTo_Which = (typeof Call_SendResultsTo_Which)[keyof typeof Call_SendResultsTo_Which];
631
+ declare class Call_SendResultsTo extends Struct {
632
+ static readonly CALLER: 0;
633
+ static readonly YOURSELF: 1;
634
+ static readonly THIRD_PARTY: 2;
635
+ static readonly _capnp: {
636
+ displayName: string;
637
+ id: string;
638
+ size: ObjectSize;
639
+ };
640
+ get _isCaller(): boolean;
641
+ set caller(_: true);
642
+ get _isYourself(): boolean;
643
+ set yourself(_: true);
644
+ _adoptThirdParty(value: Orphan<Pointer>): void;
645
+ _disownThirdParty(): Orphan<Pointer>;
646
+ /**
647
+ * **(level 3)**
648
+ *
649
+ * The call's result should be returned to a different vat. The receiver (the callee) expects
650
+ * to receive an `Accept` message from the indicated vat, and should return the call's result
651
+ * to it, rather than to the sender of the `Call`.
652
+ *
653
+ * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call`
654
+ * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from
655
+ * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends
656
+ * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C
657
+ * also sends a `Return` to Vat B with `resultsSentElsewhere`.
658
+ *
659
+ */
660
+ get thirdParty(): Pointer;
661
+ _hasThirdParty(): boolean;
662
+ get _isThirdParty(): boolean;
663
+ set thirdParty(value: Pointer);
664
+ toString(): string;
665
+ which(): Call_SendResultsTo_Which;
666
+ }
667
+ declare class Call$1 extends Struct {
668
+ static readonly _capnp: {
669
+ displayName: string;
670
+ id: string;
671
+ size: ObjectSize;
672
+ defaultAllowThirdPartyTailCall: DataView<ArrayBufferLike>;
673
+ defaultNoPromisePipelining: DataView<ArrayBufferLike>;
674
+ defaultOnlyPromisePipeline: DataView<ArrayBufferLike>;
675
+ };
676
+ /**
677
+ * A number, chosen by the caller, that identifies this call in future messages. This number
678
+ * must be different from all other calls originating from the same end of the connection (but
679
+ * may overlap with question IDs originating from the opposite end). A fine strategy is to use
680
+ * sequential question IDs, but the recipient should not assume this.
681
+ *
682
+ * A question ID can be reused once both:
683
+ * - A matching Return has been received from the callee.
684
+ * - A matching Finish has been sent from the caller.
685
+ *
686
+ */
687
+ get questionId(): number;
688
+ set questionId(value: number);
689
+ _adoptTarget(value: Orphan<MessageTarget>): void;
690
+ _disownTarget(): Orphan<MessageTarget>;
691
+ /**
692
+ * The object that should receive this call.
693
+ *
694
+ */
695
+ get target(): MessageTarget;
696
+ _hasTarget(): boolean;
697
+ _initTarget(): MessageTarget;
698
+ set target(value: MessageTarget);
699
+ /**
700
+ * The type ID of the interface being called. Each capability may implement multiple interfaces.
701
+ *
702
+ */
703
+ get interfaceId(): bigint;
704
+ set interfaceId(value: bigint);
705
+ /**
706
+ * The ordinal number of the method to call within the requested interface.
707
+ *
708
+ */
709
+ get methodId(): number;
710
+ set methodId(value: number);
711
+ /**
712
+ * Indicates whether or not the receiver is allowed to send a `Return` containing
713
+ * `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee
714
+ * will have to proxy the return in the case of a tail call to a third-party vat.
715
+ *
716
+ */
717
+ get allowThirdPartyTailCall(): boolean;
718
+ set allowThirdPartyTailCall(value: boolean);
719
+ /**
720
+ * If true, the sender promises that it won't make any promise-pipelined calls on the results of
721
+ * this call. If it breaks this promise, the receiver may throw an arbitrary error from such
722
+ * calls.
723
+ *
724
+ * The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining
725
+ * when no pipelined calls are expected. The sender typically sets this to false when the method's
726
+ * schema does not specify any return capabilities.
727
+ *
728
+ */
729
+ get noPromisePipelining(): boolean;
730
+ set noPromisePipelining(value: boolean);
731
+ /**
732
+ * If true, the sender only plans to use this call to make pipelined calls. The receiver need not
733
+ * send a `Return` message (but is still allowed to do so).
734
+ *
735
+ * Since the sender does not know whether a `Return` will be sent, it must release all state
736
+ * related to the call when it sends `Finish`. However, in the case that the callee does not
737
+ * recognize this hint and chooses to send a `Return`, then technically the caller is not allowed
738
+ * to reuse the question ID until it receives said `Return`. This creates a conundrum: How does
739
+ * the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation
740
+ * uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the
741
+ * IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the
742
+ * implementation assumes that the other end is in fact honoring the hint, and the ID counter is
743
+ * allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then
744
+ * the implementation stops using this hint.
745
+ *
746
+ */
747
+ get onlyPromisePipeline(): boolean;
748
+ set onlyPromisePipeline(value: boolean);
749
+ _adoptParams(value: Orphan<Payload>): void;
750
+ _disownParams(): Orphan<Payload>;
751
+ /**
752
+ * The call parameters. `params.content` is a struct whose fields correspond to the parameters of
753
+ * the method.
754
+ *
755
+ */
756
+ get params(): Payload;
757
+ _hasParams(): boolean;
758
+ _initParams(): Payload;
759
+ set params(value: Payload);
760
+ /**
761
+ * Where should the return message be sent?
762
+ *
763
+ */
764
+ get sendResultsTo(): Call_SendResultsTo;
765
+ _initSendResultsTo(): Call_SendResultsTo;
766
+ toString(): string;
767
+ }
768
+ declare const Return_Which: {
769
+ /**
770
+ * Equal to the QuestionId of the corresponding `Call` message.
771
+ *
772
+ */
773
+ readonly RESULTS: 0;
774
+ /**
775
+ * If true, all capabilities that were in the params should be considered released. The sender
776
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
777
+ * should always set this true. This defaults true because if level 0 implementations forget to
778
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
779
+ * to set it to false they'll quickly get errors.
780
+ *
781
+ * The receiver should act as if the sender had sent a release message with count=1 for each
782
+ * CapDescriptor in the original Call message.
783
+ *
784
+ */
785
+ readonly EXCEPTION: 1;
786
+ /**
787
+ * The result.
788
+ *
789
+ * For regular method calls, `results.content` points to the result struct.
790
+ *
791
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
792
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
793
+ * index 0. A `Finish` is still required in this case.
794
+ *
795
+ */
796
+ readonly CANCELED: 2;
797
+ /**
798
+ * Indicates that the call failed and explains why.
799
+ *
800
+ */
801
+ readonly RESULTS_SENT_ELSEWHERE: 3;
802
+ /**
803
+ * Indicates that the call was canceled due to the caller sending a Finish message
804
+ * before the call had completed.
805
+ *
806
+ */
807
+ readonly TAKE_FROM_OTHER_QUESTION: 4;
808
+ /**
809
+ * This is set when returning from a `Call` that had `sendResultsTo` set to something other
810
+ * than `caller`.
811
+ *
812
+ * It doesn't matter too much when this is sent, as the receiver doesn't need to do anything
813
+ * with it, but the C++ implementation appears to wait for the call to finish before sending
814
+ * this.
815
+ *
816
+ */
817
+ readonly ACCEPT_FROM_THIRD_PARTY: 5;
818
+ };
819
+ export type Return_Which = (typeof Return_Which)[keyof typeof Return_Which];
820
+ declare class Return extends Struct {
821
+ static readonly RESULTS: 0;
822
+ static readonly EXCEPTION: 1;
823
+ static readonly CANCELED: 2;
824
+ static readonly RESULTS_SENT_ELSEWHERE: 3;
825
+ static readonly TAKE_FROM_OTHER_QUESTION: 4;
826
+ static readonly ACCEPT_FROM_THIRD_PARTY: 5;
827
+ static readonly _capnp: {
828
+ displayName: string;
829
+ id: string;
830
+ size: ObjectSize;
831
+ defaultReleaseParamCaps: DataView<ArrayBufferLike>;
832
+ defaultNoFinishNeeded: DataView<ArrayBufferLike>;
833
+ };
834
+ /**
835
+ * Equal to the QuestionId of the corresponding `Call` message.
836
+ *
837
+ */
838
+ get answerId(): number;
839
+ set answerId(value: number);
840
+ /**
841
+ * If true, all capabilities that were in the params should be considered released. The sender
842
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
843
+ * should always set this true. This defaults true because if level 0 implementations forget to
844
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
845
+ * to set it to false they'll quickly get errors.
846
+ *
847
+ * The receiver should act as if the sender had sent a release message with count=1 for each
848
+ * CapDescriptor in the original Call message.
849
+ *
850
+ */
851
+ get releaseParamCaps(): boolean;
852
+ set releaseParamCaps(value: boolean);
853
+ /**
854
+ * If true, the sender does not need the receiver to send a `Finish` message; its answer table
855
+ * entry has already been cleaned up. This implies that the results do not contain any
856
+ * capabilities, since the `Finish` message would normally release those capabilities from
857
+ * promise pipelining responsibility. The caller may still send a `Finish` message if it wants,
858
+ * which will be silently ignored by the callee.
859
+ *
860
+ */
861
+ get noFinishNeeded(): boolean;
862
+ set noFinishNeeded(value: boolean);
863
+ _adoptResults(value: Orphan<Payload>): void;
864
+ _disownResults(): Orphan<Payload>;
865
+ /**
866
+ * The result.
867
+ *
868
+ * For regular method calls, `results.content` points to the result struct.
869
+ *
870
+ * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single
871
+ * capability (rather than a struct), and `results.content` is just a capability pointer with
872
+ * index 0. A `Finish` is still required in this case.
873
+ *
874
+ */
875
+ get results(): Payload;
876
+ _hasResults(): boolean;
877
+ _initResults(): Payload;
878
+ get _isResults(): boolean;
879
+ set results(value: Payload);
880
+ _adoptException(value: Orphan<Exception>): void;
881
+ _disownException(): Orphan<Exception>;
882
+ /**
883
+ * Indicates that the call failed and explains why.
884
+ *
885
+ */
886
+ get exception(): Exception;
887
+ _hasException(): boolean;
888
+ _initException(): Exception;
889
+ get _isException(): boolean;
890
+ set exception(value: Exception);
891
+ get _isCanceled(): boolean;
892
+ set canceled(_: true);
893
+ get _isResultsSentElsewhere(): boolean;
894
+ set resultsSentElsewhere(_: true);
895
+ /**
896
+ * The sender has also sent (before this message) a `Call` with the given question ID and with
897
+ * `sendResultsTo.yourself` set, and the results of that other call should be used as the
898
+ * results here. `takeFromOtherQuestion` can only used once per question.
899
+ *
900
+ */
901
+ get takeFromOtherQuestion(): number;
902
+ get _isTakeFromOtherQuestion(): boolean;
903
+ set takeFromOtherQuestion(value: number);
904
+ _adoptAcceptFromThirdParty(value: Orphan<Pointer>): void;
905
+ _disownAcceptFromThirdParty(): Orphan<Pointer>;
906
+ /**
907
+ * **(level 3)**
908
+ *
909
+ * The caller should contact a third-party vat to pick up the results. An `Accept` message
910
+ * sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`.
911
+ * It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set.
912
+ *
913
+ */
914
+ get acceptFromThirdParty(): Pointer;
915
+ _hasAcceptFromThirdParty(): boolean;
916
+ get _isAcceptFromThirdParty(): boolean;
917
+ set acceptFromThirdParty(value: Pointer);
918
+ toString(): string;
919
+ which(): Return_Which;
920
+ }
921
+ declare class Finish extends Struct {
922
+ static readonly _capnp: {
923
+ displayName: string;
924
+ id: string;
925
+ size: ObjectSize;
926
+ defaultReleaseResultCaps: DataView<ArrayBufferLike>;
927
+ defaultRequireEarlyCancellationWorkaround: DataView<ArrayBufferLike>;
928
+ };
929
+ /**
930
+ * ID of the call whose result is to be released.
931
+ *
932
+ */
933
+ get questionId(): number;
934
+ set questionId(value: number);
935
+ /**
936
+ * If true, all capabilities that were in the results should be considered released. The sender
937
+ * must not send separate `Release` messages for them. Level 0 implementations in particular
938
+ * should always set this true. This defaults true because if level 0 implementations forget to
939
+ * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget
940
+ * set it false they'll quickly get errors.
941
+ *
942
+ */
943
+ get releaseResultCaps(): boolean;
944
+ set releaseResultCaps(value: boolean);
945
+ /**
946
+ * If true, if the RPC system receives this Finish message before the original call has even been
947
+ * delivered, it should defer cancellation util after delivery. In particular, this gives the
948
+ * destination object a chance to opt out of cancellation, e.g. as controlled by the
949
+ * `allowCancellation` annotation defined in `c++.capnp`.
950
+ *
951
+ * This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However,
952
+ * older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and
953
+ * as a result programs built with older versions could be inadvertently relying on their peers
954
+ * to implement the behavior. The purpose of this flag is to let newer versions know when the
955
+ * peer is an older version, so that it can attempt to work around the issue.
956
+ *
957
+ * See also comments in handleFinish() in rpc.c++ for more details.
958
+ *
959
+ */
960
+ get requireEarlyCancellationWorkaround(): boolean;
961
+ set requireEarlyCancellationWorkaround(value: boolean);
962
+ toString(): string;
963
+ }
964
+ declare const Resolve_Which: {
965
+ /**
966
+ * The ID of the promise to be resolved.
967
+ *
968
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
969
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
970
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
971
+ * `ExportId` again until it has been released and recycled.
972
+ *
973
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
974
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
975
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
976
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
977
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
978
+ * this later promise does _not_ correspond to the earlier `Resolve`.
979
+ *
980
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
981
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
982
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
983
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
984
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
985
+ * receiver should simply release the capability to which the promise resolved.
986
+ *
987
+ */
988
+ readonly CAP: 0;
989
+ /**
990
+ * The object to which the promise resolved.
991
+ *
992
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
993
+ * simply forward all messages to the capability designated by `cap`. This is true even if
994
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
995
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
996
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
997
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
998
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
999
+ * if that object is itself a promise.
1000
+ *
1001
+ */
1002
+ readonly EXCEPTION: 1;
1003
+ };
1004
+ export type Resolve_Which = (typeof Resolve_Which)[keyof typeof Resolve_Which];
1005
+ declare class Resolve extends Struct {
1006
+ static readonly CAP: 0;
1007
+ static readonly EXCEPTION: 1;
1008
+ static readonly _capnp: {
1009
+ displayName: string;
1010
+ id: string;
1011
+ size: ObjectSize;
1012
+ };
1013
+ /**
1014
+ * The ID of the promise to be resolved.
1015
+ *
1016
+ * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does
1017
+ * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver
1018
+ * will release the export soon after receiving `Resolve`, and the sender will not send this
1019
+ * `ExportId` again until it has been released and recycled.
1020
+ *
1021
+ * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise,
1022
+ * this indicates that the sender will follow up at some point with a `Resolve` message. If the
1023
+ * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the
1024
+ * same ID is sent again later _after_ a `Resolve`, it can only be because the export's
1025
+ * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore
1026
+ * this later promise does _not_ correspond to the earlier `Resolve`.
1027
+ *
1028
+ * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve`
1029
+ * message may or may not still be sent (the `Resolve` may have already been in-flight when
1030
+ * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer
1031
+ * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which
1032
+ * the receiver has no knowledge, because it already released it earlier. In this case, the
1033
+ * receiver should simply release the capability to which the promise resolved.
1034
+ *
1035
+ */
1036
+ get promiseId(): number;
1037
+ set promiseId(value: number);
1038
+ _adoptCap(value: Orphan<CapDescriptor>): void;
1039
+ _disownCap(): Orphan<CapDescriptor>;
1040
+ /**
1041
+ * The object to which the promise resolved.
1042
+ *
1043
+ * The sender promises that from this point forth, until `promiseId` is released, it shall
1044
+ * simply forward all messages to the capability designated by `cap`. This is true even if
1045
+ * `cap` itself happens to designate another promise, and that other promise later resolves --
1046
+ * messages sent to `promiseId` shall still go to that other promise, not to its resolution.
1047
+ * This is important in the case that the receiver of the `Resolve` ends up sending a
1048
+ * `Disembargo` message towards `promiseId` in order to control message ordering -- that
1049
+ * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even
1050
+ * if that object is itself a promise.
1051
+ *
1052
+ */
1053
+ get cap(): CapDescriptor;
1054
+ _hasCap(): boolean;
1055
+ _initCap(): CapDescriptor;
1056
+ get _isCap(): boolean;
1057
+ set cap(value: CapDescriptor);
1058
+ _adoptException(value: Orphan<Exception>): void;
1059
+ _disownException(): Orphan<Exception>;
1060
+ /**
1061
+ * Indicates that the promise was broken.
1062
+ *
1063
+ */
1064
+ get exception(): Exception;
1065
+ _hasException(): boolean;
1066
+ _initException(): Exception;
1067
+ get _isException(): boolean;
1068
+ set exception(value: Exception);
1069
+ toString(): string;
1070
+ which(): Resolve_Which;
1071
+ }
1072
+ declare class Release extends Struct {
1073
+ static readonly _capnp: {
1074
+ displayName: string;
1075
+ id: string;
1076
+ size: ObjectSize;
1077
+ };
1078
+ /**
1079
+ * What to release.
1080
+ *
1081
+ */
1082
+ get id(): number;
1083
+ set id(value: number);
1084
+ /**
1085
+ * The amount by which to decrement the reference count. The export is only actually released
1086
+ * when the reference count reaches zero.
1087
+ *
1088
+ */
1089
+ get referenceCount(): number;
1090
+ set referenceCount(value: number);
1091
+ toString(): string;
1092
+ }
1093
+ declare const Disembargo_Context_Which: {
1094
+ /**
1095
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1096
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1097
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1098
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1099
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1100
+ * the value is unambiguous.
1101
+ *
1102
+ * The receiver must verify that the target capability actually resolves back to the sender's
1103
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1104
+ *
1105
+ */
1106
+ readonly SENDER_LOOPBACK: 0;
1107
+ /**
1108
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1109
+ * this capability, and that Disembargo is now being echoed back.
1110
+ *
1111
+ */
1112
+ readonly RECEIVER_LOOPBACK: 1;
1113
+ /**
1114
+ * **(level 3)**
1115
+ *
1116
+ * The sender is requesting a disembargo on a promise that is known to resolve to a third-party
1117
+ * capability that the sender is currently in the process of accepting (using `Accept`).
1118
+ * The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The
1119
+ * receiver should now send a `Disembargo` with `provide` set to the question ID of that
1120
+ * `Provide` message.
1121
+ *
1122
+ * See `Accept.embargo` for an example.
1123
+ *
1124
+ */
1125
+ readonly ACCEPT: 2;
1126
+ /**
1127
+ * **(level 3)**
1128
+ *
1129
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1130
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1131
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1132
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1133
+ * an example.
1134
+ *
1135
+ */
1136
+ readonly PROVIDE: 3;
1137
+ };
1138
+ export type Disembargo_Context_Which = (typeof Disembargo_Context_Which)[keyof typeof Disembargo_Context_Which];
1139
+ declare class Disembargo_Context extends Struct {
1140
+ static readonly SENDER_LOOPBACK: 0;
1141
+ static readonly RECEIVER_LOOPBACK: 1;
1142
+ static readonly ACCEPT: 2;
1143
+ static readonly PROVIDE: 3;
1144
+ static readonly _capnp: {
1145
+ displayName: string;
1146
+ id: string;
1147
+ size: ObjectSize;
1148
+ };
1149
+ /**
1150
+ * The sender is requesting a disembargo on a promise that is known to resolve back to a
1151
+ * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls
1152
+ * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback`
1153
+ * set to the same value as `senderLoopback`. This value is chosen by the sender, and since
1154
+ * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure
1155
+ * the value is unambiguous.
1156
+ *
1157
+ * The receiver must verify that the target capability actually resolves back to the sender's
1158
+ * vat. Otherwise, the sender has committed a protocol error and should be disconnected.
1159
+ *
1160
+ */
1161
+ get senderLoopback(): number;
1162
+ get _isSenderLoopback(): boolean;
1163
+ set senderLoopback(value: number);
1164
+ /**
1165
+ * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to
1166
+ * this capability, and that Disembargo is now being echoed back.
1167
+ *
1168
+ */
1169
+ get receiverLoopback(): number;
1170
+ get _isReceiverLoopback(): boolean;
1171
+ set receiverLoopback(value: number);
1172
+ get _isAccept(): boolean;
1173
+ set accept(_: true);
1174
+ /**
1175
+ * **(level 3)**
1176
+ *
1177
+ * The sender is requesting a disembargo on a capability currently being provided to a third
1178
+ * party. The question ID identifies the `Provide` message previously sent by the sender to
1179
+ * this capability. On receipt, the receiver (the capability host) shall release the embargo
1180
+ * on the `Accept` message that it has received from the third party. See `Accept.embargo` for
1181
+ * an example.
1182
+ *
1183
+ */
1184
+ get provide(): number;
1185
+ get _isProvide(): boolean;
1186
+ set provide(value: number);
1187
+ toString(): string;
1188
+ which(): Disembargo_Context_Which;
1189
+ }
1190
+ declare class Disembargo extends Struct {
1191
+ static readonly _capnp: {
1192
+ displayName: string;
1193
+ id: string;
1194
+ size: ObjectSize;
1195
+ };
1196
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1197
+ _disownTarget(): Orphan<MessageTarget>;
1198
+ /**
1199
+ * What is to be disembargoed.
1200
+ *
1201
+ */
1202
+ get target(): MessageTarget;
1203
+ _hasTarget(): boolean;
1204
+ _initTarget(): MessageTarget;
1205
+ set target(value: MessageTarget);
1206
+ get context(): Disembargo_Context;
1207
+ _initContext(): Disembargo_Context;
1208
+ toString(): string;
1209
+ }
1210
+ declare class Provide extends Struct {
1211
+ static readonly _capnp: {
1212
+ displayName: string;
1213
+ id: string;
1214
+ size: ObjectSize;
1215
+ };
1216
+ /**
1217
+ * Question ID to be held open until the recipient has received the capability. A result will be
1218
+ * returned once the third party has successfully received the capability. The sender must at some
1219
+ * point send a `Finish` message as with any other call, and that message can be used to cancel the
1220
+ * whole operation.
1221
+ *
1222
+ */
1223
+ get questionId(): number;
1224
+ set questionId(value: number);
1225
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1226
+ _disownTarget(): Orphan<MessageTarget>;
1227
+ /**
1228
+ * What is to be provided to the third party.
1229
+ *
1230
+ */
1231
+ get target(): MessageTarget;
1232
+ _hasTarget(): boolean;
1233
+ _initTarget(): MessageTarget;
1234
+ set target(value: MessageTarget);
1235
+ _adoptRecipient(value: Orphan<Pointer>): void;
1236
+ _disownRecipient(): Orphan<Pointer>;
1237
+ /**
1238
+ * Identity of the third party that is expected to pick up the capability.
1239
+ *
1240
+ */
1241
+ get recipient(): Pointer;
1242
+ _hasRecipient(): boolean;
1243
+ set recipient(value: Pointer);
1244
+ toString(): string;
1245
+ }
1246
+ declare class Accept extends Struct {
1247
+ static readonly _capnp: {
1248
+ displayName: string;
1249
+ id: string;
1250
+ size: ObjectSize;
1251
+ };
1252
+ /**
1253
+ * A new question ID identifying this accept message, which will eventually receive a Return
1254
+ * message containing the provided capability (or the call result in the case of a redirected
1255
+ * return).
1256
+ *
1257
+ */
1258
+ get questionId(): number;
1259
+ set questionId(value: number);
1260
+ _adoptProvision(value: Orphan<Pointer>): void;
1261
+ _disownProvision(): Orphan<Pointer>;
1262
+ /**
1263
+ * Identifies the provided object to be picked up.
1264
+ *
1265
+ */
1266
+ get provision(): Pointer;
1267
+ _hasProvision(): boolean;
1268
+ set provision(value: Pointer);
1269
+ /**
1270
+ * If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent,
1271
+ * and any pipelined calls will not be delivered, until the embargo is released. The receiver
1272
+ * (the capability host) will expect the provider (the vat that sent the `Provide` message) to
1273
+ * eventually send a `Disembargo` message with the field `context.provide` set to the question ID
1274
+ * of the original `Provide` message. At that point, the embargo is released and the queued
1275
+ * messages are delivered.
1276
+ *
1277
+ * For example:
1278
+ * - Alice, in Vat A, holds a promise P, which currently points toward Vat B.
1279
+ * - Alice calls foo() on P. The `Call` message is sent to Vat B.
1280
+ * - The promise P in Vat B ends up resolving to Carol, in Vat C.
1281
+ * - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient.
1282
+ * - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a
1283
+ * `ThirdPartyCapId` identifying Carol in Vat C.
1284
+ * - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that
1285
+ * it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept`
1286
+ * message.
1287
+ * - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set.
1288
+ * - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't
1289
+ * know anything about the mechanics of promise resolution happening under the hood, but she
1290
+ * expects that bar() will be delivered after foo() because that is the order in which she
1291
+ * initiated the calls.
1292
+ * - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which
1293
+ * hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability
1294
+ * are embargoed, Vat C does not deliver the call yet.
1295
+ * - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C.
1296
+ * - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the
1297
+ * question ID of the `Provide` message it had sent previously.
1298
+ * - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo()
1299
+ * before delivering bar().
1300
+ * - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from
1301
+ * Vat A, as well as deliver bar().
1302
+ *
1303
+ */
1304
+ get embargo(): boolean;
1305
+ set embargo(value: boolean);
1306
+ toString(): string;
1307
+ }
1308
+ declare class Join extends Struct {
1309
+ static readonly _capnp: {
1310
+ displayName: string;
1311
+ id: string;
1312
+ size: ObjectSize;
1313
+ };
1314
+ /**
1315
+ * Question ID used to respond to this Join. (Note that this ID only identifies one part of the
1316
+ * request for one hop; each part has a different ID and relayed copies of the request have
1317
+ * (probably) different IDs still.)
1318
+ *
1319
+ * The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult`
1320
+ * is relayed from the joined object's host, possibly with transformation applied as needed
1321
+ * by the network.
1322
+ *
1323
+ * Like any return, the result must be released using a `Finish`. However, this release
1324
+ * should not occur until the joiner has either successfully connected to the joined object.
1325
+ * Vats relaying a `Join` message similarly must not release the result they receive until the
1326
+ * return they relayed back towards the joiner has itself been released. This allows the
1327
+ * joined object's host to detect when the Join operation is canceled before completing -- if
1328
+ * it receives a `Finish` for one of the join results before the joiner successfully
1329
+ * connects. It can then free any resources it had allocated as part of the join.
1330
+ *
1331
+ */
1332
+ get questionId(): number;
1333
+ set questionId(value: number);
1334
+ _adoptTarget(value: Orphan<MessageTarget>): void;
1335
+ _disownTarget(): Orphan<MessageTarget>;
1336
+ /**
1337
+ * The capability to join.
1338
+ *
1339
+ */
1340
+ get target(): MessageTarget;
1341
+ _hasTarget(): boolean;
1342
+ _initTarget(): MessageTarget;
1343
+ set target(value: MessageTarget);
1344
+ _adoptKeyPart(value: Orphan<Pointer>): void;
1345
+ _disownKeyPart(): Orphan<Pointer>;
1346
+ /**
1347
+ * A part of the join key. These combine to form the complete join key, which is used to establish
1348
+ * a direct connection.
1349
+ *
1350
+ */
1351
+ get keyPart(): Pointer;
1352
+ _hasKeyPart(): boolean;
1353
+ set keyPart(value: Pointer);
1354
+ toString(): string;
1355
+ }
1356
+ declare const MessageTarget_Which: {
1357
+ /**
1358
+ * This message is to a capability or promise previously imported by the caller (exported by
1359
+ * the receiver).
1360
+ *
1361
+ */
1362
+ readonly IMPORTED_CAP: 0;
1363
+ /**
1364
+ * This message is to a capability that is expected to be returned by another call that has not
1365
+ * yet been completed.
1366
+ *
1367
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1368
+ * that initial startup doesn't require a round trip.
1369
+ *
1370
+ */
1371
+ readonly PROMISED_ANSWER: 1;
1372
+ };
1373
+ export type MessageTarget_Which = (typeof MessageTarget_Which)[keyof typeof MessageTarget_Which];
1374
+ declare class MessageTarget extends Struct {
1375
+ static readonly IMPORTED_CAP: 0;
1376
+ static readonly PROMISED_ANSWER: 1;
1377
+ static readonly _capnp: {
1378
+ displayName: string;
1379
+ id: string;
1380
+ size: ObjectSize;
1381
+ };
1382
+ /**
1383
+ * This message is to a capability or promise previously imported by the caller (exported by
1384
+ * the receiver).
1385
+ *
1386
+ */
1387
+ get importedCap(): number;
1388
+ get _isImportedCap(): boolean;
1389
+ set importedCap(value: number);
1390
+ _adoptPromisedAnswer(value: Orphan<PromisedAnswer>): void;
1391
+ _disownPromisedAnswer(): Orphan<PromisedAnswer>;
1392
+ /**
1393
+ * This message is to a capability that is expected to be returned by another call that has not
1394
+ * yet been completed.
1395
+ *
1396
+ * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so
1397
+ * that initial startup doesn't require a round trip.
1398
+ *
1399
+ */
1400
+ get promisedAnswer(): PromisedAnswer;
1401
+ _hasPromisedAnswer(): boolean;
1402
+ _initPromisedAnswer(): PromisedAnswer;
1403
+ get _isPromisedAnswer(): boolean;
1404
+ set promisedAnswer(value: PromisedAnswer);
1405
+ toString(): string;
1406
+ which(): MessageTarget_Which;
1407
+ }
1408
+ declare class Payload extends Struct {
1409
+ static readonly _capnp: {
1410
+ displayName: string;
1411
+ id: string;
1412
+ size: ObjectSize;
1413
+ };
1414
+ static _CapTable: ListCtor<CapDescriptor>;
1415
+ _adoptContent(value: Orphan<Pointer>): void;
1416
+ _disownContent(): Orphan<Pointer>;
1417
+ /**
1418
+ * Some Cap'n Proto data structure. Capability pointers embedded in this structure index into
1419
+ * `capTable`.
1420
+ *
1421
+ */
1422
+ get content(): Pointer;
1423
+ _hasContent(): boolean;
1424
+ set content(value: Pointer);
1425
+ _adoptCapTable(value: Orphan<List<CapDescriptor>>): void;
1426
+ _disownCapTable(): Orphan<List<CapDescriptor>>;
1427
+ /**
1428
+ * Descriptors corresponding to the cap pointers in `content`.
1429
+ *
1430
+ */
1431
+ get capTable(): List<CapDescriptor>;
1432
+ _hasCapTable(): boolean;
1433
+ _initCapTable(length: number): List<CapDescriptor>;
1434
+ set capTable(value: List<CapDescriptor>);
1435
+ toString(): string;
1436
+ }
1437
+ declare const CapDescriptor_Which: {
1438
+ /**
1439
+ * There is no capability here. This `CapDescriptor` should not appear in the payload content.
1440
+ * A `none` CapDescriptor can be generated when an application inserts a capability into a
1441
+ * message and then later changes its mind and removes it -- rewriting all of the other
1442
+ * capability pointers may be hard, so instead a tombstone is left, similar to the way a removed
1443
+ * struct or list instance is zeroed out of the message but the space is not reclaimed.
1444
+ * Hopefully this is unusual.
1445
+ *
1446
+ */
1447
+ readonly NONE: 0;
1448
+ /**
1449
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
1450
+ * newly allocated table entry, or an existing entry (increments the reference count).
1451
+ *
1452
+ */
1453
+ readonly SENDER_HOSTED: 1;
1454
+ /**
1455
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
1456
+ * message at a future point in time to replace this promise. Note that even if the same
1457
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
1458
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
1459
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
1460
+ *
1461
+ */
1462
+ readonly SENDER_PROMISE: 2;
1463
+ /**
1464
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
1465
+ *
1466
+ */
1467
+ readonly RECEIVER_HOSTED: 3;
1468
+ /**
1469
+ * A capability expected to be returned in the results of a currently-outstanding call posed
1470
+ * by the sender.
1471
+ *
1472
+ */
1473
+ readonly RECEIVER_ANSWER: 4;
1474
+ /**
1475
+ * **(level 3)**
1476
+ *
1477
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
1478
+ * to form a direct connection to a third party to pick up the capability.
1479
+ *
1480
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
1481
+ * `vine` instead.
1482
+ *
1483
+ */
1484
+ readonly THIRD_PARTY_HOSTED: 5;
1485
+ };
1486
+ export type CapDescriptor_Which = (typeof CapDescriptor_Which)[keyof typeof CapDescriptor_Which];
1487
+ declare class CapDescriptor extends Struct {
1488
+ static readonly NONE: 0;
1489
+ static readonly SENDER_HOSTED: 1;
1490
+ static readonly SENDER_PROMISE: 2;
1491
+ static readonly RECEIVER_HOSTED: 3;
1492
+ static readonly RECEIVER_ANSWER: 4;
1493
+ static readonly THIRD_PARTY_HOSTED: 5;
1494
+ static readonly _capnp: {
1495
+ displayName: string;
1496
+ id: string;
1497
+ size: ObjectSize;
1498
+ defaultAttachedFd: DataView<ArrayBufferLike>;
1499
+ };
1500
+ get _isNone(): boolean;
1501
+ set none(_: true);
1502
+ /**
1503
+ * The ID of a capability in the sender's export table (receiver's import table). It may be a
1504
+ * newly allocated table entry, or an existing entry (increments the reference count).
1505
+ *
1506
+ */
1507
+ get senderHosted(): number;
1508
+ get _isSenderHosted(): boolean;
1509
+ set senderHosted(value: number);
1510
+ /**
1511
+ * A promise that the sender will resolve later. The sender will send exactly one Resolve
1512
+ * message at a future point in time to replace this promise. Note that even if the same
1513
+ * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of
1514
+ * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this
1515
+ * `CapDescriptor`) may choose not to send the `Resolve` at all.
1516
+ *
1517
+ */
1518
+ get senderPromise(): number;
1519
+ get _isSenderPromise(): boolean;
1520
+ set senderPromise(value: number);
1521
+ /**
1522
+ * A capability (or promise) previously exported by the receiver (imported by the sender).
1523
+ *
1524
+ */
1525
+ get receiverHosted(): number;
1526
+ get _isReceiverHosted(): boolean;
1527
+ set receiverHosted(value: number);
1528
+ _adoptReceiverAnswer(value: Orphan<PromisedAnswer>): void;
1529
+ _disownReceiverAnswer(): Orphan<PromisedAnswer>;
1530
+ /**
1531
+ * A capability expected to be returned in the results of a currently-outstanding call posed
1532
+ * by the sender.
1533
+ *
1534
+ */
1535
+ get receiverAnswer(): PromisedAnswer;
1536
+ _hasReceiverAnswer(): boolean;
1537
+ _initReceiverAnswer(): PromisedAnswer;
1538
+ get _isReceiverAnswer(): boolean;
1539
+ set receiverAnswer(value: PromisedAnswer);
1540
+ _adoptThirdPartyHosted(value: Orphan<ThirdPartyCapDescriptor>): void;
1541
+ _disownThirdPartyHosted(): Orphan<ThirdPartyCapDescriptor>;
1542
+ /**
1543
+ * **(level 3)**
1544
+ *
1545
+ * A capability that lives in neither the sender's nor the receiver's vat. The sender needs
1546
+ * to form a direct connection to a third party to pick up the capability.
1547
+ *
1548
+ * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its
1549
+ * `vine` instead.
1550
+ *
1551
+ */
1552
+ get thirdPartyHosted(): ThirdPartyCapDescriptor;
1553
+ _hasThirdPartyHosted(): boolean;
1554
+ _initThirdPartyHosted(): ThirdPartyCapDescriptor;
1555
+ get _isThirdPartyHosted(): boolean;
1556
+ set thirdPartyHosted(value: ThirdPartyCapDescriptor);
1557
+ /**
1558
+ * If the RPC message in which this CapDescriptor was delivered also had file descriptors
1559
+ * attached, and `fd` is a valid index into the list of attached file descriptors, then
1560
+ * that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds
1561
+ * for said list, then no FD is attached.
1562
+ *
1563
+ * For example, if the RPC message arrived over a Unix socket, then file descriptors may be
1564
+ * attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the
1565
+ * raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS
1566
+ * whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the
1567
+ * receiver knows how to receive them, because the operating system will automatically discard
1568
+ * ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including
1569
+ * automatically closing any FDs.
1570
+ *
1571
+ * It is up to the application protocol to define what capabilities are expected to have file
1572
+ * descriptors attached, and what those FDs mean. But, for example, an application could use this
1573
+ * to open a file on disk and then transmit the open file descriptor to a sandboxed process that
1574
+ * does not otherwise have permission to access the filesystem directly. This is usually an
1575
+ * optimization: the sending process could instead provide an RPC interface supporting all the
1576
+ * operations needed (such as reading and writing a file), but by passing the file descriptor
1577
+ * directly, the recipient can often perform operations much more efficiently. Application
1578
+ * designers are encouraged to provide such RPC interfaces and automatically fall back to them
1579
+ * when FD passing is not available, so that the application can still work when the parties are
1580
+ * remote over a network.
1581
+ *
1582
+ * An attached FD is most often associated with a `senderHosted` descriptor. It could also make
1583
+ * sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that
1584
+ * they received from the third party, so that the receiver can start using it without first
1585
+ * interacting with the third party. This is an optional optimization -- the middleman may choose
1586
+ * not to forward capabilities, in which case the receiver will need to complete the handshake
1587
+ * with the third party directly before receiving the FD. If an implementation receives a second
1588
+ * attached FD after having already received one previously (e.g. both in a `thirdPartyHosted`
1589
+ * CapDescriptor and then later again when receiving the final capability directly from the
1590
+ * third party), the implementation should discard the later FD and stick with the original. At
1591
+ * present, there is no known reason why other capability types (e.g. `receiverHosted`) would want
1592
+ * to carry an attached FD, but we reserve the right to define a meaning for this in the future.
1593
+ *
1594
+ * Each file descriptor attached to the message must be used in no more than one CapDescriptor,
1595
+ * so that the receiver does not need to use dup() or refcounting to handle the possibility of
1596
+ * multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the
1597
+ * same FD index, then the receiver can arbitrarily choose which capability ends up having the
1598
+ * FD attached.
1599
+ *
1600
+ * To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to
1601
+ * receive in a single message to a small value. If a message happens to contain more than that,
1602
+ * the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for
1603
+ * security or implementation reasons, in which case the list may be truncated to zero. Hence,
1604
+ * `attachedFd` might point past the end of the list, which the implementation should treat as if
1605
+ * no FD was attached at all.
1606
+ *
1607
+ * The type of this field was chosen to be UInt8 because Linux supports sending only a maximum
1608
+ * of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of
1609
+ * padding left -- so after adding this, there is still one byte for a future feature.
1610
+ * Conveniently, this also means we're able to use 0xff as the default value, which will always
1611
+ * be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors
1612
+ * cannot be sent at once, rather than relying on Linux to do so).
1613
+ *
1614
+ */
1615
+ get attachedFd(): number;
1616
+ set attachedFd(value: number);
1617
+ toString(): string;
1618
+ which(): CapDescriptor_Which;
1619
+ }
1620
+ declare const PromisedAnswer_Op_Which: {
1621
+ /**
1622
+ * Does nothing. This member is mostly defined so that we can make `Op` a union even
1623
+ * though (as of this writing) only one real operation is defined.
1624
+ *
1625
+ */
1626
+ readonly NOOP: 0;
1627
+ /**
1628
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
1629
+ * a field ordinal, so that the receiver does not need to understand the schema.
1630
+ *
1631
+ */
1632
+ readonly GET_POINTER_FIELD: 1;
1633
+ };
1634
+ export type PromisedAnswer_Op_Which = (typeof PromisedAnswer_Op_Which)[keyof typeof PromisedAnswer_Op_Which];
1635
+ declare class PromisedAnswer_Op extends Struct {
1636
+ static readonly NOOP: 0;
1637
+ static readonly GET_POINTER_FIELD: 1;
1638
+ static readonly _capnp: {
1639
+ displayName: string;
1640
+ id: string;
1641
+ size: ObjectSize;
1642
+ };
1643
+ get _isNoop(): boolean;
1644
+ set noop(_: true);
1645
+ /**
1646
+ * Get a pointer field within a struct. The number is an index into the pointer section, NOT
1647
+ * a field ordinal, so that the receiver does not need to understand the schema.
1648
+ *
1649
+ */
1650
+ get getPointerField(): number;
1651
+ get _isGetPointerField(): boolean;
1652
+ set getPointerField(value: number);
1653
+ toString(): string;
1654
+ which(): PromisedAnswer_Op_Which;
1655
+ }
1656
+ declare class PromisedAnswer extends Struct {
1657
+ static readonly Op: typeof PromisedAnswer_Op;
1658
+ static readonly _capnp: {
1659
+ displayName: string;
1660
+ id: string;
1661
+ size: ObjectSize;
1662
+ };
1663
+ static _Transform: ListCtor<PromisedAnswer_Op>;
1664
+ /**
1665
+ * ID of the question (in the sender's question table / receiver's answer table) whose answer is
1666
+ * expected to contain the capability.
1667
+ *
1668
+ */
1669
+ get questionId(): number;
1670
+ set questionId(value: number);
1671
+ _adoptTransform(value: Orphan<List<PromisedAnswer_Op>>): void;
1672
+ _disownTransform(): Orphan<List<PromisedAnswer_Op>>;
1673
+ /**
1674
+ * Operations / transformations to apply to the result in order to get the capability actually
1675
+ * being addressed. E.g. if the result is a struct and you want to call a method on a capability
1676
+ * pointed to by a field of the struct, you need a `getPointerField` op.
1677
+ *
1678
+ */
1679
+ get transform(): List<PromisedAnswer_Op>;
1680
+ _hasTransform(): boolean;
1681
+ _initTransform(length: number): List<PromisedAnswer_Op>;
1682
+ set transform(value: List<PromisedAnswer_Op>);
1683
+ toString(): string;
1684
+ }
1685
+ declare class ThirdPartyCapDescriptor extends Struct {
1686
+ static readonly _capnp: {
1687
+ displayName: string;
1688
+ id: string;
1689
+ size: ObjectSize;
1690
+ };
1691
+ _adoptId(value: Orphan<Pointer>): void;
1692
+ _disownId(): Orphan<Pointer>;
1693
+ /**
1694
+ * Identifies the third-party host and the specific capability to accept from it.
1695
+ *
1696
+ */
1697
+ get id(): Pointer;
1698
+ _hasId(): boolean;
1699
+ set id(value: Pointer);
1700
+ /**
1701
+ * A proxy for the third-party object exported by the sender. In CapTP terminology this is called
1702
+ * a "vine", because it is an indirect reference to the third-party object that snakes through the
1703
+ * sender vat. This serves two purposes:
1704
+ *
1705
+ * * Level 1 and 2 implementations that don't understand how to connect to a third party may
1706
+ * simply send calls to the vine. Such calls will be forwarded to the third-party by the
1707
+ * sender.
1708
+ *
1709
+ * * Level 3 implementations must release the vine only once they have successfully picked up the
1710
+ * object from the third party. This ensures that the capability is not released by the sender
1711
+ * prematurely.
1712
+ *
1713
+ * The sender will close the `Provide` request that it has sent to the third party as soon as
1714
+ * it receives either a `Call` or a `Release` message directed at the vine.
1715
+ *
1716
+ */
1717
+ get vineId(): number;
1718
+ set vineId(value: number);
1719
+ toString(): string;
1720
+ }
1721
+ declare const Exception_Type: {
1722
+ /**
1723
+ * A generic problem occurred, and it is believed that if the operation were repeated without
1724
+ * any change in the state of the world, the problem would occur again.
1725
+ *
1726
+ * A client might respond to this error by logging it for investigation by the developer and/or
1727
+ * displaying it to the user.
1728
+ *
1729
+ */
1730
+ readonly FAILED: 0;
1731
+ /**
1732
+ * The request was rejected due to a temporary lack of resources.
1733
+ *
1734
+ * Examples include:
1735
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
1736
+ * - The server ran out of RAM or disk space during the request.
1737
+ * - The operation timed out (took significantly longer than it should have).
1738
+ *
1739
+ * A client might respond to this error by scheduling to retry the operation much later. The
1740
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
1741
+ *
1742
+ */
1743
+ readonly OVERLOADED: 1;
1744
+ /**
1745
+ * The method failed because a connection to some necessary capability was lost.
1746
+ *
1747
+ * Examples include:
1748
+ * - The client introduced the server to a third-party capability, the connection to that third
1749
+ * party was subsequently lost, and then the client requested that the server use the dead
1750
+ * capability for something.
1751
+ * - The client previously requested that the server obtain a capability from some third party.
1752
+ * The server returned a capability to an object wrapping the third-party capability. Later,
1753
+ * the server's connection to the third party was lost.
1754
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
1755
+ * no longer authorized to use the capability; it is often used simply as a way to force the
1756
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
1757
+ * get them to recognize some other change that has occurred.
1758
+ *
1759
+ * A client should normally respond to this error by releasing all capabilities it is currently
1760
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
1761
+ * repeating the method calls used to create them originally. In other words, disconnect and
1762
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
1763
+ * it lost, thus making everything work.
1764
+ *
1765
+ * If the client receives another `disconnected` error in the process of rebuilding the
1766
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
1767
+ * is currently unreliable, possibly due to load or other temporary issues.
1768
+ *
1769
+ */
1770
+ readonly DISCONNECTED: 2;
1771
+ /**
1772
+ * The server doesn't implement the requested method. If there is some other method that the
1773
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
1774
+ * Otherwise, this should be treated like `failed`.
1775
+ *
1776
+ */
1777
+ readonly UNIMPLEMENTED: 3;
1778
+ };
1779
+ export type Exception_Type = (typeof Exception_Type)[keyof typeof Exception_Type];
1780
+ declare class Exception extends Struct {
1781
+ static readonly Type: {
1782
+ /**
1783
+ * A generic problem occurred, and it is believed that if the operation were repeated without
1784
+ * any change in the state of the world, the problem would occur again.
1785
+ *
1786
+ * A client might respond to this error by logging it for investigation by the developer and/or
1787
+ * displaying it to the user.
1788
+ *
1789
+ */
1790
+ readonly FAILED: 0;
1791
+ /**
1792
+ * The request was rejected due to a temporary lack of resources.
1793
+ *
1794
+ * Examples include:
1795
+ * - There's not enough CPU time to keep up with incoming requests, so some are rejected.
1796
+ * - The server ran out of RAM or disk space during the request.
1797
+ * - The operation timed out (took significantly longer than it should have).
1798
+ *
1799
+ * A client might respond to this error by scheduling to retry the operation much later. The
1800
+ * client should NOT retry again immediately since this would likely exacerbate the problem.
1801
+ *
1802
+ */
1803
+ readonly OVERLOADED: 1;
1804
+ /**
1805
+ * The method failed because a connection to some necessary capability was lost.
1806
+ *
1807
+ * Examples include:
1808
+ * - The client introduced the server to a third-party capability, the connection to that third
1809
+ * party was subsequently lost, and then the client requested that the server use the dead
1810
+ * capability for something.
1811
+ * - The client previously requested that the server obtain a capability from some third party.
1812
+ * The server returned a capability to an object wrapping the third-party capability. Later,
1813
+ * the server's connection to the third party was lost.
1814
+ * - The capability has been revoked. Revocation does not necessarily mean that the client is
1815
+ * no longer authorized to use the capability; it is often used simply as a way to force the
1816
+ * client to repeat the setup process, perhaps to efficiently move them to a new back-end or
1817
+ * get them to recognize some other change that has occurred.
1818
+ *
1819
+ * A client should normally respond to this error by releasing all capabilities it is currently
1820
+ * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or
1821
+ * repeating the method calls used to create them originally. In other words, disconnect and
1822
+ * start over. This should in turn cause the server to obtain a new copy of the capability that
1823
+ * it lost, thus making everything work.
1824
+ *
1825
+ * If the client receives another `disconnected` error in the process of rebuilding the
1826
+ * capability and retrying the call, it should treat this as an `overloaded` error: the network
1827
+ * is currently unreliable, possibly due to load or other temporary issues.
1828
+ *
1829
+ */
1830
+ readonly DISCONNECTED: 2;
1831
+ /**
1832
+ * The server doesn't implement the requested method. If there is some other method that the
1833
+ * client could call (perhaps an older and/or slower interface), it should try that instead.
1834
+ * Otherwise, this should be treated like `failed`.
1835
+ *
1836
+ */
1837
+ readonly UNIMPLEMENTED: 3;
1838
+ };
1839
+ static readonly _capnp: {
1840
+ displayName: string;
1841
+ id: string;
1842
+ size: ObjectSize;
1843
+ };
1844
+ /**
1845
+ * Human-readable failure description.
1846
+ *
1847
+ */
1848
+ get reason(): string;
1849
+ set reason(value: string);
1850
+ /**
1851
+ * The type of the error. The purpose of this enum is not to describe the error itself, but
1852
+ * rather to describe how the client might want to respond to the error.
1853
+ *
1854
+ */
1855
+ get type(): Exception_Type;
1856
+ set type(value: Exception_Type);
1857
+ /**
1858
+ * OBSOLETE. Ignore.
1859
+ *
1860
+ */
1861
+ get obsoleteIsCallersFault(): boolean;
1862
+ set obsoleteIsCallersFault(value: boolean);
1863
+ /**
1864
+ * OBSOLETE. See `type` instead.
1865
+ *
1866
+ */
1867
+ get obsoleteDurability(): number;
1868
+ set obsoleteDurability(value: number);
1869
+ /**
1870
+ * Stack trace text from the remote server. The format is not specified. By default,
1871
+ * implementations do not provide stack traces; the application must explicitly enable them
1872
+ * when desired.
1873
+ *
1874
+ */
1875
+ get trace(): string;
1876
+ set trace(value: string);
1877
+ toString(): string;
1878
+ }
1879
+ export type CapabilityID = number;
1880
+ export interface Method<P extends Struct, R extends Struct> {
1881
+ interfaceId: bigint;
1882
+ methodId: number;
1883
+ interfaceName?: string;
1884
+ methodName?: string;
1885
+ ParamsClass: StructCtor<P>;
1886
+ ResultsClass: StructCtor<R>;
1887
+ }
1888
+ export type Call<P extends Struct, R extends Struct> = FuncCall<P, R> | DataCall<P, R>;
1889
+ export interface BaseCall<P extends Struct, R extends Struct> {
1890
+ method: Method<P, R>;
1891
+ }
1892
+ export type FuncCall<P extends Struct, R extends Struct> = BaseCall<P, R> & {
1893
+ paramsFunc?(params: P): void;
1894
+ };
1895
+ export type DataCall<P extends Struct, R extends Struct> = BaseCall<P, R> & {
1896
+ params: P;
1897
+ };
1898
+ export declare function isFuncCall<P extends Struct, R extends Struct>(call: Call<P, R>): call is FuncCall<P, R>;
1899
+ export declare function isDataCall<P extends Struct, R extends Struct>(call: Call<P, R>): call is DataCall<P, R>;
1900
+ export declare function copyCall<P extends Struct, R extends Struct>(call: Call<P, R>): DataCall<P, R>;
1901
+ export declare function placeParams<P extends Struct, R extends Struct>(call: Call<P, R>, contentPtr: Pointer | undefined): P;
1902
+ declare class IDGen {
1903
+ i: number;
1904
+ free: number[];
1905
+ next(): number;
1906
+ remove(i: number): void;
1907
+ }
1908
+ export interface PipelineOp {
1909
+ field: number;
1910
+ defaultValue?: Pointer;
1911
+ }
1912
+ export declare class Deferred<T> {
1913
+ static fromPromise<T>(p: Promise<T>): Deferred<T>;
1914
+ promise: Promise<T>;
1915
+ reject: (reason?: unknown) => void;
1916
+ resolve: (value: T | PromiseLike<T>) => void;
1917
+ constructor();
1918
+ }
1919
+ export interface ecall {
1920
+ call: Call<any, any>;
1921
+ f: Fulfiller<any>;
1922
+ }
1923
+ export interface pcall extends ecall {
1924
+ transform: PipelineOp[];
1925
+ }
1926
+ export type ecallSlot = ecall | null;
1927
+ declare class Ecalls {
1928
+ data: ecallSlot[];
1929
+ constructor(data: ecallSlot[]);
1930
+ static copyOf(data: ecallSlot[]): Ecalls;
1931
+ len(): number;
1932
+ clear(i: number): void;
1933
+ copy(): Ecalls;
1934
+ }
1935
+ declare class Fulfiller<R extends Struct> implements Answer<R> {
1936
+ resolved: boolean;
1937
+ answer?: Answer<R>;
1938
+ queue: pcall[];
1939
+ queueCap: number;
1940
+ deferred: Deferred<R>;
1941
+ fulfill(s: R): void;
1942
+ reject(err: Error): void;
1943
+ peek(): Answer<R> | undefined;
1944
+ struct(): Promise<R>;
1945
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
1946
+ pipelineClose(transform: PipelineOp[]): void;
1947
+ emptyQueue(s: Struct): Record<number, Ecalls>;
1948
+ }
1949
+ export interface Answer<R extends Struct> {
1950
+ struct(): Promise<R>;
1951
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
1952
+ pipelineClose(transform: PipelineOp[]): void;
1953
+ }
1954
+ declare class AnswerEntry<R extends Struct> {
1955
+ id: number;
1956
+ conn: Conn;
1957
+ resultCaps: number[];
1958
+ done: boolean;
1959
+ obj?: R;
1960
+ err?: Error;
1961
+ deferred: Deferred<R>;
1962
+ queue: AnswerPCall[];
1963
+ constructor(conn: Conn, id: number);
1964
+ fulfill(obj: R): void;
1965
+ reject(err: Error): void;
1966
+ emptyQueue(obj: R): [
1967
+ {
1968
+ [key: number]: AnswerQCall[];
1969
+ },
1970
+ Error | undefined
1971
+ ];
1972
+ queueCall<P extends Struct, R extends Struct>(call: Call<P, R>, transform: PipelineOp[], a: AnswerEntry<R>): void;
1973
+ }
1974
+ export type AnswerQCall = QCallRemoteCall | QCallLocalCall | QCallDisembargo;
1975
+ export interface QCallRemoteCall {
1976
+ call: Call<any, any>;
1977
+ a: AnswerEntry<any>;
1978
+ }
1979
+ export interface QCallLocalCall {
1980
+ call: Call<any, any>;
1981
+ f: Fulfiller<any>;
1982
+ }
1983
+ export interface QCallDisembargo {
1984
+ embargoID: number;
1985
+ embargoTarget: MessageTarget;
1986
+ }
1987
+ export interface AnswerPCall {
1988
+ qcall: AnswerQCall;
1989
+ transform: PipelineOp[];
1990
+ }
1991
+ export type Finalize = (obj: unknown, finalizer: Finalizer) => void;
1992
+ export type Finalizer = () => void;
1993
+ declare class Ref implements Client {
1994
+ rc: RefCount;
1995
+ closeState: {
1996
+ closed: boolean;
1997
+ };
1998
+ constructor(rc: RefCount, finalize: Finalize);
1999
+ call<P extends Struct, R extends Struct>(cl: Call<P, R>): Answer<R>;
2000
+ client(): Client;
2001
+ close(): void;
2002
+ }
2003
+ declare class RefCount implements Client {
2004
+ refs: number;
2005
+ finalize: Finalize;
2006
+ _client: Client;
2007
+ private constructor();
2008
+ static new(c: Client, finalize: Finalize): [
2009
+ RefCount,
2010
+ Ref
2011
+ ];
2012
+ call<P extends Struct, R extends Struct>(cl: Call<P, R>): Answer<R>;
2013
+ client(): Client;
2014
+ close(): void;
2015
+ ref(): Client;
2016
+ newRef(): Ref;
2017
+ decref(): void;
2018
+ }
2019
+ export interface Transport {
2020
+ sendMessage(msg: Message$1): void;
2021
+ recvMessage(): Promise<Message$1>;
2022
+ close(): void;
2023
+ }
2024
+ declare enum QuestionState {
2025
+ IN_PROGRESS = 0,
2026
+ RESOLVED = 1,
2027
+ CANCELED = 2
2028
+ }
2029
+ declare class Question<P extends Struct, R extends Struct> implements Answer<R> {
2030
+ conn: Conn;
2031
+ id: number;
2032
+ method?: Method<P, R> | undefined;
2033
+ paramCaps: number[];
2034
+ state: QuestionState;
2035
+ obj?: R;
2036
+ err?: Error;
2037
+ derived: PipelineOp[][];
2038
+ deferred: Deferred<R>;
2039
+ constructor(conn: Conn, id: number, method?: Method<P, R> | undefined);
2040
+ struct(): Promise<R>;
2041
+ start(): void;
2042
+ fulfill(obj: Pointer): void;
2043
+ reject(err: Error): void;
2044
+ cancel(err: Error): boolean;
2045
+ pipelineCall<CallParams extends Struct, CallResults extends Struct>(transform: PipelineOp[], call: Call<CallParams, CallResults>): Answer<CallResults>;
2046
+ addPromise(transform: PipelineOp[]): void;
2047
+ pipelineClose(): void;
2048
+ }
2049
+ export interface ServerMethod<P extends Struct, R extends Struct> extends Method<P, R> {
2050
+ impl(params: P, results: R): Promise<void>;
2051
+ }
2052
+ export interface ServerCall<P extends Struct, R extends Struct> extends DataCall<P, R> {
2053
+ serverMethod: ServerMethod<P, R>;
2054
+ answer: Fulfiller<R>;
2055
+ }
2056
+ export declare class Server implements Client {
2057
+ target: any;
2058
+ methods: Array<ServerMethod<any, any>>;
2059
+ constructor(target: any, methods: Array<ServerMethod<any, any>>);
2060
+ startCall<P extends Struct, R extends Struct>(call: ServerCall<P, R>): void;
2061
+ call<P extends Struct, R extends Struct>(call: Call<P, R>): Answer<R>;
2062
+ close(): void;
2063
+ }
2064
+ export type QuestionSlot = Question<any, any> | null;
2065
+ export declare class Conn {
2066
+ transport: Transport;
2067
+ finalize: Finalize;
2068
+ questionID: IDGen;
2069
+ questions: QuestionSlot[];
2070
+ answers: {
2071
+ [key: number]: AnswerEntry<any>;
2072
+ };
2073
+ exportID: IDGen;
2074
+ exports: Array<Export | null>;
2075
+ imports: {
2076
+ [key: number]: ImportEntry;
2077
+ };
2078
+ onError?: (err?: Error) => void;
2079
+ main?: Client;
2080
+ working: boolean;
2081
+ /**
2082
+ * Create a new connection
2083
+ * @param transport The transport used to receive/send messages.
2084
+ * @param finalize Weak reference implementation. Compatible with
2085
+ * the 'weak' module on node.js (just add weak as a dependency and pass
2086
+ * require("weak")), but alternative implementations can be provided for
2087
+ * other platforms like Electron. Defaults to using FinalizationRegistry if
2088
+ * available.
2089
+ * @returns A new connection.
2090
+ */
2091
+ constructor(transport: Transport, finalize?: Finalize);
2092
+ bootstrap<C>(InterfaceClass: InterfaceCtor<C, Server>): C;
2093
+ initMain<S extends InterfaceCtor<unknown, Server>>(InterfaceClass: S, target: ServerTarget<S>): void;
2094
+ startWork(): void;
2095
+ sendReturnException(id: number, err: Error): void;
2096
+ handleBootstrapMessage(m: Message$1): void;
2097
+ handleFinishMessage(m: Message$1): void;
2098
+ handleMessage(m: Message$1): void;
2099
+ handleReturnMessage(m: Message$1): void;
2100
+ handleCallMessage(m: Message$1): void;
2101
+ routeCallMessage<P extends Struct, R extends Struct>(result: AnswerEntry<R>, mt: MessageTarget, cl: Call<P, R>): void;
2102
+ populateMessageCapTable(payload: Payload): void;
2103
+ addImport(id: number): Client;
2104
+ findExport(id: number): Export | null;
2105
+ addExport(client: Client): number;
2106
+ releaseExport(id: number, refs: number): void;
2107
+ error(s: string): void;
2108
+ newQuestion<CallParams extends Struct, CallResults extends Struct>(method?: Method<CallParams, CallResults>): Question<CallParams, CallResults>;
2109
+ findQuestion<P extends Struct, R extends Struct>(id: number): Question<P, R> | null;
2110
+ popQuestion<P extends Struct, R extends Struct>(id: number): Question<P, R> | null;
2111
+ insertAnswer(id: number): AnswerEntry<any> | null;
2112
+ popAnswer(id: number): AnswerEntry<any> | null;
2113
+ shutdown(_err?: Error): void;
2114
+ call<P extends Struct, R extends Struct>(client: Client, call: Call<P, R>): Answer<R>;
2115
+ fillParams<P extends Struct, R extends Struct>(payload: Payload, cl: Call<P, R>): void;
2116
+ makeCapTable(s: Segment, init: (length: number) => List<CapDescriptor>): void;
2117
+ descriptorForClient(desc: CapDescriptor, _client: Client): void;
2118
+ sendMessage(msg: Message$1): void;
2119
+ private work;
2120
+ }
2121
+ export interface Export {
2122
+ id: number;
2123
+ rc: RefCount;
2124
+ client: Client;
2125
+ wireRefs: number;
2126
+ }
2127
+ export interface ImportEntry {
2128
+ rc: RefCount;
2129
+ refs: number;
2130
+ }
2131
+ export declare function answerPipelineClient<T extends Struct>(a: AnswerEntry<T>, transform: PipelineOp[]): Client;
2132
+ export type ServerTarget<S extends InterfaceCtor<unknown, Server>> = ConstructorParameters<S["Server"]>[0];
2133
+ export interface InterfaceCtor<C, S extends Server> {
2134
+ readonly _capnp: {
2135
+ displayName: string;
2136
+ id: string;
2137
+ size: ObjectSize;
2138
+ };
2139
+ readonly Client: {
2140
+ new (client: Client): C;
2141
+ };
2142
+ readonly Server: {
2143
+ new (target: any): S;
2144
+ };
2145
+ new (segment: Segment, byteOffset: number, depthLimit?: number): Interface;
2146
+ }
2147
+ export declare class Interface extends Pointer {
2148
+ static readonly _capnp: {
2149
+ displayName: string;
2150
+ };
2151
+ static readonly getCapID: typeof getCapID;
2152
+ static readonly getAsInterface: typeof getAsInterface;
2153
+ static readonly isInterface: typeof isInterface;
2154
+ static readonly getClient: typeof getClient;
2155
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number);
2156
+ static fromPointer(p: Pointer): Interface | null;
2157
+ getCapId(): CapabilityID;
2158
+ getClient(): Client | null;
2159
+ }
2160
+ declare function getAsInterface(p: Pointer): Interface | null;
2161
+ declare function isInterface(p: Pointer): boolean;
2162
+ declare function getCapID(i: Interface): CapabilityID;
2163
+ declare function getClient(i: Interface): Client | null;
2164
+ export interface _Orphan {
2165
+ capId: number;
2166
+ elementSize: ListElementSize;
2167
+ length: number;
2168
+ size: ObjectSize;
2169
+ type: PointerType;
2170
+ }
2171
+ /**
2172
+ * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left
2173
+ * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to
2174
+ * be reconstructed once another pointer is ready to adopt it.
2175
+ */
2176
+ export declare class Orphan<T extends Pointer> {
2177
+ /** If this member is not present then the orphan has already been adopted, or something went very wrong. */
2178
+ _capnp?: _Orphan;
2179
+ byteOffset: number;
2180
+ segment: Segment;
2181
+ constructor(src: T);
2182
+ /**
2183
+ * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed.
2184
+ *
2185
+ * @param dst The destination pointer.
2186
+ */
2187
+ _moveTo(dst: T): void;
2188
+ dispose(): void;
2189
+ }
2190
+ declare class Segment implements DataView {
2191
+ readonly id: number;
2192
+ readonly message: Message;
2193
+ buffer: ArrayBuffer;
2194
+ /** The number of bytes currently allocated in the segment. */
2195
+ byteLength: number;
2196
+ /**
2197
+ * This value should always be zero. It's only here to satisfy the DataView interface.
2198
+ *
2199
+ * In the future the Segment implementation (or a child class) may allow accessing the buffer from a nonzero offset,
2200
+ * but that adds a lot of extra arithmetic.
2201
+ */
2202
+ byteOffset: number;
2203
+ readonly [Symbol.toStringTag]: "DataView";
2204
+ private _dv;
2205
+ constructor(id: number, message: Message, buffer: ArrayBuffer, byteLength?: number);
2206
+ /**
2207
+ * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return
2208
+ * a pointer to freshly allocated space in another segment from the same message.
2209
+ *
2210
+ * @param byteLength The number of bytes to allocate, will be rounded up to the nearest word.
2211
+ * @returns A pointer to the newly allocated space.
2212
+ */
2213
+ allocate(byteLength: number): Pointer;
2214
+ /**
2215
+ * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset.
2216
+ *
2217
+ * @param byteOffset The offset to write the word to.
2218
+ * @param srcSegment The segment to copy the word from.
2219
+ * @param srcByteOffset The offset from the start of `srcSegment` to copy from.
2220
+ */
2221
+ copyWord(byteOffset: number, srcSegment: Segment, srcByteOffset: number): void;
2222
+ /**
2223
+ * Quickly copy words from `srcSegment` into this one.
2224
+ *
2225
+ * @param byteOffset The offset to start copying into.
2226
+ * @param srcSegment The segment to copy from.
2227
+ * @param srcByteOffset The start offset to copy from.
2228
+ * @param wordLength The number of words to copy.
2229
+ */
2230
+ copyWords(byteOffset: number, srcSegment: Segment, srcByteOffset: number, wordLength: number): void;
2231
+ /**
2232
+ * Quickly fill a number of words in the buffer with zeroes.
2233
+ *
2234
+ * @param byteOffset The first byte to set to zero.
2235
+ * @param wordLength The number of words (not bytes!) to zero out.
2236
+ */
2237
+ fillZeroWords(byteOffset: number, wordLength: number): void;
2238
+ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
2239
+ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
2240
+ /**
2241
+ * Get the total number of bytes available in this segment (the size of its underlying buffer).
2242
+ *
2243
+ * @returns The total number of bytes this segment can hold.
2244
+ */
2245
+ getCapacity(): number;
2246
+ /**
2247
+ * Read a float32 value out of this segment.
2248
+ *
2249
+ * @param byteOffset The offset in bytes to the value.
2250
+ * @returns The value.
2251
+ */
2252
+ getFloat32(byteOffset: number): number;
2253
+ /**
2254
+ * Read a float64 value out of this segment.
2255
+ *
2256
+ * @param byteOffset The offset in bytes to the value.
2257
+ * @returns The value.
2258
+ */
2259
+ getFloat64(byteOffset: number): number;
2260
+ /**
2261
+ * Read an int16 value out of this segment.
2262
+ *
2263
+ * @param byteOffset The offset in bytes to the value.
2264
+ * @returns The value.
2265
+ */
2266
+ getInt16(byteOffset: number): number;
2267
+ /**
2268
+ * Read an int32 value out of this segment.
2269
+ *
2270
+ * @param byteOffset The offset in bytes to the value.
2271
+ * @returns The value.
2272
+ */
2273
+ getInt32(byteOffset: number): number;
2274
+ /**
2275
+ * Read an int64 value out of this segment.
2276
+ *
2277
+ * @param byteOffset The offset in bytes to the value.
2278
+ * @returns The value.
2279
+ */
2280
+ getInt64(byteOffset: number): bigint;
2281
+ /**
2282
+ * Read an int8 value out of this segment.
2283
+ *
2284
+ * @param byteOffset The offset in bytes to the value.
2285
+ * @returns The value.
2286
+ */
2287
+ getInt8(byteOffset: number): number;
2288
+ /**
2289
+ * Read a uint16 value out of this segment.
2290
+ *
2291
+ * @param byteOffset The offset in bytes to the value.
2292
+ * @returns The value.
2293
+ */
2294
+ getUint16(byteOffset: number): number;
2295
+ /**
2296
+ * Read a uint32 value out of this segment.
2297
+ *
2298
+ * @param byteOffset The offset in bytes to the value.
2299
+ * @returns The value.
2300
+ */
2301
+ getUint32(byteOffset: number): number;
2302
+ /**
2303
+ * Read a uint64 value (as a bigint) out of this segment.
2304
+ * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the returned value!
2305
+ *
2306
+ * @param byteOffset The offset in bytes to the value.
2307
+ * @returns The value.
2308
+ */
2309
+ getUint64(byteOffset: number): bigint;
2310
+ /**
2311
+ * Read a uint8 value out of this segment.
2312
+ *
2313
+ * @param byteOffset The offset in bytes to the value.
2314
+ * @returns The value.
2315
+ */
2316
+ getUint8(byteOffset: number): number;
2317
+ hasCapacity(byteLength: number): boolean;
2318
+ /**
2319
+ * Quickly check the word at the given offset to see if it is equal to zero.
2320
+ *
2321
+ * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format
2322
+ * and see if it's zero.
2323
+ *
2324
+ * Benchmark: http://jsben.ch/#/Pjooc
2325
+ *
2326
+ * @param byteOffset The offset to the word.
2327
+ * @returns `true` if the word is zero.
2328
+ */
2329
+ isWordZero(byteOffset: number): boolean;
2330
+ /**
2331
+ * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but
2332
+ * more free space, otherwise all existing pointers to this segment will be hilariously broken.
2333
+ *
2334
+ * @param buffer The new buffer to use.
2335
+ */
2336
+ replaceBuffer(buffer: ArrayBuffer): void;
2337
+ /**
2338
+ * Read a float16 value from the specified offset.
2339
+ *
2340
+ * @param byteOffset The offset from the beginning of the buffer.
2341
+ * @param littleEndian If true, read the value as little-endian, otherwise read it as big-endian.
2342
+ * @returns The value read from the buffer.
2343
+ */
2344
+ getFloat16(byteOffset: number, littleEndian?: boolean | undefined): number;
2345
+ /**
2346
+ * Write an float16 value to the specified offset.
2347
+ *
2348
+ * @param byteOffset The offset from the beginning of the buffer.
2349
+ * @param val The value to store.
2350
+ */
2351
+ setFloat16(byteOffset: number, val: number): void;
2352
+ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
2353
+ /** WARNING: This function is not yet implemented. */
2354
+ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
2355
+ /**
2356
+ * Write a float32 value to the specified offset.
2357
+ *
2358
+ * @param byteOffset The offset from the beginning of the buffer.
2359
+ * @param val The value to store.
2360
+ */
2361
+ setFloat32(byteOffset: number, val: number): void;
2362
+ /**
2363
+ * Write an float64 value to the specified offset.
2364
+ *
2365
+ * @param byteOffset The offset from the beginning of the buffer.
2366
+ * @param val The value to store.
2367
+ */
2368
+ setFloat64(byteOffset: number, val: number): void;
2369
+ /**
2370
+ * Write an int16 value to the specified offset.
2371
+ *
2372
+ * @param byteOffset The offset from the beginning of the buffer.
2373
+ * @param val The value to store.
2374
+ */
2375
+ setInt16(byteOffset: number, val: number): void;
2376
+ /**
2377
+ * Write an int32 value to the specified offset.
2378
+ *
2379
+ * @param byteOffset The offset from the beginning of the buffer.
2380
+ * @param val The value to store.
2381
+ */
2382
+ setInt32(byteOffset: number, val: number): void;
2383
+ /**
2384
+ * Write an int8 value to the specified offset.
2385
+ *
2386
+ * @param byteOffset The offset from the beginning of the buffer.
2387
+ * @param val The value to store.
2388
+ */
2389
+ setInt8(byteOffset: number, val: number): void;
2390
+ /**
2391
+ * Write an int64 value to the specified offset.
2392
+ *
2393
+ * @param byteOffset The offset from the beginning of the buffer.
2394
+ * @param val The value to store.
2395
+ */
2396
+ setInt64(byteOffset: number, val: bigint): void;
2397
+ /**
2398
+ * Write a uint16 value to the specified offset.
2399
+ *
2400
+ * @param byteOffset The offset from the beginning of the buffer.
2401
+ * @param val The value to store.
2402
+ */
2403
+ setUint16(byteOffset: number, val: number): void;
2404
+ /**
2405
+ * Write a uint32 value to the specified offset.
2406
+ *
2407
+ * @param byteOffset The offset from the beginning of the buffer.
2408
+ * @param val The value to store.
2409
+ */
2410
+ setUint32(byteOffset: number, val: number): void;
2411
+ /**
2412
+ * Write a uint64 value to the specified offset.
2413
+ *
2414
+ * @param byteOffset The offset from the beginning of the buffer.
2415
+ * @param val The value to store.
2416
+ */
2417
+ setUint64(byteOffset: number, val: bigint): void;
2418
+ /**
2419
+ * Write a uint8 (byte) value to the specified offset.
2420
+ *
2421
+ * @param byteOffset The offset from the beginning of the buffer.
2422
+ * @param val The value to store.
2423
+ */
2424
+ setUint8(byteOffset: number, val: number): void;
2425
+ /**
2426
+ * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or
2427
+ * `setFloat64` with a zero value.
2428
+ *
2429
+ * Benchmark: http://jsben.ch/#/dUdPI
2430
+ *
2431
+ * @param byteOffset The offset of the word to set to zero.
2432
+ */
2433
+ setWordZero(byteOffset: number): void;
2434
+ toString(): string;
2435
+ }
2436
+ export interface _StructCtor extends _PointerCtor {
2437
+ readonly id: string;
2438
+ readonly size: ObjectSize;
2439
+ }
2440
+ export interface StructCtor<T extends Struct> {
2441
+ readonly _capnp: _StructCtor;
2442
+ new (segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number): T;
2443
+ }
2444
+ export interface _Struct extends _Pointer {
2445
+ compositeIndex?: number;
2446
+ }
2447
+ export declare class Struct extends Pointer<_Struct> {
2448
+ static readonly _capnp: {
2449
+ displayName: string;
2450
+ };
2451
+ /**
2452
+ * Create a new pointer to a struct.
2453
+ *
2454
+ * @param segment The segment the pointer resides in.
2455
+ * @param byteOffset The offset from the beginning of the segment to the beginning of the pointer data.
2456
+ * @param depthLimit The nesting depth limit for this object.
2457
+ * @param compositeIndex If set, then this pointer is actually a reference to a composite list
2458
+ * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within
2459
+ * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when
2460
+ * the list pointer is initialized.
2461
+ */
2462
+ constructor(segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number);
2463
+ static [Symbol.toStringTag](): string;
2464
+ [Symbol.toStringTag](): string;
2465
+ }
2466
+ export interface Client {
2467
+ call<P extends Struct, R extends Struct>(call: Call<P, R>): Answer<R>;
2468
+ close(): void;
2469
+ }
2470
+ export declare function isSameClient(c: Client, d: Client): boolean;
2471
+ export declare function clientFromResolution(transform: PipelineOp[], obj?: Struct, err?: Error): Client;
2472
+ declare class ArenaAllocationResult {
2473
+ /**
2474
+ * The newly allocated buffer. This buffer might be a copy of an existing segment's buffer with free space appended.
2475
+ */
2476
+ readonly buffer: ArrayBuffer;
2477
+ /**
2478
+ * The id of the newly-allocated segment.
2479
+ */
2480
+ readonly id: number;
2481
+ constructor(id: number, buffer: ArrayBuffer);
2482
+ }
2483
+ declare enum ArenaKind {
2484
+ SINGLE_SEGMENT = 0,
2485
+ MULTI_SEGMENT = 1
2486
+ }
2487
+ declare class MultiSegmentArena {
2488
+ readonly buffers: ArrayBuffer[];
2489
+ static readonly allocate: typeof allocate$1;
2490
+ static readonly getBuffer: typeof getBuffer$1;
2491
+ static readonly getNumSegments: typeof getNumSegments$1;
2492
+ readonly kind = ArenaKind.MULTI_SEGMENT;
2493
+ constructor(buffers?: ArrayBuffer[]);
2494
+ toString(): string;
2495
+ }
2496
+ declare function allocate$1(minSize: number, m: MultiSegmentArena): ArenaAllocationResult;
2497
+ declare function getBuffer$1(id: number, m: MultiSegmentArena): ArrayBuffer;
2498
+ declare function getNumSegments$1(m: MultiSegmentArena): number;
2499
+ declare class SingleSegmentArena {
2500
+ static readonly allocate: typeof allocate;
2501
+ static readonly getBuffer: typeof getBuffer;
2502
+ static readonly getNumSegments: typeof getNumSegments;
2503
+ buffer: ArrayBuffer;
2504
+ readonly kind = ArenaKind.SINGLE_SEGMENT;
2505
+ constructor(buffer?: ArrayBuffer);
2506
+ toString(): string;
2507
+ }
2508
+ declare function allocate(minSize: number, segments: Segment[], s: SingleSegmentArena): ArenaAllocationResult;
2509
+ declare function getBuffer(id: number, s: SingleSegmentArena): ArrayBuffer;
2510
+ declare function getNumSegments(): number;
2511
+ export type AnyArena = MultiSegmentArena | SingleSegmentArena;
2512
+ export interface _Message {
2513
+ readonly arena: AnyArena;
2514
+ segments: Segment[];
2515
+ traversalLimit: number;
2516
+ capTable?: Array<Client | null>;
2517
+ }
2518
+ export declare class Message {
2519
+ static readonly allocateSegment: typeof allocateSegment;
2520
+ static readonly dump: typeof dump;
2521
+ static readonly getRoot: typeof getRoot;
2522
+ static readonly getSegment: typeof getSegment;
2523
+ static readonly initRoot: typeof initRoot;
2524
+ static readonly readRawPointer: typeof readRawPointer;
2525
+ static readonly toArrayBuffer: typeof toArrayBuffer;
2526
+ static readonly toPackedArrayBuffer: typeof toPackedArrayBuffer;
2527
+ readonly _capnp: _Message;
2528
+ /**
2529
+ * A Cap'n Proto message.
2530
+ *
2531
+ * SECURITY WARNING: In Node.js do not pass a Buffer's internal array buffer into this constructor. Pass the buffer
2532
+ * directly and everything will be fine. If not, your message will potentially be initialized with random memory
2533
+ * contents!
2534
+ *
2535
+ * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer
2536
+ * to read from.
2537
+ *
2538
+ * @param src The source for the message.
2539
+ * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the
2540
+ * root pointer; it will expand as you go. This is a reasonable choice for most messages.
2541
+ *
2542
+ * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted
2543
+ * as-is.
2544
+ *
2545
+ * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source
2546
+ * buffer; beware of the potential performance cost!
2547
+ *
2548
+ * @param packed Whether or not the message is packed. If `true` (the default), the message will be
2549
+ * unpacked.
2550
+ *
2551
+ * @param singleSegment If true, `src` will be treated as a message consisting of a single segment without
2552
+ * a framing header.
2553
+ *
2554
+ */
2555
+ constructor(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed?: boolean, singleSegment?: boolean);
2556
+ allocateSegment(byteLength: number): Segment;
2557
+ /**
2558
+ * Copies the contents of this message into an identical message with its own ArrayBuffers.
2559
+ *
2560
+ * @returns A copy of this message.
2561
+ */
2562
+ copy(): Message;
2563
+ /**
2564
+ * Create a pretty-printed string dump of this message; incredibly useful for debugging.
2565
+ *
2566
+ * WARNING: Do not call this method on large messages!
2567
+ *
2568
+ * @returns A big steaming pile of pretty hex digits.
2569
+ */
2570
+ dump(): string;
2571
+ /**
2572
+ * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not
2573
+ * overwrite existing data.
2574
+ *
2575
+ * @param RootStruct The struct type to use as the root.
2576
+ * @returns A struct representing the root of the message.
2577
+ */
2578
+ getRoot<T extends Struct>(RootStruct: StructCtor<T>): T;
2579
+ /**
2580
+ * Get a segment by its id.
2581
+ *
2582
+ * This will lazily allocate the first segment if it doesn't already exist.
2583
+ *
2584
+ * @param id The segment id.
2585
+ * @returns The requested segment.
2586
+ */
2587
+ getSegment(id: number): Segment;
2588
+ /**
2589
+ * Initialize a new message using the provided struct type as the root.
2590
+ *
2591
+ * @param RootStruct The struct type to use as the root.
2592
+ * @returns An initialized struct pointing to the root of the message.
2593
+ */
2594
+ initRoot<T extends Struct>(RootStruct: StructCtor<T>): T;
2595
+ /**
2596
+ * Set the root of the message to a copy of the given pointer. Used internally
2597
+ * to make copies of pointers for default values.
2598
+ *
2599
+ * @param src The source pointer to copy.
2600
+ */
2601
+ setRoot(src: Pointer): void;
2602
+ /**
2603
+ * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header
2604
+ * containing information about the following segment data.
2605
+ *
2606
+ * @returns An ArrayBuffer with the contents of this message.
2607
+ */
2608
+ toArrayBuffer(): ArrayBuffer;
2609
+ /**
2610
+ * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to
2611
+ * use if you're sending the message over a network link or other slow I/O interface where size matters.
2612
+ *
2613
+ * @returns A packed message.
2614
+ */
2615
+ toPackedArrayBuffer(): ArrayBuffer;
2616
+ addCap(client: Client | null): number;
2617
+ toString(): string;
2618
+ }
2619
+ declare function allocateSegment(byteLength: number, m: Message): Segment;
2620
+ declare function dump(m: Message): string;
2621
+ declare function getRoot<T extends Struct>(RootStruct: StructCtor<T>, m: Message): T;
2622
+ declare function getSegment(id: number, m: Message): Segment;
2623
+ declare function initRoot<T extends Struct>(RootStruct: StructCtor<T>, m: Message): T;
2624
+ /**
2625
+ * Read a pointer in raw form (a packed message with framing headers). Does not
2626
+ * care or attempt to validate the input beyond parsing the message
2627
+ * segments.
2628
+ *
2629
+ * This is typically used by the compiler to load default values, but can be
2630
+ * useful to work with messages with an unknown schema.
2631
+ *
2632
+ * @param data The raw data to read.
2633
+ * @returns A root pointer.
2634
+ */
2635
+ export declare function readRawPointer(data: ArrayBuffer): Pointer;
2636
+ declare function toArrayBuffer(m: Message): ArrayBuffer;
2637
+ declare function toPackedArrayBuffer(m: Message): ArrayBuffer;
2638
+ /**
2639
+ * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and
2640
+ * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once.
2641
+ */
2642
+ export declare class Data extends List<number> {
2643
+ static fromPointer(pointer: Pointer): Data;
2644
+ protected static _fromPointerUnchecked(pointer: Pointer): Data;
2645
+ /**
2646
+ * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the
2647
+ * remaining bytes will be zeroed out. Extra bytes in `src` are ignored.
2648
+ *
2649
+ * @param src The source buffer.
2650
+ */
2651
+ copyBuffer(src: ArrayBuffer | ArrayBufferView): void;
2652
+ /**
2653
+ * Read a byte from the specified offset.
2654
+ *
2655
+ * @param byteOffset The byte offset to read.
2656
+ * @returns The byte value.
2657
+ */
2658
+ get(byteOffset: number): number;
2659
+ /**
2660
+ * Write a byte at the specified offset.
2661
+ *
2662
+ * @param byteOffset The byte offset to set.
2663
+ * @param value The byte value to set.
2664
+ */
2665
+ set(byteOffset: number, value: number): void;
2666
+ /**
2667
+ * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer.
2668
+ *
2669
+ * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`.
2670
+ *
2671
+ * @returns A copy of this data buffer.
2672
+ */
2673
+ toArrayBuffer(): ArrayBuffer;
2674
+ /**
2675
+ * Convert this Data pointer to a DataView representing the pointer's contents.
2676
+ *
2677
+ * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the
2678
+ * DataView or else BAD THINGS.
2679
+ *
2680
+ * @returns A live reference to the underlying buffer.
2681
+ */
2682
+ toDataView(): DataView;
2683
+ [Symbol.toStringTag](): string;
2684
+ /**
2685
+ * Convert this Data pointer to a Uint8Array representing the pointer's contents.
2686
+ *
2687
+ * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the
2688
+ * Uint8Array or else BAD THINGS.
2689
+ *
2690
+ * @returns A live reference to the underlying buffer.
2691
+ */
2692
+ toUint8Array(): Uint8Array;
2693
+ }
2694
+ declare class PipelineClient<AnswerResults extends Struct, ParentResults extends Struct, Results extends Struct> implements Client {
2695
+ pipeline: Pipeline<AnswerResults, ParentResults, Results>;
2696
+ constructor(pipeline: Pipeline<AnswerResults, ParentResults, Results>);
2697
+ transform(): PipelineOp[];
2698
+ call<CallParams extends Struct, CallResults extends Struct>(call: Call<CallParams, CallResults>): Answer<CallResults>;
2699
+ close(): void;
2700
+ }
2701
+ /**
2702
+ * A Pipeline is a generic wrapper for an answer
2703
+ */
2704
+ export declare class Pipeline<AnswerResults extends Struct, ParentResults extends Struct, Results extends Struct> {
2705
+ ResultsClass: StructCtor<Results>;
2706
+ answer: Answer<AnswerResults>;
2707
+ parent?: Pipeline<AnswerResults, Struct, ParentResults> | undefined;
2708
+ op: PipelineOp;
2709
+ pipelineClient?: PipelineClient<AnswerResults, ParentResults, Results>;
2710
+ constructor(ResultsClass: StructCtor<Results>, answer: Answer<AnswerResults>, op?: PipelineOp, parent?: Pipeline<AnswerResults, Struct, ParentResults> | undefined);
2711
+ transform(): PipelineOp[];
2712
+ struct(): Promise<Results>;
2713
+ client(): PipelineClient<AnswerResults, ParentResults, Results>;
2714
+ getPipeline<RR extends Struct>(ResultsClass: StructCtor<RR>, off: number, defaultValue?: Pointer): Pipeline<AnswerResults, Results, RR>;
2715
+ }
2716
+ export declare abstract class DeferredTransport implements Transport {
2717
+ protected d?: Deferred<Message$1>;
2718
+ protected closed: boolean;
2719
+ abstract sendMessage(msg: Message$1): void;
2720
+ close(): void;
2721
+ recvMessage(): Promise<Message$1>;
2722
+ protected reject: (err: unknown) => void;
2723
+ protected resolve: (buf: ArrayBuffer) => void;
2724
+ }
2725
+ export declare class ErrorClient implements Client {
2726
+ err: Error;
2727
+ constructor(err: Error);
2728
+ call<P extends Struct, R extends Struct>(_call: Call<P, R>): Answer<R>;
2729
+ close(): void;
2730
+ }
2731
+ export declare function clientOrNull(client: Client | null): Client;
2732
+ export interface InterfaceDefinition {
2733
+ methods: Array<Method<any, any>>;
2734
+ }
2735
+ export declare class Registry {
2736
+ static readonly interfaces: Map<bigint, InterfaceDefinition>;
2737
+ static register(id: bigint, def: InterfaceDefinition): void;
2738
+ static lookup(id: bigint): InterfaceDefinition | undefined;
2739
+ }
2740
+ export declare class Text extends List<string> {
2741
+ static fromPointer(pointer: Pointer): Text;
2742
+ /**
2743
+ * Read a utf-8 encoded string value from this pointer.
2744
+ *
2745
+ * @param index The index at which to start reading; defaults to zero.
2746
+ * @returns The string value.
2747
+ */
2748
+ get(index?: number): string;
2749
+ /**
2750
+ * Get the number of utf-8 encoded bytes in this text. This does **not** include the NUL byte.
2751
+ *
2752
+ * @returns The number of bytes allocated for the text.
2753
+ */
2754
+ get length(): number;
2755
+ /**
2756
+ * Write a utf-8 encoded string value starting at the specified index.
2757
+ *
2758
+ * @param index The index at which to start copying the string. Note that if this is not zero the bytes
2759
+ * before `index` will be left as-is. All bytes after `index` will be overwritten.
2760
+ * @param value The string value to set.
2761
+ */
2762
+ set(index: number, value: string): void;
2763
+ toString(): string;
2764
+ toJSON(): string;
2765
+ [Symbol.toPrimitive](): string;
2766
+ [Symbol.toStringTag](): string;
2767
+ }
2768
+ export declare class Void extends Struct {
2769
+ static readonly _capnp: _StructCtor;
2770
+ }
2771
+ declare function initStruct(size: ObjectSize, s: Struct): void;
2772
+ declare function initStructAt<T extends Struct>(index: number, StructClass: StructCtor<T>, p: Pointer): T;
2773
+ declare function checkPointerBounds(index: number, s: Struct): void;
2774
+ declare function getInterfaceClientOrNullAt(index: number, s: Struct): Client;
2775
+ declare function getInterfaceClientOrNull(p: Pointer): Client;
2776
+ declare function resize(dstSize: ObjectSize, s: Struct): void;
2777
+ declare function getAs<T extends Struct>(StructClass: StructCtor<T>, s: Struct): T;
2778
+ declare function getBit(bitOffset: number, s: Struct, defaultMask?: DataView): boolean;
2779
+ declare function getData(index: number, s: Struct, defaultValue?: Pointer): Data;
2780
+ declare function getDataSection(s: Struct): Pointer;
2781
+ declare function getFloat32(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2782
+ declare function getFloat64(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2783
+ declare function getInt16(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2784
+ declare function getInt32(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2785
+ declare function getInt64(byteOffset: number, s: Struct, defaultMask?: DataView): bigint;
2786
+ declare function getInt8(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2787
+ declare function getList<T>(index: number, ListClass: ListCtor<T>, s: Struct, defaultValue?: Pointer): List<T>;
2788
+ declare function getPointer(index: number, s: Struct): Pointer;
2789
+ declare function getPointerAs<T extends Pointer>(index: number, PointerClass: PointerCtor<T>, s: Struct): T;
2790
+ declare function getPointerSection(s: Struct): Pointer;
2791
+ declare function getSize(s: Struct): ObjectSize;
2792
+ declare function getStruct<T extends Struct>(index: number, StructClass: StructCtor<T>, s: Struct, defaultValue?: Pointer): T;
2793
+ declare function getText(index: number, s: Struct, defaultValue?: string): string;
2794
+ declare function getUint16(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2795
+ declare function getUint32(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2796
+ declare function getUint64(byteOffset: number, s: Struct, defaultMask?: DataView): bigint;
2797
+ declare function getUint8(byteOffset: number, s: Struct, defaultMask?: DataView): number;
2798
+ declare function initData(index: number, length: number, s: Struct): Data;
2799
+ declare function initList<T>(index: number, ListClass: ListCtor<T>, length: number, s: Struct): List<T>;
2800
+ declare function setBit(bitOffset: number, value: boolean, s: Struct, defaultMask?: DataView): void;
2801
+ declare function setFloat32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2802
+ declare function setFloat64(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2803
+ declare function setInt16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2804
+ declare function setInt32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2805
+ declare function setInt64(byteOffset: number, value: bigint, s: Struct, defaultMask?: DataView): void;
2806
+ declare function setInt8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2807
+ declare function setText(index: number, value: string, s: Struct): void;
2808
+ declare function setUint16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2809
+ declare function setUint32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2810
+ declare function setUint64(byteOffset: number, value: bigint, s: Struct, defaultMask?: DataView): void;
2811
+ declare function setUint8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void;
2812
+ declare function testWhich(name: string, found: number, wanted: number, s: Struct): void;
2813
+ declare function checkDataBounds(byteOffset: number, byteLength: number, s: Struct): void;
2814
+ declare function adopt<T extends Pointer>(src: Orphan<T>, p: T): void;
2815
+ declare function disown<T extends Pointer>(p: T): Orphan<T>;
2816
+ declare function dump$1(p: Pointer): string;
2817
+ declare function getListByteLength(elementSize: ListElementSize, length: number, compositeSize?: ObjectSize): number;
2818
+ declare function getListElementByteLength(elementSize: ListElementSize): number;
2819
+ declare function add(offset: number, p: Pointer): Pointer;
2820
+ declare function copyFrom(src: Pointer, p: Pointer): void;
2821
+ declare function erase(p: Pointer): void;
2822
+ declare function erasePointer(p: Pointer): void;
2823
+ declare function followFar(p: Pointer): Pointer;
2824
+ declare function followFars(p: Pointer): Pointer;
2825
+ declare function getCapabilityId(p: Pointer): number;
2826
+ declare function getContent(p: Pointer, ignoreCompositeIndex?: boolean): Pointer;
2827
+ declare function getFarSegmentId(p: Pointer): number;
2828
+ declare function getListElementSize(p: Pointer): ListElementSize;
2829
+ declare function getListLength(p: Pointer): number;
2830
+ declare function getOffsetWords(p: Pointer): number;
2831
+ declare function getPointerType(p: Pointer): PointerType;
2832
+ declare function getStructDataWords(p: Pointer): number;
2833
+ declare function getStructPointerLength(p: Pointer): number;
2834
+ declare function getStructSize(p: Pointer): ObjectSize;
2835
+ declare function getTargetCompositeListTag(p: Pointer): Pointer;
2836
+ declare function getTargetCompositeListSize(p: Pointer): ObjectSize;
2837
+ declare function getTargetListElementSize(p: Pointer): ListElementSize;
2838
+ declare function getTargetListLength(p: Pointer): number;
2839
+ declare function getTargetPointerType(p: Pointer): PointerType;
2840
+ declare function getTargetStructSize(p: Pointer): ObjectSize;
2841
+ declare function initPointer(contentSegment: Segment, contentOffset: number, p: Pointer): PointerAllocationResult;
2842
+ declare function isDoubleFar(p: Pointer): boolean;
2843
+ declare function isNull(p: Pointer): boolean;
2844
+ declare function relocateTo(dst: Pointer, src: Pointer): void;
2845
+ declare function setFarPointer(doubleFar: boolean, offsetWords: number, segmentId: number, p: Pointer): void;
2846
+ declare function setInterfacePointer(capId: number, p: Pointer): void;
2847
+ declare function getInterfacePointer(p: Pointer): number;
2848
+ declare function setListPointer(offsetWords: number, size: ListElementSize, length: number, p: Pointer, compositeSize?: ObjectSize): void;
2849
+ declare function setStructPointer(offsetWords: number, size: ObjectSize, p: Pointer): void;
2850
+ declare function validate(pointerType: PointerType, p: Pointer, elementSize?: ListElementSize): void;
2851
+ declare function copyFromInterface(src: Pointer, dst: Pointer): void;
2852
+ declare function copyFromList(src: Pointer, dst: Pointer): void;
2853
+ declare function copyFromStruct(src: Pointer, dst: Pointer): void;
2854
+ declare function trackPointerAllocation(message: Message, p: Pointer): void;
2855
+ declare class PointerAllocationResult {
2856
+ readonly pointer: Pointer;
2857
+ readonly offsetWords: number;
2858
+ constructor(pointer: Pointer, offsetWords: number);
2859
+ }
2860
+ export type utils_PointerAllocationResult = PointerAllocationResult;
2861
+ declare const utils_PointerAllocationResult: typeof PointerAllocationResult;
2862
+ declare const utils_add: typeof add;
2863
+ declare const utils_adopt: typeof adopt;
2864
+ declare const utils_checkDataBounds: typeof checkDataBounds;
2865
+ declare const utils_checkPointerBounds: typeof checkPointerBounds;
2866
+ declare const utils_copyFrom: typeof copyFrom;
2867
+ declare const utils_copyFromInterface: typeof copyFromInterface;
2868
+ declare const utils_copyFromList: typeof copyFromList;
2869
+ declare const utils_copyFromStruct: typeof copyFromStruct;
2870
+ declare const utils_disown: typeof disown;
2871
+ declare const utils_dump: typeof dump$1;
2872
+ declare const utils_erase: typeof erase;
2873
+ declare const utils_erasePointer: typeof erasePointer;
2874
+ declare const utils_followFar: typeof followFar;
2875
+ declare const utils_followFars: typeof followFars;
2876
+ declare const utils_getAs: typeof getAs;
2877
+ declare const utils_getBit: typeof getBit;
2878
+ declare const utils_getCapabilityId: typeof getCapabilityId;
2879
+ declare const utils_getContent: typeof getContent;
2880
+ declare const utils_getData: typeof getData;
2881
+ declare const utils_getDataSection: typeof getDataSection;
2882
+ declare const utils_getFarSegmentId: typeof getFarSegmentId;
2883
+ declare const utils_getFloat32: typeof getFloat32;
2884
+ declare const utils_getFloat64: typeof getFloat64;
2885
+ declare const utils_getInt16: typeof getInt16;
2886
+ declare const utils_getInt32: typeof getInt32;
2887
+ declare const utils_getInt64: typeof getInt64;
2888
+ declare const utils_getInt8: typeof getInt8;
2889
+ declare const utils_getInterfaceClientOrNull: typeof getInterfaceClientOrNull;
2890
+ declare const utils_getInterfaceClientOrNullAt: typeof getInterfaceClientOrNullAt;
2891
+ declare const utils_getInterfacePointer: typeof getInterfacePointer;
2892
+ declare const utils_getList: typeof getList;
2893
+ declare const utils_getListByteLength: typeof getListByteLength;
2894
+ declare const utils_getListElementByteLength: typeof getListElementByteLength;
2895
+ declare const utils_getListElementSize: typeof getListElementSize;
2896
+ declare const utils_getListLength: typeof getListLength;
2897
+ declare const utils_getOffsetWords: typeof getOffsetWords;
2898
+ declare const utils_getPointer: typeof getPointer;
2899
+ declare const utils_getPointerAs: typeof getPointerAs;
2900
+ declare const utils_getPointerSection: typeof getPointerSection;
2901
+ declare const utils_getPointerType: typeof getPointerType;
2902
+ declare const utils_getSize: typeof getSize;
2903
+ declare const utils_getStruct: typeof getStruct;
2904
+ declare const utils_getStructDataWords: typeof getStructDataWords;
2905
+ declare const utils_getStructPointerLength: typeof getStructPointerLength;
2906
+ declare const utils_getStructSize: typeof getStructSize;
2907
+ declare const utils_getTargetCompositeListSize: typeof getTargetCompositeListSize;
2908
+ declare const utils_getTargetCompositeListTag: typeof getTargetCompositeListTag;
2909
+ declare const utils_getTargetListElementSize: typeof getTargetListElementSize;
2910
+ declare const utils_getTargetListLength: typeof getTargetListLength;
2911
+ declare const utils_getTargetPointerType: typeof getTargetPointerType;
2912
+ declare const utils_getTargetStructSize: typeof getTargetStructSize;
2913
+ declare const utils_getText: typeof getText;
2914
+ declare const utils_getUint16: typeof getUint16;
2915
+ declare const utils_getUint32: typeof getUint32;
2916
+ declare const utils_getUint64: typeof getUint64;
2917
+ declare const utils_getUint8: typeof getUint8;
2918
+ declare const utils_initData: typeof initData;
2919
+ declare const utils_initList: typeof initList;
2920
+ declare const utils_initPointer: typeof initPointer;
2921
+ declare const utils_initStruct: typeof initStruct;
2922
+ declare const utils_initStructAt: typeof initStructAt;
2923
+ declare const utils_isDoubleFar: typeof isDoubleFar;
2924
+ declare const utils_isNull: typeof isNull;
2925
+ declare const utils_relocateTo: typeof relocateTo;
2926
+ declare const utils_resize: typeof resize;
2927
+ declare const utils_setBit: typeof setBit;
2928
+ declare const utils_setFarPointer: typeof setFarPointer;
2929
+ declare const utils_setFloat32: typeof setFloat32;
2930
+ declare const utils_setFloat64: typeof setFloat64;
2931
+ declare const utils_setInt16: typeof setInt16;
2932
+ declare const utils_setInt32: typeof setInt32;
2933
+ declare const utils_setInt64: typeof setInt64;
2934
+ declare const utils_setInt8: typeof setInt8;
2935
+ declare const utils_setInterfacePointer: typeof setInterfacePointer;
2936
+ declare const utils_setListPointer: typeof setListPointer;
2937
+ declare const utils_setStructPointer: typeof setStructPointer;
2938
+ declare const utils_setText: typeof setText;
2939
+ declare const utils_setUint16: typeof setUint16;
2940
+ declare const utils_setUint32: typeof setUint32;
2941
+ declare const utils_setUint64: typeof setUint64;
2942
+ declare const utils_setUint8: typeof setUint8;
2943
+ declare const utils_testWhich: typeof testWhich;
2944
+ declare const utils_trackPointerAllocation: typeof trackPointerAllocation;
2945
+ declare const utils_validate: typeof validate;
2946
+ export declare namespace utils {
2947
+ export { utils_PointerAllocationResult as utils_PointerAllocationResult, utils_add as utils_add, utils_adopt as utils_adopt, utils_checkDataBounds as utils_checkDataBounds, utils_checkPointerBounds as utils_checkPointerBounds, utils_copyFrom as utils_copyFrom, utils_copyFromInterface as utils_copyFromInterface, utils_copyFromList as utils_copyFromList, utils_copyFromStruct as utils_copyFromStruct, utils_disown as utils_disown, utils_dump as utils_dump, utils_erase as utils_erase, utils_erasePointer as utils_erasePointer, utils_followFar as utils_followFar, utils_followFars as utils_followFars, utils_getAs as utils_getAs, utils_getBit as utils_getBit, utils_getCapabilityId as utils_getCapabilityId, utils_getContent as utils_getContent, utils_getData as utils_getData, utils_getDataSection as utils_getDataSection, utils_getFarSegmentId as utils_getFarSegmentId, utils_getFloat32 as utils_getFloat32, utils_getFloat64 as utils_getFloat64, utils_getInt16 as utils_getInt16, utils_getInt32 as utils_getInt32, utils_getInt64 as utils_getInt64, utils_getInt8 as utils_getInt8, utils_getInterfaceClientOrNull as utils_getInterfaceClientOrNull, utils_getInterfaceClientOrNullAt as utils_getInterfaceClientOrNullAt, utils_getInterfacePointer as utils_getInterfacePointer, utils_getList as utils_getList, utils_getListByteLength as utils_getListByteLength, utils_getListElementByteLength as utils_getListElementByteLength, utils_getListElementSize as utils_getListElementSize, utils_getListLength as utils_getListLength, utils_getOffsetWords as utils_getOffsetWords, utils_getPointer as utils_getPointer, utils_getPointerAs as utils_getPointerAs, utils_getPointerSection as utils_getPointerSection, utils_getPointerType as utils_getPointerType, utils_getSize as utils_getSize, utils_getStruct as utils_getStruct, utils_getStructDataWords as utils_getStructDataWords, utils_getStructPointerLength as utils_getStructPointerLength, utils_getStructSize as utils_getStructSize, utils_getTargetCompositeListSize as utils_getTargetCompositeListSize, utils_getTargetCompositeListTag as utils_getTargetCompositeListTag, utils_getTargetListElementSize as utils_getTargetListElementSize, utils_getTargetListLength as utils_getTargetListLength, utils_getTargetPointerType as utils_getTargetPointerType, utils_getTargetStructSize as utils_getTargetStructSize, utils_getText as utils_getText, utils_getUint16 as utils_getUint16, utils_getUint32 as utils_getUint32, utils_getUint64 as utils_getUint64, utils_getUint8 as utils_getUint8, utils_initData as utils_initData, utils_initList as utils_initList, utils_initPointer as utils_initPointer, utils_initStruct as utils_initStruct, utils_initStructAt as utils_initStructAt, utils_isDoubleFar as utils_isDoubleFar, utils_isNull as utils_isNull, utils_relocateTo as utils_relocateTo, utils_resize as utils_resize, utils_setBit as utils_setBit, utils_setFarPointer as utils_setFarPointer, utils_setFloat32 as utils_setFloat32, utils_setFloat64 as utils_setFloat64, utils_setInt16 as utils_setInt16, utils_setInt32 as utils_setInt32, utils_setInt64 as utils_setInt64, utils_setInt8 as utils_setInt8, utils_setInterfacePointer as utils_setInterfacePointer, utils_setListPointer as utils_setListPointer, utils_setStructPointer as utils_setStructPointer, utils_setText as utils_setText, utils_setUint16 as utils_setUint16, utils_setUint32 as utils_setUint32, utils_setUint64 as utils_setUint64, utils_setUint8 as utils_setUint8, utils_testWhich as utils_testWhich, utils_trackPointerAllocation as utils_trackPointerAllocation, utils_validate as utils_validate };
2948
+ }
2949
+ export declare const AnyPointerList: ListCtor<Pointer>;
2950
+ export declare class BoolList extends List<boolean> {
2951
+ static readonly _capnp: _ListCtor;
2952
+ get(index: number): boolean;
2953
+ set(index: number, value: boolean): void;
2954
+ [Symbol.toStringTag](): string;
2955
+ }
2956
+ export declare function CompositeList<T extends Struct>(CompositeClass: StructCtor<T>): ListCtor<T>;
2957
+ export declare const DataList: ListCtor<Data>;
2958
+ export declare class Float32List extends List<number> {
2959
+ static readonly _capnp: _ListCtor;
2960
+ get(index: number): number;
2961
+ set(index: number, value: number): void;
2962
+ [Symbol.toStringTag](): string;
2963
+ }
2964
+ export declare class Float64List extends List<number> {
2965
+ static readonly _capnp: _ListCtor;
2966
+ get(index: number): number;
2967
+ set(index: number, value: number): void;
2968
+ [Symbol.toStringTag](): string;
2969
+ }
2970
+ export declare class Int8List extends List<number> {
2971
+ static readonly _capnp: _ListCtor;
2972
+ get(index: number): number;
2973
+ set(index: number, value: number): void;
2974
+ [Symbol.toStringTag](): string;
2975
+ }
2976
+ export declare class Int16List extends List<number> {
2977
+ static readonly _capnp: _ListCtor;
2978
+ get(index: number): number;
2979
+ set(index: number, value: number): void;
2980
+ [Symbol.toStringTag](): string;
2981
+ }
2982
+ export declare class Int32List extends List<number> {
2983
+ static readonly _capnp: _ListCtor;
2984
+ get(index: number): number;
2985
+ set(index: number, value: number): void;
2986
+ [Symbol.toStringTag](): string;
2987
+ }
2988
+ export declare class Int64List extends List<bigint> {
2989
+ static readonly _capnp: _ListCtor;
2990
+ get(index: number): bigint;
2991
+ set(index: number, value: bigint): void;
2992
+ [Symbol.toStringTag](): string;
2993
+ }
2994
+ export declare const InterfaceList: ListCtor<Interface>;
2995
+ export declare function PointerList<T extends Pointer>(PointerClass: PointerCtor<T>): ListCtor<T>;
2996
+ export declare class TextList extends List<string> {
2997
+ static readonly _capnp: _ListCtor;
2998
+ get(index: number): string;
2999
+ set(index: number, value: string): void;
3000
+ [Symbol.toStringTag](): string;
3001
+ }
3002
+ export declare class Uint8List extends List<number> {
3003
+ static readonly _capnp: _ListCtor;
3004
+ get(index: number): number;
3005
+ set(index: number, value: number): void;
3006
+ [Symbol.toStringTag](): string;
3007
+ }
3008
+ export declare class Uint16List extends List<number> {
3009
+ static readonly _capnp: _ListCtor;
3010
+ get(index: number): number;
3011
+ set(index: number, value: number): void;
3012
+ [Symbol.toStringTag](): string;
3013
+ }
3014
+ export declare class Uint32List extends List<number> {
3015
+ static readonly _capnp: _ListCtor;
3016
+ get(index: number): number;
3017
+ set(index: number, value: number): void;
3018
+ [Symbol.toStringTag](): string;
3019
+ }
3020
+ export declare class Uint64List extends List<bigint> {
3021
+ static readonly _capnp: _ListCtor;
3022
+ get(index: number): bigint;
3023
+ set(index: number, value: bigint): void;
3024
+ [Symbol.toStringTag](): string;
3025
+ }
3026
+ export declare const VoidList: ListCtor<Void>;
3027
+ export declare const getFloat32Mask: (x: number) => DataView;
3028
+ export declare const getFloat64Mask: (x: number) => DataView;
3029
+ export declare const getInt16Mask: (x: number) => DataView;
3030
+ export declare const getInt32Mask: (x: number) => DataView;
3031
+ export declare const getInt64Mask: (x: bigint) => DataView;
3032
+ export declare const getInt8Mask: (x: number) => DataView;
3033
+ export declare const getUint16Mask: (x: number) => DataView;
3034
+ export declare const getUint32Mask: (x: number) => DataView;
3035
+ export declare const getUint64Mask: (x: bigint) => DataView;
3036
+ export declare const getUint8Mask: (x: number) => DataView;
3037
+ export declare function getBitMask(value: boolean, bitOffset: number): DataView;
3038
+ /**
3039
+ * A class that manages Cap'n Proto RPC connections.
3040
+ */
3041
+ export declare class CapnpRPC {
3042
+ protected acceptQueue: Deferred<Conn>[];
3043
+ protected connections: Record<number, Conn>;
3044
+ protected connectQueue: MessagePort$1[];
3045
+ /**
3046
+ * Creates a new {@link Conn} instance.
3047
+ *
3048
+ * @remarks
3049
+ * This class is used to manage connections and accept incoming connections using the {@link MessageChannel} API.
3050
+ */
3051
+ connect(id?: number): Conn;
3052
+ /**
3053
+ * Accepts a connection from the connect queue.
3054
+ *
3055
+ * @returns A promise that resolves to a Conn instance when a connection is accepted.
3056
+ * @throws If no connections are available in the connect queue.
3057
+ */
3058
+ accept(): Promise<Conn>;
3059
+ /**
3060
+ * Closes all connections and clears the queues.
3061
+ *
3062
+ * @remarks
3063
+ * This method will reject all pending accept promises and close all
3064
+ * connections in the connect queue.
3065
+ */
3066
+ close(): void;
3067
+ }
3068
+ export declare class MessageChannelTransport extends DeferredTransport {
3069
+ port: MessagePort$1;
3070
+ constructor(port: MessagePort$1);
3071
+ close: () => void;
3072
+ sendMessage(msg: Message$1): void;
3073
+ }
3074
+ declare class Node_Parameter extends Struct {
3075
+ static readonly _capnp: {
3076
+ displayName: string;
3077
+ id: string;
3078
+ size: ObjectSize;
3079
+ };
3080
+ get name(): string;
3081
+ set name(value: string);
3082
+ toString(): string;
3083
+ }
3084
+ declare class Node_NestedNode extends Struct {
3085
+ static readonly _capnp: {
3086
+ displayName: string;
3087
+ id: string;
3088
+ size: ObjectSize;
3089
+ };
3090
+ /**
3091
+ * Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically.
3092
+ *
3093
+ * (On Zooko's triangle, this is the node's petname according to its parent scope.)
3094
+ *
3095
+ */
3096
+ get name(): string;
3097
+ set name(value: string);
3098
+ /**
3099
+ * ID of the nested node. Typically, the target node's scopeId points back to this node, but
3100
+ * robust code should avoid relying on this.
3101
+ *
3102
+ */
3103
+ get id(): bigint;
3104
+ set id(value: bigint);
3105
+ toString(): string;
3106
+ }
3107
+ declare class Node_SourceInfo_Member extends Struct {
3108
+ static readonly _capnp: {
3109
+ displayName: string;
3110
+ id: string;
3111
+ size: ObjectSize;
3112
+ };
3113
+ /**
3114
+ * Doc comment on the member.
3115
+ *
3116
+ */
3117
+ get docComment(): string;
3118
+ set docComment(value: string);
3119
+ toString(): string;
3120
+ }
3121
+ declare class Node_SourceInfo extends Struct {
3122
+ static readonly Member: typeof Node_SourceInfo_Member;
3123
+ static readonly _capnp: {
3124
+ displayName: string;
3125
+ id: string;
3126
+ size: ObjectSize;
3127
+ };
3128
+ static _Members: ListCtor<Node_SourceInfo_Member>;
3129
+ /**
3130
+ * ID of the Node which this info describes.
3131
+ *
3132
+ */
3133
+ get id(): bigint;
3134
+ set id(value: bigint);
3135
+ /**
3136
+ * The top-level doc comment for the Node.
3137
+ *
3138
+ */
3139
+ get docComment(): string;
3140
+ set docComment(value: string);
3141
+ _adoptMembers(value: Orphan<List<Node_SourceInfo_Member>>): void;
3142
+ _disownMembers(): Orphan<List<Node_SourceInfo_Member>>;
3143
+ /**
3144
+ * Information about each member -- i.e. fields (for structs), enumerants (for enums), or
3145
+ * methods (for interfaces).
3146
+ *
3147
+ * This list is the same length and order as the corresponding list in the Node, i.e.
3148
+ * Node.struct.fields, Node.enum.enumerants, or Node.interface.methods.
3149
+ *
3150
+ */
3151
+ get members(): List<Node_SourceInfo_Member>;
3152
+ _hasMembers(): boolean;
3153
+ _initMembers(length: number): List<Node_SourceInfo_Member>;
3154
+ set members(value: List<Node_SourceInfo_Member>);
3155
+ toString(): string;
3156
+ }
3157
+ declare class Node_Struct extends Struct {
3158
+ static readonly _capnp: {
3159
+ displayName: string;
3160
+ id: string;
3161
+ size: ObjectSize;
3162
+ };
3163
+ static _Fields: ListCtor<Field>;
3164
+ /**
3165
+ * Size of the data section, in words.
3166
+ *
3167
+ */
3168
+ get dataWordCount(): number;
3169
+ set dataWordCount(value: number);
3170
+ /**
3171
+ * Size of the pointer section, in pointers (which are one word each).
3172
+ *
3173
+ */
3174
+ get pointerCount(): number;
3175
+ set pointerCount(value: number);
3176
+ /**
3177
+ * The preferred element size to use when encoding a list of this struct. If this is anything
3178
+ * other than `inlineComposite` then the struct is one word or less in size and is a candidate
3179
+ * for list packing optimization.
3180
+ *
3181
+ */
3182
+ get preferredListEncoding(): ElementSize;
3183
+ set preferredListEncoding(value: ElementSize);
3184
+ /**
3185
+ * If true, then this "struct" node is actually not an independent node, but merely represents
3186
+ * some named union or group within a particular parent struct. This node's scopeId refers
3187
+ * to the parent struct, which may itself be a union/group in yet another struct.
3188
+ *
3189
+ * All group nodes share the same dataWordCount and pointerCount as the top-level
3190
+ * struct, and their fields live in the same ordinal and offset spaces as all other fields in
3191
+ * the struct.
3192
+ *
3193
+ * Note that a named union is considered a special kind of group -- in fact, a named union
3194
+ * is exactly equivalent to a group that contains nothing but an unnamed union.
3195
+ *
3196
+ */
3197
+ get isGroup(): boolean;
3198
+ set isGroup(value: boolean);
3199
+ /**
3200
+ * Number of fields in this struct which are members of an anonymous union, and thus may
3201
+ * overlap. If this is non-zero, then a 16-bit discriminant is present indicating which
3202
+ * of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be
3203
+ * two or more.
3204
+ *
3205
+ * Note that the fields of an unnamed union are considered fields of the scope containing the
3206
+ * union -- an unnamed union is not its own group. So, a top-level struct may contain a
3207
+ * non-zero discriminant count. Named unions, on the other hand, are equivalent to groups
3208
+ * containing unnamed unions. So, a named union has its own independent schema node, with
3209
+ * `isGroup` = true.
3210
+ *
3211
+ */
3212
+ get discriminantCount(): number;
3213
+ set discriminantCount(value: number);
3214
+ /**
3215
+ * If `discriminantCount` is non-zero, this is the offset of the union discriminant, in
3216
+ * multiples of 16 bits.
3217
+ *
3218
+ */
3219
+ get discriminantOffset(): number;
3220
+ set discriminantOffset(value: number);
3221
+ _adoptFields(value: Orphan<List<Field>>): void;
3222
+ _disownFields(): Orphan<List<Field>>;
3223
+ /**
3224
+ * Fields defined within this scope (either the struct's top-level fields, or the fields of
3225
+ * a particular group; see `isGroup`).
3226
+ *
3227
+ * The fields are sorted by ordinal number, but note that because groups share the same
3228
+ * ordinal space, the field's index in this list is not necessarily exactly its ordinal.
3229
+ * On the other hand, the field's position in this list does remain the same even as the
3230
+ * protocol evolves, since it is not possible to insert or remove an earlier ordinal.
3231
+ * Therefore, for most use cases, if you want to identify a field by number, it may make the
3232
+ * most sense to use the field's index in this list rather than its ordinal.
3233
+ *
3234
+ */
3235
+ get fields(): List<Field>;
3236
+ _hasFields(): boolean;
3237
+ _initFields(length: number): List<Field>;
3238
+ set fields(value: List<Field>);
3239
+ toString(): string;
3240
+ }
3241
+ declare class Node_Enum extends Struct {
3242
+ static readonly _capnp: {
3243
+ displayName: string;
3244
+ id: string;
3245
+ size: ObjectSize;
3246
+ };
3247
+ static _Enumerants: ListCtor<Enumerant>;
3248
+ _adoptEnumerants(value: Orphan<List<Enumerant>>): void;
3249
+ _disownEnumerants(): Orphan<List<Enumerant>>;
3250
+ /**
3251
+ * Enumerants ordered by numeric value (ordinal).
3252
+ *
3253
+ */
3254
+ get enumerants(): List<Enumerant>;
3255
+ _hasEnumerants(): boolean;
3256
+ _initEnumerants(length: number): List<Enumerant>;
3257
+ set enumerants(value: List<Enumerant>);
3258
+ toString(): string;
3259
+ }
3260
+ declare class Node_Interface extends Struct {
3261
+ static readonly _capnp: {
3262
+ displayName: string;
3263
+ id: string;
3264
+ size: ObjectSize;
3265
+ };
3266
+ static _Methods: ListCtor<Method$1>;
3267
+ static _Superclasses: ListCtor<Superclass>;
3268
+ _adoptMethods(value: Orphan<List<Method$1>>): void;
3269
+ _disownMethods(): Orphan<List<Method$1>>;
3270
+ /**
3271
+ * Methods ordered by ordinal.
3272
+ *
3273
+ */
3274
+ get methods(): List<Method$1>;
3275
+ _hasMethods(): boolean;
3276
+ _initMethods(length: number): List<Method$1>;
3277
+ set methods(value: List<Method$1>);
3278
+ _adoptSuperclasses(value: Orphan<List<Superclass>>): void;
3279
+ _disownSuperclasses(): Orphan<List<Superclass>>;
3280
+ /**
3281
+ * Superclasses of this interface.
3282
+ *
3283
+ */
3284
+ get superclasses(): List<Superclass>;
3285
+ _hasSuperclasses(): boolean;
3286
+ _initSuperclasses(length: number): List<Superclass>;
3287
+ set superclasses(value: List<Superclass>);
3288
+ toString(): string;
3289
+ }
3290
+ declare class Node_Const extends Struct {
3291
+ static readonly _capnp: {
3292
+ displayName: string;
3293
+ id: string;
3294
+ size: ObjectSize;
3295
+ };
3296
+ _adoptType(value: Orphan<Type>): void;
3297
+ _disownType(): Orphan<Type>;
3298
+ get type(): Type;
3299
+ _hasType(): boolean;
3300
+ _initType(): Type;
3301
+ set type(value: Type);
3302
+ _adoptValue(value: Orphan<Value>): void;
3303
+ _disownValue(): Orphan<Value>;
3304
+ get value(): Value;
3305
+ _hasValue(): boolean;
3306
+ _initValue(): Value;
3307
+ set value(value: Value);
3308
+ toString(): string;
3309
+ }
3310
+ declare class Node_Annotation extends Struct {
3311
+ static readonly _capnp: {
3312
+ displayName: string;
3313
+ id: string;
3314
+ size: ObjectSize;
3315
+ };
3316
+ _adoptType(value: Orphan<Type>): void;
3317
+ _disownType(): Orphan<Type>;
3318
+ get type(): Type;
3319
+ _hasType(): boolean;
3320
+ _initType(): Type;
3321
+ set type(value: Type);
3322
+ get targetsFile(): boolean;
3323
+ set targetsFile(value: boolean);
3324
+ get targetsConst(): boolean;
3325
+ set targetsConst(value: boolean);
3326
+ get targetsEnum(): boolean;
3327
+ set targetsEnum(value: boolean);
3328
+ get targetsEnumerant(): boolean;
3329
+ set targetsEnumerant(value: boolean);
3330
+ get targetsStruct(): boolean;
3331
+ set targetsStruct(value: boolean);
3332
+ get targetsField(): boolean;
3333
+ set targetsField(value: boolean);
3334
+ get targetsUnion(): boolean;
3335
+ set targetsUnion(value: boolean);
3336
+ get targetsGroup(): boolean;
3337
+ set targetsGroup(value: boolean);
3338
+ get targetsInterface(): boolean;
3339
+ set targetsInterface(value: boolean);
3340
+ get targetsMethod(): boolean;
3341
+ set targetsMethod(value: boolean);
3342
+ get targetsParam(): boolean;
3343
+ set targetsParam(value: boolean);
3344
+ get targetsAnnotation(): boolean;
3345
+ set targetsAnnotation(value: boolean);
3346
+ toString(): string;
3347
+ }
3348
+ declare const Node_Which: {
3349
+ readonly FILE: 0;
3350
+ /**
3351
+ * Name to present to humans to identify this Node. You should not attempt to parse this. Its
3352
+ * format could change. It is not guaranteed to be unique.
3353
+ *
3354
+ * (On Zooko's triangle, this is the node's nickname.)
3355
+ *
3356
+ */
3357
+ readonly STRUCT: 1;
3358
+ /**
3359
+ * If you want a shorter version of `displayName` (just naming this node, without its surrounding
3360
+ * scope), chop off this many characters from the beginning of `displayName`.
3361
+ *
3362
+ */
3363
+ readonly ENUM: 2;
3364
+ /**
3365
+ * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
3366
+ * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
3367
+ * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
3368
+ * zero if the node has no parent, which is normally only the case with files, but should be
3369
+ * allowed for any kind of node (in order to make runtime type generation easier).
3370
+ *
3371
+ */
3372
+ readonly INTERFACE: 3;
3373
+ /**
3374
+ * List of nodes nested within this node, along with the names under which they were declared.
3375
+ *
3376
+ */
3377
+ readonly CONST: 4;
3378
+ /**
3379
+ * Annotations applied to this node.
3380
+ *
3381
+ */
3382
+ readonly ANNOTATION: 5;
3383
+ };
3384
+ export type Node_Which = (typeof Node_Which)[keyof typeof Node_Which];
3385
+ declare class Node extends Struct {
3386
+ static readonly FILE: 0;
3387
+ static readonly STRUCT: 1;
3388
+ static readonly ENUM: 2;
3389
+ static readonly INTERFACE: 3;
3390
+ static readonly CONST: 4;
3391
+ static readonly ANNOTATION: 5;
3392
+ static readonly Parameter: typeof Node_Parameter;
3393
+ static readonly NestedNode: typeof Node_NestedNode;
3394
+ static readonly SourceInfo: typeof Node_SourceInfo;
3395
+ static readonly _capnp: {
3396
+ displayName: string;
3397
+ id: string;
3398
+ size: ObjectSize;
3399
+ };
3400
+ static _Parameters: ListCtor<Node_Parameter>;
3401
+ static _NestedNodes: ListCtor<Node_NestedNode>;
3402
+ static _Annotations: ListCtor<Annotation>;
3403
+ get id(): bigint;
3404
+ set id(value: bigint);
3405
+ /**
3406
+ * Name to present to humans to identify this Node. You should not attempt to parse this. Its
3407
+ * format could change. It is not guaranteed to be unique.
3408
+ *
3409
+ * (On Zooko's triangle, this is the node's nickname.)
3410
+ *
3411
+ */
3412
+ get displayName(): string;
3413
+ set displayName(value: string);
3414
+ /**
3415
+ * If you want a shorter version of `displayName` (just naming this node, without its surrounding
3416
+ * scope), chop off this many characters from the beginning of `displayName`.
3417
+ *
3418
+ */
3419
+ get displayNamePrefixLength(): number;
3420
+ set displayNamePrefixLength(value: number);
3421
+ /**
3422
+ * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
3423
+ * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
3424
+ * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
3425
+ * zero if the node has no parent, which is normally only the case with files, but should be
3426
+ * allowed for any kind of node (in order to make runtime type generation easier).
3427
+ *
3428
+ */
3429
+ get scopeId(): bigint;
3430
+ set scopeId(value: bigint);
3431
+ _adoptParameters(value: Orphan<List<Node_Parameter>>): void;
3432
+ _disownParameters(): Orphan<List<Node_Parameter>>;
3433
+ /**
3434
+ * If this node is parameterized (generic), the list of parameters. Empty for non-generic types.
3435
+ *
3436
+ */
3437
+ get parameters(): List<Node_Parameter>;
3438
+ _hasParameters(): boolean;
3439
+ _initParameters(length: number): List<Node_Parameter>;
3440
+ set parameters(value: List<Node_Parameter>);
3441
+ /**
3442
+ * True if this node is generic, meaning that it or one of its parent scopes has a non-empty
3443
+ * `parameters`.
3444
+ *
3445
+ */
3446
+ get isGeneric(): boolean;
3447
+ set isGeneric(value: boolean);
3448
+ _adoptNestedNodes(value: Orphan<List<Node_NestedNode>>): void;
3449
+ _disownNestedNodes(): Orphan<List<Node_NestedNode>>;
3450
+ /**
3451
+ * List of nodes nested within this node, along with the names under which they were declared.
3452
+ *
3453
+ */
3454
+ get nestedNodes(): List<Node_NestedNode>;
3455
+ _hasNestedNodes(): boolean;
3456
+ _initNestedNodes(length: number): List<Node_NestedNode>;
3457
+ set nestedNodes(value: List<Node_NestedNode>);
3458
+ _adoptAnnotations(value: Orphan<List<Annotation>>): void;
3459
+ _disownAnnotations(): Orphan<List<Annotation>>;
3460
+ /**
3461
+ * Annotations applied to this node.
3462
+ *
3463
+ */
3464
+ get annotations(): List<Annotation>;
3465
+ _hasAnnotations(): boolean;
3466
+ _initAnnotations(length: number): List<Annotation>;
3467
+ set annotations(value: List<Annotation>);
3468
+ get _isFile(): boolean;
3469
+ set file(_: true);
3470
+ get struct(): Node_Struct;
3471
+ _initStruct(): Node_Struct;
3472
+ get _isStruct(): boolean;
3473
+ set struct(_: true);
3474
+ get enum(): Node_Enum;
3475
+ _initEnum(): Node_Enum;
3476
+ get _isEnum(): boolean;
3477
+ set enum(_: true);
3478
+ get interface(): Node_Interface;
3479
+ _initInterface(): Node_Interface;
3480
+ get _isInterface(): boolean;
3481
+ set interface(_: true);
3482
+ get const(): Node_Const;
3483
+ _initConst(): Node_Const;
3484
+ get _isConst(): boolean;
3485
+ set const(_: true);
3486
+ get annotation(): Node_Annotation;
3487
+ _initAnnotation(): Node_Annotation;
3488
+ get _isAnnotation(): boolean;
3489
+ set annotation(_: true);
3490
+ toString(): string;
3491
+ which(): Node_Which;
3492
+ }
3493
+ declare class Field_Slot extends Struct {
3494
+ static readonly _capnp: {
3495
+ displayName: string;
3496
+ id: string;
3497
+ size: ObjectSize;
3498
+ };
3499
+ /**
3500
+ * Offset, in units of the field's size, from the beginning of the section in which the field
3501
+ * resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the
3502
+ * beginning of the data section.
3503
+ *
3504
+ */
3505
+ get offset(): number;
3506
+ set offset(value: number);
3507
+ _adoptType(value: Orphan<Type>): void;
3508
+ _disownType(): Orphan<Type>;
3509
+ get type(): Type;
3510
+ _hasType(): boolean;
3511
+ _initType(): Type;
3512
+ set type(value: Type);
3513
+ _adoptDefaultValue(value: Orphan<Value>): void;
3514
+ _disownDefaultValue(): Orphan<Value>;
3515
+ get defaultValue(): Value;
3516
+ _hasDefaultValue(): boolean;
3517
+ _initDefaultValue(): Value;
3518
+ set defaultValue(value: Value);
3519
+ /**
3520
+ * Whether the default value was specified explicitly. Non-explicit default values are always
3521
+ * zero or empty values. Usually, whether the default value was explicit shouldn't matter.
3522
+ * The main use case for this flag is for structs representing method parameters:
3523
+ * explicitly-defaulted parameters may be allowed to be omitted when calling the method.
3524
+ *
3525
+ */
3526
+ get hadExplicitDefault(): boolean;
3527
+ set hadExplicitDefault(value: boolean);
3528
+ toString(): string;
3529
+ }
3530
+ declare class Field_Group extends Struct {
3531
+ static readonly _capnp: {
3532
+ displayName: string;
3533
+ id: string;
3534
+ size: ObjectSize;
3535
+ };
3536
+ /**
3537
+ * The ID of the group's node.
3538
+ *
3539
+ */
3540
+ get typeId(): bigint;
3541
+ set typeId(value: bigint);
3542
+ toString(): string;
3543
+ }
3544
+ declare const Field_Ordinal_Which: {
3545
+ readonly IMPLICIT: 0;
3546
+ /**
3547
+ * The original ordinal number given to the field. You probably should NOT use this; if you need
3548
+ * a numeric identifier for a field, use its position within the field array for its scope.
3549
+ * The ordinal is given here mainly just so that the original schema text can be reproduced given
3550
+ * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
3551
+ *
3552
+ */
3553
+ readonly EXPLICIT: 1;
3554
+ };
3555
+ export type Field_Ordinal_Which = (typeof Field_Ordinal_Which)[keyof typeof Field_Ordinal_Which];
3556
+ declare class Field_Ordinal extends Struct {
3557
+ static readonly IMPLICIT: 0;
3558
+ static readonly EXPLICIT: 1;
3559
+ static readonly _capnp: {
3560
+ displayName: string;
3561
+ id: string;
3562
+ size: ObjectSize;
3563
+ };
3564
+ get _isImplicit(): boolean;
3565
+ set implicit(_: true);
3566
+ /**
3567
+ * The original ordinal number given to the field. You probably should NOT use this; if you need
3568
+ * a numeric identifier for a field, use its position within the field array for its scope.
3569
+ * The ordinal is given here mainly just so that the original schema text can be reproduced given
3570
+ * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
3571
+ *
3572
+ */
3573
+ get explicit(): number;
3574
+ get _isExplicit(): boolean;
3575
+ set explicit(value: number);
3576
+ toString(): string;
3577
+ which(): Field_Ordinal_Which;
3578
+ }
3579
+ declare const Field_Which: {
3580
+ readonly SLOT: 0;
3581
+ /**
3582
+ * Indicates where this member appeared in the code, relative to other members.
3583
+ * Code ordering may have semantic relevance -- programmers tend to place related fields
3584
+ * together. So, using code ordering makes sense in human-readable formats where ordering is
3585
+ * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
3586
+ * value is count(members) - 1. Fields that are members of a union are only ordered relative to
3587
+ * the other members of that union, so the maximum value there is count(union.members).
3588
+ *
3589
+ */
3590
+ readonly GROUP: 1;
3591
+ };
3592
+ export type Field_Which = (typeof Field_Which)[keyof typeof Field_Which];
3593
+ declare class Field extends Struct {
3594
+ static readonly NO_DISCRIMINANT = 65535;
3595
+ static readonly SLOT: 0;
3596
+ static readonly GROUP: 1;
3597
+ static readonly _capnp: {
3598
+ displayName: string;
3599
+ id: string;
3600
+ size: ObjectSize;
3601
+ defaultDiscriminantValue: DataView<ArrayBufferLike>;
3602
+ };
3603
+ static _Annotations: ListCtor<Annotation>;
3604
+ get name(): string;
3605
+ set name(value: string);
3606
+ /**
3607
+ * Indicates where this member appeared in the code, relative to other members.
3608
+ * Code ordering may have semantic relevance -- programmers tend to place related fields
3609
+ * together. So, using code ordering makes sense in human-readable formats where ordering is
3610
+ * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
3611
+ * value is count(members) - 1. Fields that are members of a union are only ordered relative to
3612
+ * the other members of that union, so the maximum value there is count(union.members).
3613
+ *
3614
+ */
3615
+ get codeOrder(): number;
3616
+ set codeOrder(value: number);
3617
+ _adoptAnnotations(value: Orphan<List<Annotation>>): void;
3618
+ _disownAnnotations(): Orphan<List<Annotation>>;
3619
+ get annotations(): List<Annotation>;
3620
+ _hasAnnotations(): boolean;
3621
+ _initAnnotations(length: number): List<Annotation>;
3622
+ set annotations(value: List<Annotation>);
3623
+ /**
3624
+ * If the field is in a union, this is the value which the union's discriminant should take when
3625
+ * the field is active. If the field is not in a union, this is 0xffff.
3626
+ *
3627
+ */
3628
+ get discriminantValue(): number;
3629
+ set discriminantValue(value: number);
3630
+ /**
3631
+ * A regular, non-group, non-fixed-list field.
3632
+ *
3633
+ */
3634
+ get slot(): Field_Slot;
3635
+ _initSlot(): Field_Slot;
3636
+ get _isSlot(): boolean;
3637
+ set slot(_: true);
3638
+ /**
3639
+ * A group.
3640
+ *
3641
+ */
3642
+ get group(): Field_Group;
3643
+ _initGroup(): Field_Group;
3644
+ get _isGroup(): boolean;
3645
+ set group(_: true);
3646
+ get ordinal(): Field_Ordinal;
3647
+ _initOrdinal(): Field_Ordinal;
3648
+ toString(): string;
3649
+ which(): Field_Which;
3650
+ }
3651
+ declare class Enumerant extends Struct {
3652
+ static readonly _capnp: {
3653
+ displayName: string;
3654
+ id: string;
3655
+ size: ObjectSize;
3656
+ };
3657
+ static _Annotations: ListCtor<Annotation>;
3658
+ get name(): string;
3659
+ set name(value: string);
3660
+ /**
3661
+ * Specifies order in which the enumerants were declared in the code.
3662
+ * Like utils.Field.codeOrder.
3663
+ *
3664
+ */
3665
+ get codeOrder(): number;
3666
+ set codeOrder(value: number);
3667
+ _adoptAnnotations(value: Orphan<List<Annotation>>): void;
3668
+ _disownAnnotations(): Orphan<List<Annotation>>;
3669
+ get annotations(): List<Annotation>;
3670
+ _hasAnnotations(): boolean;
3671
+ _initAnnotations(length: number): List<Annotation>;
3672
+ set annotations(value: List<Annotation>);
3673
+ toString(): string;
3674
+ }
3675
+ declare class Superclass extends Struct {
3676
+ static readonly _capnp: {
3677
+ displayName: string;
3678
+ id: string;
3679
+ size: ObjectSize;
3680
+ };
3681
+ get id(): bigint;
3682
+ set id(value: bigint);
3683
+ _adoptBrand(value: Orphan<Brand>): void;
3684
+ _disownBrand(): Orphan<Brand>;
3685
+ get brand(): Brand;
3686
+ _hasBrand(): boolean;
3687
+ _initBrand(): Brand;
3688
+ set brand(value: Brand);
3689
+ toString(): string;
3690
+ }
3691
+ declare class Method$1 extends Struct {
3692
+ static readonly _capnp: {
3693
+ displayName: string;
3694
+ id: string;
3695
+ size: ObjectSize;
3696
+ };
3697
+ static _ImplicitParameters: ListCtor<Node_Parameter>;
3698
+ static _Annotations: ListCtor<Annotation>;
3699
+ get name(): string;
3700
+ set name(value: string);
3701
+ /**
3702
+ * Specifies order in which the methods were declared in the code.
3703
+ * Like utils.Field.codeOrder.
3704
+ *
3705
+ */
3706
+ get codeOrder(): number;
3707
+ set codeOrder(value: number);
3708
+ _adoptImplicitParameters(value: Orphan<List<Node_Parameter>>): void;
3709
+ _disownImplicitParameters(): Orphan<List<Node_Parameter>>;
3710
+ /**
3711
+ * The parameters listed in [] (typically, type / generic parameters), whose bindings are intended
3712
+ * to be inferred rather than specified explicitly, although not all languages support this.
3713
+ *
3714
+ */
3715
+ get implicitParameters(): List<Node_Parameter>;
3716
+ _hasImplicitParameters(): boolean;
3717
+ _initImplicitParameters(length: number): List<Node_Parameter>;
3718
+ set implicitParameters(value: List<Node_Parameter>);
3719
+ /**
3720
+ * ID of the parameter struct type. If a named parameter list was specified in the method
3721
+ * declaration (rather than a single struct parameter type) then a corresponding struct type is
3722
+ * auto-generated. Such an auto-generated type will not be listed in the interface's
3723
+ * `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace.
3724
+ * (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes
3725
+ * this a situation where you can't just climb the scope chain to find where a particular
3726
+ * generic parameter was introduced. Making the `scopeId` zero was a mistake.)
3727
+ *
3728
+ */
3729
+ get paramStructType(): bigint;
3730
+ set paramStructType(value: bigint);
3731
+ _adoptParamBrand(value: Orphan<Brand>): void;
3732
+ _disownParamBrand(): Orphan<Brand>;
3733
+ /**
3734
+ * Brand of param struct type.
3735
+ *
3736
+ */
3737
+ get paramBrand(): Brand;
3738
+ _hasParamBrand(): boolean;
3739
+ _initParamBrand(): Brand;
3740
+ set paramBrand(value: Brand);
3741
+ /**
3742
+ * ID of the return struct type; similar to `paramStructType`.
3743
+ *
3744
+ */
3745
+ get resultStructType(): bigint;
3746
+ set resultStructType(value: bigint);
3747
+ _adoptResultBrand(value: Orphan<Brand>): void;
3748
+ _disownResultBrand(): Orphan<Brand>;
3749
+ /**
3750
+ * Brand of result struct type.
3751
+ *
3752
+ */
3753
+ get resultBrand(): Brand;
3754
+ _hasResultBrand(): boolean;
3755
+ _initResultBrand(): Brand;
3756
+ set resultBrand(value: Brand);
3757
+ _adoptAnnotations(value: Orphan<List<Annotation>>): void;
3758
+ _disownAnnotations(): Orphan<List<Annotation>>;
3759
+ get annotations(): List<Annotation>;
3760
+ _hasAnnotations(): boolean;
3761
+ _initAnnotations(length: number): List<Annotation>;
3762
+ set annotations(value: List<Annotation>);
3763
+ toString(): string;
3764
+ }
3765
+ declare class Type_List extends Struct {
3766
+ static readonly _capnp: {
3767
+ displayName: string;
3768
+ id: string;
3769
+ size: ObjectSize;
3770
+ };
3771
+ _adoptElementType(value: Orphan<Type>): void;
3772
+ _disownElementType(): Orphan<Type>;
3773
+ get elementType(): Type;
3774
+ _hasElementType(): boolean;
3775
+ _initElementType(): Type;
3776
+ set elementType(value: Type);
3777
+ toString(): string;
3778
+ }
3779
+ declare class Type_Enum extends Struct {
3780
+ static readonly _capnp: {
3781
+ displayName: string;
3782
+ id: string;
3783
+ size: ObjectSize;
3784
+ };
3785
+ get typeId(): bigint;
3786
+ set typeId(value: bigint);
3787
+ _adoptBrand(value: Orphan<Brand>): void;
3788
+ _disownBrand(): Orphan<Brand>;
3789
+ get brand(): Brand;
3790
+ _hasBrand(): boolean;
3791
+ _initBrand(): Brand;
3792
+ set brand(value: Brand);
3793
+ toString(): string;
3794
+ }
3795
+ declare class Type_Struct extends Struct {
3796
+ static readonly _capnp: {
3797
+ displayName: string;
3798
+ id: string;
3799
+ size: ObjectSize;
3800
+ };
3801
+ get typeId(): bigint;
3802
+ set typeId(value: bigint);
3803
+ _adoptBrand(value: Orphan<Brand>): void;
3804
+ _disownBrand(): Orphan<Brand>;
3805
+ get brand(): Brand;
3806
+ _hasBrand(): boolean;
3807
+ _initBrand(): Brand;
3808
+ set brand(value: Brand);
3809
+ toString(): string;
3810
+ }
3811
+ declare class Type_Interface extends Struct {
3812
+ static readonly _capnp: {
3813
+ displayName: string;
3814
+ id: string;
3815
+ size: ObjectSize;
3816
+ };
3817
+ get typeId(): bigint;
3818
+ set typeId(value: bigint);
3819
+ _adoptBrand(value: Orphan<Brand>): void;
3820
+ _disownBrand(): Orphan<Brand>;
3821
+ get brand(): Brand;
3822
+ _hasBrand(): boolean;
3823
+ _initBrand(): Brand;
3824
+ set brand(value: Brand);
3825
+ toString(): string;
3826
+ }
3827
+ declare const Type_AnyPointer_Unconstrained_Which: {
3828
+ /**
3829
+ * truly AnyPointer
3830
+ *
3831
+ */
3832
+ readonly ANY_KIND: 0;
3833
+ /**
3834
+ * AnyStruct
3835
+ *
3836
+ */
3837
+ readonly STRUCT: 1;
3838
+ /**
3839
+ * AnyList
3840
+ *
3841
+ */
3842
+ readonly LIST: 2;
3843
+ /**
3844
+ * Capability
3845
+ *
3846
+ */
3847
+ readonly CAPABILITY: 3;
3848
+ };
3849
+ export type Type_AnyPointer_Unconstrained_Which = (typeof Type_AnyPointer_Unconstrained_Which)[keyof typeof Type_AnyPointer_Unconstrained_Which];
3850
+ declare class Type_AnyPointer_Unconstrained extends Struct {
3851
+ static readonly ANY_KIND: 0;
3852
+ static readonly STRUCT: 1;
3853
+ static readonly LIST: 2;
3854
+ static readonly CAPABILITY: 3;
3855
+ static readonly _capnp: {
3856
+ displayName: string;
3857
+ id: string;
3858
+ size: ObjectSize;
3859
+ };
3860
+ get _isAnyKind(): boolean;
3861
+ set anyKind(_: true);
3862
+ get _isStruct(): boolean;
3863
+ set struct(_: true);
3864
+ get _isList(): boolean;
3865
+ set list(_: true);
3866
+ get _isCapability(): boolean;
3867
+ set capability(_: true);
3868
+ toString(): string;
3869
+ which(): Type_AnyPointer_Unconstrained_Which;
3870
+ }
3871
+ declare class Type_AnyPointer_Parameter extends Struct {
3872
+ static readonly _capnp: {
3873
+ displayName: string;
3874
+ id: string;
3875
+ size: ObjectSize;
3876
+ };
3877
+ /**
3878
+ * ID of the generic type whose parameter we're referencing. This should be a parent of the
3879
+ * current scope.
3880
+ *
3881
+ */
3882
+ get scopeId(): bigint;
3883
+ set scopeId(value: bigint);
3884
+ /**
3885
+ * Index of the parameter within the generic type's parameter list.
3886
+ *
3887
+ */
3888
+ get parameterIndex(): number;
3889
+ set parameterIndex(value: number);
3890
+ toString(): string;
3891
+ }
3892
+ declare class Type_AnyPointer_ImplicitMethodParameter extends Struct {
3893
+ static readonly _capnp: {
3894
+ displayName: string;
3895
+ id: string;
3896
+ size: ObjectSize;
3897
+ };
3898
+ get parameterIndex(): number;
3899
+ set parameterIndex(value: number);
3900
+ toString(): string;
3901
+ }
3902
+ declare const Type_AnyPointer_Which: {
3903
+ /**
3904
+ * A regular AnyPointer.
3905
+ *
3906
+ * The name "unconstrained" means as opposed to constraining it to match a type parameter.
3907
+ * In retrospect this name is probably a poor choice given that it may still be constrained
3908
+ * to be a struct, list, or capability.
3909
+ *
3910
+ */
3911
+ readonly UNCONSTRAINED: 0;
3912
+ /**
3913
+ * This is actually a reference to a type parameter defined within this scope.
3914
+ *
3915
+ */
3916
+ readonly PARAMETER: 1;
3917
+ /**
3918
+ * This is actually a reference to an implicit (generic) parameter of a method. The only
3919
+ * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
3920
+ *
3921
+ */
3922
+ readonly IMPLICIT_METHOD_PARAMETER: 2;
3923
+ };
3924
+ export type Type_AnyPointer_Which = (typeof Type_AnyPointer_Which)[keyof typeof Type_AnyPointer_Which];
3925
+ declare class Type_AnyPointer extends Struct {
3926
+ static readonly UNCONSTRAINED: 0;
3927
+ static readonly PARAMETER: 1;
3928
+ static readonly IMPLICIT_METHOD_PARAMETER: 2;
3929
+ static readonly _capnp: {
3930
+ displayName: string;
3931
+ id: string;
3932
+ size: ObjectSize;
3933
+ };
3934
+ /**
3935
+ * A regular AnyPointer.
3936
+ *
3937
+ * The name "unconstrained" means as opposed to constraining it to match a type parameter.
3938
+ * In retrospect this name is probably a poor choice given that it may still be constrained
3939
+ * to be a struct, list, or capability.
3940
+ *
3941
+ */
3942
+ get unconstrained(): Type_AnyPointer_Unconstrained;
3943
+ _initUnconstrained(): Type_AnyPointer_Unconstrained;
3944
+ get _isUnconstrained(): boolean;
3945
+ set unconstrained(_: true);
3946
+ /**
3947
+ * This is actually a reference to a type parameter defined within this scope.
3948
+ *
3949
+ */
3950
+ get parameter(): Type_AnyPointer_Parameter;
3951
+ _initParameter(): Type_AnyPointer_Parameter;
3952
+ get _isParameter(): boolean;
3953
+ set parameter(_: true);
3954
+ /**
3955
+ * This is actually a reference to an implicit (generic) parameter of a method. The only
3956
+ * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
3957
+ *
3958
+ */
3959
+ get implicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter;
3960
+ _initImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter;
3961
+ get _isImplicitMethodParameter(): boolean;
3962
+ set implicitMethodParameter(_: true);
3963
+ toString(): string;
3964
+ which(): Type_AnyPointer_Which;
3965
+ }
3966
+ declare const Type_Which: {
3967
+ readonly VOID: 0;
3968
+ readonly BOOL: 1;
3969
+ readonly INT8: 2;
3970
+ readonly INT16: 3;
3971
+ readonly INT32: 4;
3972
+ readonly INT64: 5;
3973
+ readonly UINT8: 6;
3974
+ readonly UINT16: 7;
3975
+ readonly UINT32: 8;
3976
+ readonly UINT64: 9;
3977
+ readonly FLOAT32: 10;
3978
+ readonly FLOAT64: 11;
3979
+ readonly TEXT: 12;
3980
+ readonly DATA: 13;
3981
+ readonly LIST: 14;
3982
+ readonly ENUM: 15;
3983
+ readonly STRUCT: 16;
3984
+ readonly INTERFACE: 17;
3985
+ readonly ANY_POINTER: 18;
3986
+ };
3987
+ export type Type_Which = (typeof Type_Which)[keyof typeof Type_Which];
3988
+ declare class Type extends Struct {
3989
+ static readonly VOID: 0;
3990
+ static readonly BOOL: 1;
3991
+ static readonly INT8: 2;
3992
+ static readonly INT16: 3;
3993
+ static readonly INT32: 4;
3994
+ static readonly INT64: 5;
3995
+ static readonly UINT8: 6;
3996
+ static readonly UINT16: 7;
3997
+ static readonly UINT32: 8;
3998
+ static readonly UINT64: 9;
3999
+ static readonly FLOAT32: 10;
4000
+ static readonly FLOAT64: 11;
4001
+ static readonly TEXT: 12;
4002
+ static readonly DATA: 13;
4003
+ static readonly LIST: 14;
4004
+ static readonly ENUM: 15;
4005
+ static readonly STRUCT: 16;
4006
+ static readonly INTERFACE: 17;
4007
+ static readonly ANY_POINTER: 18;
4008
+ static readonly _capnp: {
4009
+ displayName: string;
4010
+ id: string;
4011
+ size: ObjectSize;
4012
+ };
4013
+ get _isVoid(): boolean;
4014
+ set void(_: true);
4015
+ get _isBool(): boolean;
4016
+ set bool(_: true);
4017
+ get _isInt8(): boolean;
4018
+ set int8(_: true);
4019
+ get _isInt16(): boolean;
4020
+ set int16(_: true);
4021
+ get _isInt32(): boolean;
4022
+ set int32(_: true);
4023
+ get _isInt64(): boolean;
4024
+ set int64(_: true);
4025
+ get _isUint8(): boolean;
4026
+ set uint8(_: true);
4027
+ get _isUint16(): boolean;
4028
+ set uint16(_: true);
4029
+ get _isUint32(): boolean;
4030
+ set uint32(_: true);
4031
+ get _isUint64(): boolean;
4032
+ set uint64(_: true);
4033
+ get _isFloat32(): boolean;
4034
+ set float32(_: true);
4035
+ get _isFloat64(): boolean;
4036
+ set float64(_: true);
4037
+ get _isText(): boolean;
4038
+ set text(_: true);
4039
+ get _isData(): boolean;
4040
+ set data(_: true);
4041
+ get list(): Type_List;
4042
+ _initList(): Type_List;
4043
+ get _isList(): boolean;
4044
+ set list(_: true);
4045
+ get enum(): Type_Enum;
4046
+ _initEnum(): Type_Enum;
4047
+ get _isEnum(): boolean;
4048
+ set enum(_: true);
4049
+ get struct(): Type_Struct;
4050
+ _initStruct(): Type_Struct;
4051
+ get _isStruct(): boolean;
4052
+ set struct(_: true);
4053
+ get interface(): Type_Interface;
4054
+ _initInterface(): Type_Interface;
4055
+ get _isInterface(): boolean;
4056
+ set interface(_: true);
4057
+ get anyPointer(): Type_AnyPointer;
4058
+ _initAnyPointer(): Type_AnyPointer;
4059
+ get _isAnyPointer(): boolean;
4060
+ set anyPointer(_: true);
4061
+ toString(): string;
4062
+ which(): Type_Which;
4063
+ }
4064
+ declare const Brand_Scope_Which: {
4065
+ /**
4066
+ * ID of the scope to which these params apply.
4067
+ *
4068
+ */
4069
+ readonly BIND: 0;
4070
+ /**
4071
+ * List of parameter bindings.
4072
+ *
4073
+ */
4074
+ readonly INHERIT: 1;
4075
+ };
4076
+ export type Brand_Scope_Which = (typeof Brand_Scope_Which)[keyof typeof Brand_Scope_Which];
4077
+ declare class Brand_Scope extends Struct {
4078
+ static readonly BIND: 0;
4079
+ static readonly INHERIT: 1;
4080
+ static readonly _capnp: {
4081
+ displayName: string;
4082
+ id: string;
4083
+ size: ObjectSize;
4084
+ };
4085
+ static _Bind: ListCtor<Brand_Binding>;
4086
+ /**
4087
+ * ID of the scope to which these params apply.
4088
+ *
4089
+ */
4090
+ get scopeId(): bigint;
4091
+ set scopeId(value: bigint);
4092
+ _adoptBind(value: Orphan<List<Brand_Binding>>): void;
4093
+ _disownBind(): Orphan<List<Brand_Binding>>;
4094
+ /**
4095
+ * List of parameter bindings.
4096
+ *
4097
+ */
4098
+ get bind(): List<Brand_Binding>;
4099
+ _hasBind(): boolean;
4100
+ _initBind(length: number): List<Brand_Binding>;
4101
+ get _isBind(): boolean;
4102
+ set bind(value: List<Brand_Binding>);
4103
+ get _isInherit(): boolean;
4104
+ set inherit(_: true);
4105
+ toString(): string;
4106
+ which(): Brand_Scope_Which;
4107
+ }
4108
+ declare const Brand_Binding_Which: {
4109
+ readonly UNBOUND: 0;
4110
+ readonly TYPE: 1;
4111
+ };
4112
+ export type Brand_Binding_Which = (typeof Brand_Binding_Which)[keyof typeof Brand_Binding_Which];
4113
+ declare class Brand_Binding extends Struct {
4114
+ static readonly UNBOUND: 0;
4115
+ static readonly TYPE: 1;
4116
+ static readonly _capnp: {
4117
+ displayName: string;
4118
+ id: string;
4119
+ size: ObjectSize;
4120
+ };
4121
+ get _isUnbound(): boolean;
4122
+ set unbound(_: true);
4123
+ _adoptType(value: Orphan<Type>): void;
4124
+ _disownType(): Orphan<Type>;
4125
+ get type(): Type;
4126
+ _hasType(): boolean;
4127
+ _initType(): Type;
4128
+ get _isType(): boolean;
4129
+ set type(value: Type);
4130
+ toString(): string;
4131
+ which(): Brand_Binding_Which;
4132
+ }
4133
+ declare class Brand extends Struct {
4134
+ static readonly Scope: typeof Brand_Scope;
4135
+ static readonly Binding: typeof Brand_Binding;
4136
+ static readonly _capnp: {
4137
+ displayName: string;
4138
+ id: string;
4139
+ size: ObjectSize;
4140
+ };
4141
+ static _Scopes: ListCtor<Brand_Scope>;
4142
+ _adoptScopes(value: Orphan<List<Brand_Scope>>): void;
4143
+ _disownScopes(): Orphan<List<Brand_Scope>>;
4144
+ /**
4145
+ * For each of the target type and each of its parent scopes, a parameterization may be included
4146
+ * in this list. If no parameterization is included for a particular relevant scope, then either
4147
+ * that scope has no parameters or all parameters should be considered to be `AnyPointer`.
4148
+ *
4149
+ */
4150
+ get scopes(): List<Brand_Scope>;
4151
+ _hasScopes(): boolean;
4152
+ _initScopes(length: number): List<Brand_Scope>;
4153
+ set scopes(value: List<Brand_Scope>);
4154
+ toString(): string;
4155
+ }
4156
+ declare const Value_Which: {
4157
+ readonly VOID: 0;
4158
+ readonly BOOL: 1;
4159
+ readonly INT8: 2;
4160
+ readonly INT16: 3;
4161
+ readonly INT32: 4;
4162
+ readonly INT64: 5;
4163
+ readonly UINT8: 6;
4164
+ readonly UINT16: 7;
4165
+ readonly UINT32: 8;
4166
+ readonly UINT64: 9;
4167
+ readonly FLOAT32: 10;
4168
+ readonly FLOAT64: 11;
4169
+ readonly TEXT: 12;
4170
+ readonly DATA: 13;
4171
+ readonly LIST: 14;
4172
+ readonly ENUM: 15;
4173
+ readonly STRUCT: 16;
4174
+ /**
4175
+ * The only interface value that can be represented statically is "null", whose methods always
4176
+ * throw exceptions.
4177
+ *
4178
+ */
4179
+ readonly INTERFACE: 17;
4180
+ readonly ANY_POINTER: 18;
4181
+ };
4182
+ export type Value_Which = (typeof Value_Which)[keyof typeof Value_Which];
4183
+ declare class Value extends Struct {
4184
+ static readonly VOID: 0;
4185
+ static readonly BOOL: 1;
4186
+ static readonly INT8: 2;
4187
+ static readonly INT16: 3;
4188
+ static readonly INT32: 4;
4189
+ static readonly INT64: 5;
4190
+ static readonly UINT8: 6;
4191
+ static readonly UINT16: 7;
4192
+ static readonly UINT32: 8;
4193
+ static readonly UINT64: 9;
4194
+ static readonly FLOAT32: 10;
4195
+ static readonly FLOAT64: 11;
4196
+ static readonly TEXT: 12;
4197
+ static readonly DATA: 13;
4198
+ static readonly LIST: 14;
4199
+ static readonly ENUM: 15;
4200
+ static readonly STRUCT: 16;
4201
+ static readonly INTERFACE: 17;
4202
+ static readonly ANY_POINTER: 18;
4203
+ static readonly _capnp: {
4204
+ displayName: string;
4205
+ id: string;
4206
+ size: ObjectSize;
4207
+ };
4208
+ get _isVoid(): boolean;
4209
+ set void(_: true);
4210
+ get bool(): boolean;
4211
+ get _isBool(): boolean;
4212
+ set bool(value: boolean);
4213
+ get int8(): number;
4214
+ get _isInt8(): boolean;
4215
+ set int8(value: number);
4216
+ get int16(): number;
4217
+ get _isInt16(): boolean;
4218
+ set int16(value: number);
4219
+ get int32(): number;
4220
+ get _isInt32(): boolean;
4221
+ set int32(value: number);
4222
+ get int64(): bigint;
4223
+ get _isInt64(): boolean;
4224
+ set int64(value: bigint);
4225
+ get uint8(): number;
4226
+ get _isUint8(): boolean;
4227
+ set uint8(value: number);
4228
+ get uint16(): number;
4229
+ get _isUint16(): boolean;
4230
+ set uint16(value: number);
4231
+ get uint32(): number;
4232
+ get _isUint32(): boolean;
4233
+ set uint32(value: number);
4234
+ get uint64(): bigint;
4235
+ get _isUint64(): boolean;
4236
+ set uint64(value: bigint);
4237
+ get float32(): number;
4238
+ get _isFloat32(): boolean;
4239
+ set float32(value: number);
4240
+ get float64(): number;
4241
+ get _isFloat64(): boolean;
4242
+ set float64(value: number);
4243
+ get text(): string;
4244
+ get _isText(): boolean;
4245
+ set text(value: string);
4246
+ _adoptData(value: Orphan<Data>): void;
4247
+ _disownData(): Orphan<Data>;
4248
+ get data(): Data;
4249
+ _hasData(): boolean;
4250
+ _initData(length: number): Data;
4251
+ get _isData(): boolean;
4252
+ set data(value: Data);
4253
+ _adoptList(value: Orphan<Pointer>): void;
4254
+ _disownList(): Orphan<Pointer>;
4255
+ get list(): Pointer;
4256
+ _hasList(): boolean;
4257
+ get _isList(): boolean;
4258
+ set list(value: Pointer);
4259
+ get enum(): number;
4260
+ get _isEnum(): boolean;
4261
+ set enum(value: number);
4262
+ _adoptStruct(value: Orphan<Pointer>): void;
4263
+ _disownStruct(): Orphan<Pointer>;
4264
+ get struct(): Pointer;
4265
+ _hasStruct(): boolean;
4266
+ get _isStruct(): boolean;
4267
+ set struct(value: Pointer);
4268
+ get _isInterface(): boolean;
4269
+ set interface(_: true);
4270
+ _adoptAnyPointer(value: Orphan<Pointer>): void;
4271
+ _disownAnyPointer(): Orphan<Pointer>;
4272
+ get anyPointer(): Pointer;
4273
+ _hasAnyPointer(): boolean;
4274
+ get _isAnyPointer(): boolean;
4275
+ set anyPointer(value: Pointer);
4276
+ toString(): string;
4277
+ which(): Value_Which;
4278
+ }
4279
+ declare class Annotation extends Struct {
4280
+ static readonly _capnp: {
4281
+ displayName: string;
4282
+ id: string;
4283
+ size: ObjectSize;
4284
+ };
4285
+ /**
4286
+ * ID of the annotation node.
4287
+ *
4288
+ */
4289
+ get id(): bigint;
4290
+ set id(value: bigint);
4291
+ _adoptBrand(value: Orphan<Brand>): void;
4292
+ _disownBrand(): Orphan<Brand>;
4293
+ /**
4294
+ * Brand of the annotation.
4295
+ *
4296
+ * Note that the annotation itself is not allowed to be parameterized, but its scope might be.
4297
+ *
4298
+ */
4299
+ get brand(): Brand;
4300
+ _hasBrand(): boolean;
4301
+ _initBrand(): Brand;
4302
+ set brand(value: Brand);
4303
+ _adoptValue(value: Orphan<Value>): void;
4304
+ _disownValue(): Orphan<Value>;
4305
+ get value(): Value;
4306
+ _hasValue(): boolean;
4307
+ _initValue(): Value;
4308
+ set value(value: Value);
4309
+ toString(): string;
4310
+ }
4311
+ declare const ElementSize: {
4312
+ /**
4313
+ * aka "void", but that's a keyword.
4314
+ *
4315
+ */
4316
+ readonly EMPTY: 0;
4317
+ readonly BIT: 1;
4318
+ readonly BYTE: 2;
4319
+ readonly TWO_BYTES: 3;
4320
+ readonly FOUR_BYTES: 4;
4321
+ readonly EIGHT_BYTES: 5;
4322
+ readonly POINTER: 6;
4323
+ readonly INLINE_COMPOSITE: 7;
4324
+ };
4325
+ export type ElementSize = (typeof ElementSize)[keyof typeof ElementSize];
4326
+ declare class CodeGeneratorRequest_RequestedFile_Import extends Struct {
4327
+ static readonly _capnp: {
4328
+ displayName: string;
4329
+ id: string;
4330
+ size: ObjectSize;
4331
+ };
4332
+ /**
4333
+ * ID of the imported file.
4334
+ *
4335
+ */
4336
+ get id(): bigint;
4337
+ set id(value: bigint);
4338
+ /**
4339
+ * Name which *this* file used to refer to the foreign file. This may be a relative name.
4340
+ * This information is provided because it might be useful for code generation, e.g. to
4341
+ * generate #include directives in C++. We don't put this in Node.file because this
4342
+ * information is only meaningful at compile time anyway.
4343
+ *
4344
+ * (On Zooko's triangle, this is the import's petname according to the importing file.)
4345
+ *
4346
+ */
4347
+ get name(): string;
4348
+ set name(value: string);
4349
+ toString(): string;
4350
+ }
4351
+ export interface CodeGeneratorFileContext {
4352
+ readonly nodes: Node[];
4353
+ readonly imports: CodeGeneratorRequest_RequestedFile_Import[];
4354
+ concreteLists: Array<[
4355
+ string,
4356
+ Field
4357
+ ]>;
4358
+ generatedNodeIds: Set<string>;
4359
+ generatedResultsPromiseIds: Set<bigint>;
4360
+ tsPath: string;
4361
+ codeParts?: string[];
4362
+ constructor: any;
4363
+ toString: () => string;
4364
+ }
4365
+ export declare class CodeGeneratorContext {
4366
+ files: CodeGeneratorFileContext[];
4367
+ }
4368
+ export interface CapnpcCLIOptions {
4369
+ ts?: boolean;
4370
+ noTs?: boolean;
4371
+ js?: boolean;
4372
+ dts?: boolean;
4373
+ noDts?: boolean;
4374
+ schema: string;
4375
+ output?: string;
4376
+ importPath?: string[];
4377
+ tsconfig: string;
4378
+ generateId?: boolean;
4379
+ standardImport?: boolean;
4380
+ projectRoot: string;
4381
+ workspaceRoot: string;
4382
+ tty?: boolean;
4383
+ }
4384
+ export type CapnpcOptions = Omit<CapnpcCLIOptions, "noTs" | "noDts" | "tsconfig" | "schema"> & {
4385
+ tsconfig: ParsedCommandLine;
4386
+ schemas: string[];
4387
+ };
4388
+ export interface CapnpcResult {
4389
+ ctx: CodeGeneratorContext;
4390
+ files: Map<string, string>;
4391
+ }
4392
+
4393
+ export {};