import { ParsedCommandLine } from 'typescript'; export declare enum ListElementSize { VOID = 0, BIT = 1, BYTE = 2, BYTE_2 = 3, BYTE_4 = 4, BYTE_8 = 5, POINTER = 6, COMPOSITE = 7 } /** * A simple object that describes the size of a struct. */ export declare class ObjectSize { readonly dataByteLength: number; readonly pointerLength: number; /** * Creates a new ObjectSize instance. * * @param dataByteLength - The number of bytes in the data section of the struct * @param pointerLength - The number of pointers in the pointer section of the struct */ constructor(dataByteLength: number, pointerLength: number); toString(): string; } export interface _PointerCtor { readonly displayName: string; } export interface PointerCtor { readonly _capnp: _PointerCtor; new (segment: Segment, byteOffset: number, depthLimit?: number): T; } export declare enum PointerType { STRUCT = 0, LIST = 1, FAR = 2, OTHER = 3 } export interface _Pointer { compositeIndex?: number; compositeList: boolean; /** * A number that is decremented as nested pointers are traversed. When this hits zero errors will be thrown. */ depthLimit: number; } /** * A pointer referencing a single byte location in a segment. This is typically used for Cap'n Proto pointers, but is * also sometimes used to reference an offset to a pointer's content or tag words. */ export declare class Pointer { static readonly _capnp: _PointerCtor; readonly _capnp: T; /** Offset, in bytes, from the start of the segment to the beginning of this pointer. */ byteOffset: number; /** * The starting segment for this pointer's data. In the case of a far pointer, the actual content this pointer is * referencing will be in another segment within the same message. */ segment: Segment; constructor(segment: Segment, byteOffset: number, depthLimit?: number); [Symbol.toStringTag](): string; toString(): string; } export interface _ListCtor { readonly compositeSize?: ObjectSize; readonly displayName: string; readonly size: ListElementSize; } export interface ListCtor { readonly _capnp: _ListCtor; new (segment: Segment, byteOffset: number, depthLimit?: number): List; } export type ArrayCb = (this: any, value: T, index: number, array: T[]) => RT; /** * A generic list class. Implements Filterable, */ export declare class List extends Pointer implements Array { #private; static readonly _capnp: _ListCtor; [n: number]: T; constructor(segment: Segment, byteOffset: number, depthLimit?: number); get length(): number; toArray(): T[]; get(_index: number): T; set(_index: number, _value: T): void; at(index: number): T; concat(other: T[]): T[]; some(cb: ArrayCb, _this?: any): boolean; filter(cb: ArrayCb, _this?: any): T[]; find(cb: ArrayCb, _this?: any): T | undefined; findIndex(cb: (v: T, i: number, arr: T[]) => boolean, _this?: any): number; forEach(cb: ArrayCb, _this?: any): void; map(cb: ArrayCb, _this?: any): U[]; flatMap(cb: ArrayCb, _this?: any): U[]; every(cb: (v: T, i: number) => v is S, t?: any): this is S[]; reduce(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T; reduceRight(cb: (p: T, c: T, i: number, a: T[]) => T, initialValue?: T): T; slice(start?: number, end?: number): T[]; join(separator?: string): string; toReversed(): T[]; toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[]; toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; fill(value: T, start?: number, end?: number): this; copyWithin(target: number, start: number, end?: number): this; keys(): ArrayIterator; values(): ArrayIterator; entries(): ArrayIterator<[ number, T ]>; flat(this: A, depth?: D): FlatArray[]; with(index: number, value: T): T[]; includes(_searchElement: T, _fromIndex?: number): boolean; findLast(_cb: unknown, _thisArg?: unknown): T | undefined; findLastIndex(_cb: (v: T, i: number, a: T[]) => unknown, _t?: any): number; indexOf(_searchElement: T, _fromIndex?: number): number; lastIndexOf(_searchElement: T, _fromIndex?: number): number; pop(): T | undefined; push(..._items: T[]): number; reverse(): T[]; shift(): T | undefined; unshift(..._items: T[]): number; splice(_start: unknown, _deleteCount?: unknown, ..._rest: unknown[]): T[]; sort(_fn?: ((a: T, b: T) => number) | undefined): this; get [Symbol.unscopables](): { [x: number]: boolean | undefined; length?: boolean | undefined; toString?: boolean | undefined; toLocaleString?: boolean | undefined; pop?: boolean | undefined; push?: boolean | undefined; concat?: boolean | undefined; join?: boolean | undefined; reverse?: boolean | undefined; shift?: boolean | undefined; slice?: boolean | undefined; sort?: boolean | undefined; splice?: boolean | undefined; unshift?: boolean | undefined; indexOf?: boolean | undefined; lastIndexOf?: boolean | undefined; every?: boolean | undefined; some?: boolean | undefined; forEach?: boolean | undefined; map?: boolean | undefined; filter?: boolean | undefined; reduce?: boolean | undefined; reduceRight?: boolean | undefined; find?: boolean | undefined; findIndex?: boolean | undefined; fill?: boolean | undefined; copyWithin?: boolean | undefined; entries?: boolean | undefined; keys?: boolean | undefined; values?: boolean | undefined; includes?: boolean | undefined; flatMap?: boolean | undefined; flat?: boolean | undefined; at?: boolean | undefined; findLast?: boolean | undefined; findLastIndex?: boolean | undefined; toReversed?: boolean | undefined; toSorted?: boolean | undefined; toSpliced?: boolean | undefined; with?: boolean | undefined; [Symbol.iterator]?: boolean | undefined; readonly [Symbol.unscopables]?: boolean | undefined; }; [Symbol.iterator](): ArrayIterator; toJSON(): unknown; toString(): string; toLocaleString(_locales?: unknown, _options?: unknown): string; [Symbol.toStringTag](): string; static [Symbol.toStringTag](): string; } declare const Message_Which: { /** * The sender previously received this message from the peer but didn't understand it or doesn't * yet implement the functionality that was requested. So, the sender is echoing the message * back. In some cases, the receiver may be able to recover from this by pretending the sender * had taken some appropriate "null" action. * * For example, say `resolve` is received by a level 0 implementation (because a previous call * or return happened to contain a promise). The level 0 implementation will echo it back as * `unimplemented`. The original sender can then simply release the cap to which the promise * had resolved, thus avoiding a leak. * * For any message type that introduces a question, if the message comes back unimplemented, * the original sender may simply treat it as if the question failed with an exception. * * In cases where there is no sensible way to react to an `unimplemented` message (without * resource leaks or other serious problems), the connection may need to be aborted. This is * a gray area; different implementations may take different approaches. * */ readonly UNIMPLEMENTED: 0; /** * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g. * because the sender received an invalid or nonsensical message or because the sender had an * internal error. The sender will shut down the outgoing half of the connection after `abort` * and will completely close the connection shortly thereafter (it's up to the sender how much * of a time buffer they want to offer for the client to receive the `abort` before the * connection is reset). * */ readonly ABORT: 1; /** * Request the peer's bootstrap interface. * */ readonly BOOTSTRAP: 8; /** * Begin a method call. * */ readonly CALL: 2; /** * Complete a method call. * */ readonly RETURN: 3; /** * Release a returned answer / cancel a call. * */ readonly FINISH: 4; /** * Resolve a previously-sent promise. * */ readonly RESOLVE: 5; /** * Release a capability so that the remote object can be deallocated. * */ readonly RELEASE: 6; /** * Lift an embargo used to enforce E-order over promise resolution. * */ readonly DISEMBARGO: 13; /** * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced * by the `Persistent` interface defined in `persistent.capnp`. This operation was never * implemented. * */ readonly OBSOLETE_SAVE: 7; /** * Obsolete way to delete a SturdyRef. This operation was never implemented. * */ readonly OBSOLETE_DELETE: 9; /** * Provide a capability to a third party. * */ readonly PROVIDE: 10; /** * Accept a capability provided by a third party. * */ readonly ACCEPT: 11; /** * Directly connect to the common root of two or more proxied caps. * */ readonly JOIN: 12; }; export type Message_Which = (typeof Message_Which)[keyof typeof Message_Which]; declare class Message$1 extends Struct { static readonly UNIMPLEMENTED: 0; static readonly ABORT: 1; static readonly BOOTSTRAP: 8; static readonly CALL: 2; static readonly RETURN: 3; static readonly FINISH: 4; static readonly RESOLVE: 5; static readonly RELEASE: 6; static readonly DISEMBARGO: 13; static readonly OBSOLETE_SAVE: 7; static readonly OBSOLETE_DELETE: 9; static readonly PROVIDE: 10; static readonly ACCEPT: 11; static readonly JOIN: 12; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptUnimplemented(value: Orphan): void; _disownUnimplemented(): Orphan; /** * The sender previously received this message from the peer but didn't understand it or doesn't * yet implement the functionality that was requested. So, the sender is echoing the message * back. In some cases, the receiver may be able to recover from this by pretending the sender * had taken some appropriate "null" action. * * For example, say `resolve` is received by a level 0 implementation (because a previous call * or return happened to contain a promise). The level 0 implementation will echo it back as * `unimplemented`. The original sender can then simply release the cap to which the promise * had resolved, thus avoiding a leak. * * For any message type that introduces a question, if the message comes back unimplemented, * the original sender may simply treat it as if the question failed with an exception. * * In cases where there is no sensible way to react to an `unimplemented` message (without * resource leaks or other serious problems), the connection may need to be aborted. This is * a gray area; different implementations may take different approaches. * */ get unimplemented(): Message$1; _hasUnimplemented(): boolean; _initUnimplemented(): Message$1; get _isUnimplemented(): boolean; set unimplemented(value: Message$1); _adoptAbort(value: Orphan): void; _disownAbort(): Orphan; /** * Sent when a connection is being aborted due to an unrecoverable error. This could be e.g. * because the sender received an invalid or nonsensical message or because the sender had an * internal error. The sender will shut down the outgoing half of the connection after `abort` * and will completely close the connection shortly thereafter (it's up to the sender how much * of a time buffer they want to offer for the client to receive the `abort` before the * connection is reset). * */ get abort(): Exception; _hasAbort(): boolean; _initAbort(): Exception; get _isAbort(): boolean; set abort(value: Exception); _adoptBootstrap(value: Orphan): void; _disownBootstrap(): Orphan; /** * Request the peer's bootstrap interface. * */ get bootstrap(): Bootstrap; _hasBootstrap(): boolean; _initBootstrap(): Bootstrap; get _isBootstrap(): boolean; set bootstrap(value: Bootstrap); _adoptCall(value: Orphan): void; _disownCall(): Orphan; /** * Begin a method call. * */ get call(): Call$1; _hasCall(): boolean; _initCall(): Call$1; get _isCall(): boolean; set call(value: Call$1); _adoptReturn(value: Orphan): void; _disownReturn(): Orphan; /** * Complete a method call. * */ get return(): Return; _hasReturn(): boolean; _initReturn(): Return; get _isReturn(): boolean; set return(value: Return); _adoptFinish(value: Orphan): void; _disownFinish(): Orphan; /** * Release a returned answer / cancel a call. * */ get finish(): Finish; _hasFinish(): boolean; _initFinish(): Finish; get _isFinish(): boolean; set finish(value: Finish); _adoptResolve(value: Orphan): void; _disownResolve(): Orphan; /** * Resolve a previously-sent promise. * */ get resolve(): Resolve; _hasResolve(): boolean; _initResolve(): Resolve; get _isResolve(): boolean; set resolve(value: Resolve); _adoptRelease(value: Orphan): void; _disownRelease(): Orphan; /** * Release a capability so that the remote object can be deallocated. * */ get release(): Release; _hasRelease(): boolean; _initRelease(): Release; get _isRelease(): boolean; set release(value: Release); _adoptDisembargo(value: Orphan): void; _disownDisembargo(): Orphan; /** * Lift an embargo used to enforce E-order over promise resolution. * */ get disembargo(): Disembargo; _hasDisembargo(): boolean; _initDisembargo(): Disembargo; get _isDisembargo(): boolean; set disembargo(value: Disembargo); _adoptObsoleteSave(value: Orphan): void; _disownObsoleteSave(): Orphan; /** * Obsolete request to save a capability, resulting in a SturdyRef. This has been replaced * by the `Persistent` interface defined in `persistent.capnp`. This operation was never * implemented. * */ get obsoleteSave(): Pointer; _hasObsoleteSave(): boolean; get _isObsoleteSave(): boolean; set obsoleteSave(value: Pointer); _adoptObsoleteDelete(value: Orphan): void; _disownObsoleteDelete(): Orphan; /** * Obsolete way to delete a SturdyRef. This operation was never implemented. * */ get obsoleteDelete(): Pointer; _hasObsoleteDelete(): boolean; get _isObsoleteDelete(): boolean; set obsoleteDelete(value: Pointer); _adoptProvide(value: Orphan): void; _disownProvide(): Orphan; /** * Provide a capability to a third party. * */ get provide(): Provide; _hasProvide(): boolean; _initProvide(): Provide; get _isProvide(): boolean; set provide(value: Provide); _adoptAccept(value: Orphan): void; _disownAccept(): Orphan; /** * Accept a capability provided by a third party. * */ get accept(): Accept; _hasAccept(): boolean; _initAccept(): Accept; get _isAccept(): boolean; set accept(value: Accept); _adoptJoin(value: Orphan): void; _disownJoin(): Orphan; /** * Directly connect to the common root of two or more proxied caps. * */ get join(): Join; _hasJoin(): boolean; _initJoin(): Join; get _isJoin(): boolean; set join(value: Join); toString(): string; which(): Message_Which; } declare class Bootstrap extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * A new question ID identifying this request, which will eventually receive a Return message * containing the restored capability. * */ get questionId(): number; set questionId(value: number); _adoptDeprecatedObjectId(value: Orphan): void; _disownDeprecatedObjectId(): Orphan; /** * ** DEPRECATED ** * * A Vat may export multiple bootstrap interfaces. In this case, `deprecatedObjectId` specifies * which one to return. If this pointer is null, then the default bootstrap interface is returned. * * As of version 0.5, use of this field is deprecated. If a service wants to export multiple * bootstrap interfaces, it should instead define a single bootstrap interface that has methods * that return each of the other interfaces. * * **History** * * In the first version of Cap'n Proto RPC (0.4.x) the `Bootstrap` message was called `Restore`. * At the time, it was thought that this would eventually serve as the way to restore SturdyRefs * (level 2). Meanwhile, an application could offer its "main" interface on a well-known * (non-secret) SturdyRef. * * Since level 2 RPC was not implemented at the time, the `Restore` message was in practice only * used to obtain the main interface. Since most applications had only one main interface that * they wanted to restore, they tended to designate this with a null `objectId`. * * Unfortunately, the earliest version of the EZ RPC interfaces set a precedent of exporting * multiple main interfaces by allowing them to be exported under string names. In this case, * `objectId` was a Text value specifying the name. * * All of this proved problematic for several reasons: * * - The arrangement assumed that a client wishing to restore a SturdyRef would know exactly what * machine to connect to and would be able to immediately restore a SturdyRef on connection. * However, in practice, the ability to restore SturdyRefs is itself a capability that may * require going through an authentication process to obtain. Thus, it makes more sense to * define a "restorer service" as a full Cap'n Proto interface. If this restorer interface is * offered as the vat's bootstrap interface, then this is equivalent to the old arrangement. * * - Overloading "Restore" for the purpose of obtaining well-known capabilities encouraged the * practice of exporting singleton services with string names. If singleton services are desired, * it is better to have one main interface that has methods that can be used to obtain each * service, in order to get all the usual benefits of schemas and type checking. * * - Overloading "Restore" also had a security problem: Often, "main" or "well-known" * capabilities exported by a vat are in fact not public: they are intended to be accessed only * by clients who are capable of forming a connection to the vat. This can lead to trouble if * the client itself has other clients and wishes to forward some `Restore` requests from those * external clients -- it has to be very careful not to allow through `Restore` requests * addressing the default capability. * * For example, consider the case of a sandboxed Sandstorm application and its supervisor. The * application exports a default capability to its supervisor that provides access to * functionality that only the supervisor is supposed to access. Meanwhile, though, applications * may publish other capabilities that may be persistent, in which case the application needs * to field `Restore` requests that could come from anywhere. These requests of course have to * pass through the supervisor, as all communications with the outside world must. But, the * supervisor has to be careful not to honor an external request addressing the application's * default capability, since this capability is privileged. Unfortunately, the default * capability cannot be given an unguessable name, because then the supervisor itself would not * be able to address it! * * As of Cap'n Proto 0.5, `Restore` has been renamed to `Bootstrap` and is no longer planned for * use in restoring SturdyRefs. * * Note that 0.4 also defined a message type called `Delete` that, like `Restore`, addressed a * SturdyRef, but indicated that the client would not restore the ref again in the future. This * operation was never implemented, so it was removed entirely. If a "delete" operation is desired, * it should exist as a method on the same interface that handles restoring SturdyRefs. However, * the utility of such an operation is questionable. You wouldn't be able to rely on it for * garbage collection since a client could always disappear permanently without remembering to * delete all its SturdyRefs, thus leaving them dangling forever. Therefore, it is advisable to * design systems such that SturdyRefs never represent "owned" pointers. * * For example, say a SturdyRef points to an image file hosted on some server. That image file * should also live inside a collection (a gallery, perhaps) hosted on the same server, owned by * a user who can delete the image at any time. If the user deletes the image, the SturdyRef * stops working. On the other hand, if the SturdyRef is discarded, this has no effect on the * existence of the image in its collection. * */ get deprecatedObjectId(): Pointer; _hasDeprecatedObjectId(): boolean; set deprecatedObjectId(value: Pointer); toString(): string; } declare const Call_SendResultsTo_Which: { /** * Send the return message back to the caller (the usual). * */ readonly CALLER: 0; /** * **(level 1)** * * Don't actually return the results to the sender. Instead, hold on to them and await * instructions from the sender regarding what to do with them. In particular, the sender * may subsequently send a `Return` for some other call (which the receiver had previously made * to the sender) with `takeFromOtherQuestion` set. The results from this call are then used * as the results of the other call. * * When `yourself` is used, the receiver must still send a `Return` for the call, but sets the * field `resultsSentElsewhere` in that `Return` rather than including the results. * * This feature can be used to implement tail calls in which a call from Vat A to Vat B ends up * returning the result of a call from Vat B back to Vat A. * * In particular, the most common use case for this feature is when Vat A makes a call to a * promise in Vat B, and then that promise ends up resolving to a capability back in Vat A. * Vat B must forward all the queued calls on that promise back to Vat A, but can set `yourself` * in the calls so that the results need not pass back through Vat B. * * For example: * - Alice, in Vat A, calls foo() on Bob in Vat B. * - Alice makes a pipelined call bar() on the promise returned by foo(). * - Later on, Bob resolves the promise from foo() to point at Carol, who lives in Vat A (next * to Alice). * - Vat B dutifully forwards the bar() call to Carol. Let us call this forwarded call bar'(). * Notice that bar() and bar'() are travelling in opposite directions on the same network * link. * - The `Call` for bar'() has `sendResultsTo` set to `yourself`. * - Vat B sends a `Return` for bar() with `takeFromOtherQuestion` set in place of the results, * with the value set to the question ID of bar'(). Vat B does not wait for bar'() to return, * as doing so would introduce unnecessary round trip latency. * - Vat A receives bar'() and delivers it to Carol. * - When bar'() returns, Vat A sends a `Return` for bar'() to Vat B, with `resultsSentElsewhere` * set in place of results. * - Vat A sends a `Finish` for the bar() call to Vat B. * - Vat B receives the `Finish` for bar() and sends a `Finish` for bar'(). * */ readonly YOURSELF: 1; /** * **(level 3)** * * The call's result should be returned to a different vat. The receiver (the callee) expects * to receive an `Accept` message from the indicated vat, and should return the call's result * to it, rather than to the sender of the `Call`. * * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call` * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C * also sends a `Return` to Vat B with `resultsSentElsewhere`. * */ readonly THIRD_PARTY: 2; }; export type Call_SendResultsTo_Which = (typeof Call_SendResultsTo_Which)[keyof typeof Call_SendResultsTo_Which]; declare class Call_SendResultsTo extends Struct { static readonly CALLER: 0; static readonly YOURSELF: 1; static readonly THIRD_PARTY: 2; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isCaller(): boolean; set caller(_: true); get _isYourself(): boolean; set yourself(_: true); _adoptThirdParty(value: Orphan): void; _disownThirdParty(): Orphan; /** * **(level 3)** * * The call's result should be returned to a different vat. The receiver (the callee) expects * to receive an `Accept` message from the indicated vat, and should return the call's result * to it, rather than to the sender of the `Call`. * * This operates much like `yourself`, above, except that Carol is in a separate Vat C. `Call` * messages are sent from Vat A -> Vat B and Vat B -> Vat C. A `Return` message is sent from * Vat B -> Vat A that contains `acceptFromThirdParty` in place of results. When Vat A sends * an `Accept` to Vat C, it receives back a `Return` containing the call's actual result. Vat C * also sends a `Return` to Vat B with `resultsSentElsewhere`. * */ get thirdParty(): Pointer; _hasThirdParty(): boolean; get _isThirdParty(): boolean; set thirdParty(value: Pointer); toString(): string; which(): Call_SendResultsTo_Which; } declare class Call$1 extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; defaultAllowThirdPartyTailCall: DataView; defaultNoPromisePipelining: DataView; defaultOnlyPromisePipeline: DataView; }; /** * A number, chosen by the caller, that identifies this call in future messages. This number * must be different from all other calls originating from the same end of the connection (but * may overlap with question IDs originating from the opposite end). A fine strategy is to use * sequential question IDs, but the recipient should not assume this. * * A question ID can be reused once both: * - A matching Return has been received from the callee. * - A matching Finish has been sent from the caller. * */ get questionId(): number; set questionId(value: number); _adoptTarget(value: Orphan): void; _disownTarget(): Orphan; /** * The object that should receive this call. * */ get target(): MessageTarget; _hasTarget(): boolean; _initTarget(): MessageTarget; set target(value: MessageTarget); /** * The type ID of the interface being called. Each capability may implement multiple interfaces. * */ get interfaceId(): bigint; set interfaceId(value: bigint); /** * The ordinal number of the method to call within the requested interface. * */ get methodId(): number; set methodId(value: number); /** * Indicates whether or not the receiver is allowed to send a `Return` containing * `acceptFromThirdParty`. Level 3 implementations should set this true. Otherwise, the callee * will have to proxy the return in the case of a tail call to a third-party vat. * */ get allowThirdPartyTailCall(): boolean; set allowThirdPartyTailCall(value: boolean); /** * If true, the sender promises that it won't make any promise-pipelined calls on the results of * this call. If it breaks this promise, the receiver may throw an arbitrary error from such * calls. * * The receiver may use this as an optimization, by skipping the bookkeeping needed for pipelining * when no pipelined calls are expected. The sender typically sets this to false when the method's * schema does not specify any return capabilities. * */ get noPromisePipelining(): boolean; set noPromisePipelining(value: boolean); /** * If true, the sender only plans to use this call to make pipelined calls. The receiver need not * send a `Return` message (but is still allowed to do so). * * Since the sender does not know whether a `Return` will be sent, it must release all state * related to the call when it sends `Finish`. However, in the case that the callee does not * recognize this hint and chooses to send a `Return`, then technically the caller is not allowed * to reuse the question ID until it receives said `Return`. This creates a conundrum: How does * the caller decide when it's OK to reuse the ID? To sidestep the problem, the C++ implementation * uses high-numbered IDs (with the high-order bit set) for such calls, and cycles through the * IDs in order. If all 2^31 IDs in this space are used without ever seeing a `Return`, then the * implementation assumes that the other end is in fact honoring the hint, and the ID counter is * allowed to loop around. If a `Return` is ever seen when `onlyPromisePipeline` was set, then * the implementation stops using this hint. * */ get onlyPromisePipeline(): boolean; set onlyPromisePipeline(value: boolean); _adoptParams(value: Orphan): void; _disownParams(): Orphan; /** * The call parameters. `params.content` is a struct whose fields correspond to the parameters of * the method. * */ get params(): Payload; _hasParams(): boolean; _initParams(): Payload; set params(value: Payload); /** * Where should the return message be sent? * */ get sendResultsTo(): Call_SendResultsTo; _initSendResultsTo(): Call_SendResultsTo; toString(): string; } declare const Return_Which: { /** * Equal to the QuestionId of the corresponding `Call` message. * */ readonly RESULTS: 0; /** * If true, all capabilities that were in the params should be considered released. The sender * must not send separate `Release` messages for them. Level 0 implementations in particular * should always set this true. This defaults true because if level 0 implementations forget to * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget * to set it to false they'll quickly get errors. * * The receiver should act as if the sender had sent a release message with count=1 for each * CapDescriptor in the original Call message. * */ readonly EXCEPTION: 1; /** * The result. * * For regular method calls, `results.content` points to the result struct. * * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single * capability (rather than a struct), and `results.content` is just a capability pointer with * index 0. A `Finish` is still required in this case. * */ readonly CANCELED: 2; /** * Indicates that the call failed and explains why. * */ readonly RESULTS_SENT_ELSEWHERE: 3; /** * Indicates that the call was canceled due to the caller sending a Finish message * before the call had completed. * */ readonly TAKE_FROM_OTHER_QUESTION: 4; /** * This is set when returning from a `Call` that had `sendResultsTo` set to something other * than `caller`. * * It doesn't matter too much when this is sent, as the receiver doesn't need to do anything * with it, but the C++ implementation appears to wait for the call to finish before sending * this. * */ readonly ACCEPT_FROM_THIRD_PARTY: 5; }; export type Return_Which = (typeof Return_Which)[keyof typeof Return_Which]; declare class Return extends Struct { static readonly RESULTS: 0; static readonly EXCEPTION: 1; static readonly CANCELED: 2; static readonly RESULTS_SENT_ELSEWHERE: 3; static readonly TAKE_FROM_OTHER_QUESTION: 4; static readonly ACCEPT_FROM_THIRD_PARTY: 5; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; defaultReleaseParamCaps: DataView; defaultNoFinishNeeded: DataView; }; /** * Equal to the QuestionId of the corresponding `Call` message. * */ get answerId(): number; set answerId(value: number); /** * If true, all capabilities that were in the params should be considered released. The sender * must not send separate `Release` messages for them. Level 0 implementations in particular * should always set this true. This defaults true because if level 0 implementations forget to * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget * to set it to false they'll quickly get errors. * * The receiver should act as if the sender had sent a release message with count=1 for each * CapDescriptor in the original Call message. * */ get releaseParamCaps(): boolean; set releaseParamCaps(value: boolean); /** * If true, the sender does not need the receiver to send a `Finish` message; its answer table * entry has already been cleaned up. This implies that the results do not contain any * capabilities, since the `Finish` message would normally release those capabilities from * promise pipelining responsibility. The caller may still send a `Finish` message if it wants, * which will be silently ignored by the callee. * */ get noFinishNeeded(): boolean; set noFinishNeeded(value: boolean); _adoptResults(value: Orphan): void; _disownResults(): Orphan; /** * The result. * * For regular method calls, `results.content` points to the result struct. * * For a `Return` in response to an `Accept` or `Bootstrap`, `results` contains a single * capability (rather than a struct), and `results.content` is just a capability pointer with * index 0. A `Finish` is still required in this case. * */ get results(): Payload; _hasResults(): boolean; _initResults(): Payload; get _isResults(): boolean; set results(value: Payload); _adoptException(value: Orphan): void; _disownException(): Orphan; /** * Indicates that the call failed and explains why. * */ get exception(): Exception; _hasException(): boolean; _initException(): Exception; get _isException(): boolean; set exception(value: Exception); get _isCanceled(): boolean; set canceled(_: true); get _isResultsSentElsewhere(): boolean; set resultsSentElsewhere(_: true); /** * The sender has also sent (before this message) a `Call` with the given question ID and with * `sendResultsTo.yourself` set, and the results of that other call should be used as the * results here. `takeFromOtherQuestion` can only used once per question. * */ get takeFromOtherQuestion(): number; get _isTakeFromOtherQuestion(): boolean; set takeFromOtherQuestion(value: number); _adoptAcceptFromThirdParty(value: Orphan): void; _disownAcceptFromThirdParty(): Orphan; /** * **(level 3)** * * The caller should contact a third-party vat to pick up the results. An `Accept` message * sent to the vat will return the result. This pairs with `Call.sendResultsTo.thirdParty`. * It should only be used if the corresponding `Call` had `allowThirdPartyTailCall` set. * */ get acceptFromThirdParty(): Pointer; _hasAcceptFromThirdParty(): boolean; get _isAcceptFromThirdParty(): boolean; set acceptFromThirdParty(value: Pointer); toString(): string; which(): Return_Which; } declare class Finish extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; defaultReleaseResultCaps: DataView; defaultRequireEarlyCancellationWorkaround: DataView; }; /** * ID of the call whose result is to be released. * */ get questionId(): number; set questionId(value: number); /** * If true, all capabilities that were in the results should be considered released. The sender * must not send separate `Release` messages for them. Level 0 implementations in particular * should always set this true. This defaults true because if level 0 implementations forget to * set it they'll never notice (just silently leak caps), but if level >=1 implementations forget * set it false they'll quickly get errors. * */ get releaseResultCaps(): boolean; set releaseResultCaps(value: boolean); /** * If true, if the RPC system receives this Finish message before the original call has even been * delivered, it should defer cancellation util after delivery. In particular, this gives the * destination object a chance to opt out of cancellation, e.g. as controlled by the * `allowCancellation` annotation defined in `c++.capnp`. * * This is a work-around. Versions 1.0 and up of Cap'n Proto always set this to false. However, * older versions of Cap'n Proto unintentionally exhibited this errant behavior by default, and * as a result programs built with older versions could be inadvertently relying on their peers * to implement the behavior. The purpose of this flag is to let newer versions know when the * peer is an older version, so that it can attempt to work around the issue. * * See also comments in handleFinish() in rpc.c++ for more details. * */ get requireEarlyCancellationWorkaround(): boolean; set requireEarlyCancellationWorkaround(value: boolean); toString(): string; } declare const Resolve_Which: { /** * The ID of the promise to be resolved. * * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver * will release the export soon after receiving `Resolve`, and the sender will not send this * `ExportId` again until it has been released and recycled. * * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise, * this indicates that the sender will follow up at some point with a `Resolve` message. If the * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the * same ID is sent again later _after_ a `Resolve`, it can only be because the export's * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore * this later promise does _not_ correspond to the earlier `Resolve`. * * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve` * message may or may not still be sent (the `Resolve` may have already been in-flight when * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which * the receiver has no knowledge, because it already released it earlier. In this case, the * receiver should simply release the capability to which the promise resolved. * */ readonly CAP: 0; /** * The object to which the promise resolved. * * The sender promises that from this point forth, until `promiseId` is released, it shall * simply forward all messages to the capability designated by `cap`. This is true even if * `cap` itself happens to designate another promise, and that other promise later resolves -- * messages sent to `promiseId` shall still go to that other promise, not to its resolution. * This is important in the case that the receiver of the `Resolve` ends up sending a * `Disembargo` message towards `promiseId` in order to control message ordering -- that * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even * if that object is itself a promise. * */ readonly EXCEPTION: 1; }; export type Resolve_Which = (typeof Resolve_Which)[keyof typeof Resolve_Which]; declare class Resolve extends Struct { static readonly CAP: 0; static readonly EXCEPTION: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * The ID of the promise to be resolved. * * Unlike all other instances of `ExportId` sent from the exporter, the `Resolve` message does * _not_ increase the reference count of `promiseId`. In fact, it is expected that the receiver * will release the export soon after receiving `Resolve`, and the sender will not send this * `ExportId` again until it has been released and recycled. * * When an export ID sent over the wire (e.g. in a `CapDescriptor`) is indicated to be a promise, * this indicates that the sender will follow up at some point with a `Resolve` message. If the * same `promiseId` is sent again before `Resolve`, still only one `Resolve` is sent. If the * same ID is sent again later _after_ a `Resolve`, it can only be because the export's * reference count hit zero in the meantime and the ID was re-assigned to a new export, therefore * this later promise does _not_ correspond to the earlier `Resolve`. * * If a promise ID's reference count reaches zero before a `Resolve` is sent, the `Resolve` * message may or may not still be sent (the `Resolve` may have already been in-flight when * `Release` was sent, but if the `Release` is received before `Resolve` then there is no longer * any reason to send a `Resolve`). Thus a `Resolve` may be received for a promise of which * the receiver has no knowledge, because it already released it earlier. In this case, the * receiver should simply release the capability to which the promise resolved. * */ get promiseId(): number; set promiseId(value: number); _adoptCap(value: Orphan): void; _disownCap(): Orphan; /** * The object to which the promise resolved. * * The sender promises that from this point forth, until `promiseId` is released, it shall * simply forward all messages to the capability designated by `cap`. This is true even if * `cap` itself happens to designate another promise, and that other promise later resolves -- * messages sent to `promiseId` shall still go to that other promise, not to its resolution. * This is important in the case that the receiver of the `Resolve` ends up sending a * `Disembargo` message towards `promiseId` in order to control message ordering -- that * `Disembargo` really needs to reflect back to exactly the object designated by `cap` even * if that object is itself a promise. * */ get cap(): CapDescriptor; _hasCap(): boolean; _initCap(): CapDescriptor; get _isCap(): boolean; set cap(value: CapDescriptor); _adoptException(value: Orphan): void; _disownException(): Orphan; /** * Indicates that the promise was broken. * */ get exception(): Exception; _hasException(): boolean; _initException(): Exception; get _isException(): boolean; set exception(value: Exception); toString(): string; which(): Resolve_Which; } declare class Release extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * What to release. * */ get id(): number; set id(value: number); /** * The amount by which to decrement the reference count. The export is only actually released * when the reference count reaches zero. * */ get referenceCount(): number; set referenceCount(value: number); toString(): string; } declare const Disembargo_Context_Which: { /** * The sender is requesting a disembargo on a promise that is known to resolve back to a * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback` * set to the same value as `senderLoopback`. This value is chosen by the sender, and since * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure * the value is unambiguous. * * The receiver must verify that the target capability actually resolves back to the sender's * vat. Otherwise, the sender has committed a protocol error and should be disconnected. * */ readonly SENDER_LOOPBACK: 0; /** * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to * this capability, and that Disembargo is now being echoed back. * */ readonly RECEIVER_LOOPBACK: 1; /** * **(level 3)** * * The sender is requesting a disembargo on a promise that is known to resolve to a third-party * capability that the sender is currently in the process of accepting (using `Accept`). * The receiver of this `Disembargo` has an outstanding `Provide` on said capability. The * receiver should now send a `Disembargo` with `provide` set to the question ID of that * `Provide` message. * * See `Accept.embargo` for an example. * */ readonly ACCEPT: 2; /** * **(level 3)** * * The sender is requesting a disembargo on a capability currently being provided to a third * party. The question ID identifies the `Provide` message previously sent by the sender to * this capability. On receipt, the receiver (the capability host) shall release the embargo * on the `Accept` message that it has received from the third party. See `Accept.embargo` for * an example. * */ readonly PROVIDE: 3; }; export type Disembargo_Context_Which = (typeof Disembargo_Context_Which)[keyof typeof Disembargo_Context_Which]; declare class Disembargo_Context extends Struct { static readonly SENDER_LOOPBACK: 0; static readonly RECEIVER_LOOPBACK: 1; static readonly ACCEPT: 2; static readonly PROVIDE: 3; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * The sender is requesting a disembargo on a promise that is known to resolve back to a * capability hosted by the sender. As soon as the receiver has echoed back all pipelined calls * on this promise, it will deliver the Disembargo back to the sender with `receiverLoopback` * set to the same value as `senderLoopback`. This value is chosen by the sender, and since * it is also consumed be the sender, the sender can use whatever strategy it wants to make sure * the value is unambiguous. * * The receiver must verify that the target capability actually resolves back to the sender's * vat. Otherwise, the sender has committed a protocol error and should be disconnected. * */ get senderLoopback(): number; get _isSenderLoopback(): boolean; set senderLoopback(value: number); /** * The receiver previously sent a `senderLoopback` Disembargo towards a promise resolving to * this capability, and that Disembargo is now being echoed back. * */ get receiverLoopback(): number; get _isReceiverLoopback(): boolean; set receiverLoopback(value: number); get _isAccept(): boolean; set accept(_: true); /** * **(level 3)** * * The sender is requesting a disembargo on a capability currently being provided to a third * party. The question ID identifies the `Provide` message previously sent by the sender to * this capability. On receipt, the receiver (the capability host) shall release the embargo * on the `Accept` message that it has received from the third party. See `Accept.embargo` for * an example. * */ get provide(): number; get _isProvide(): boolean; set provide(value: number); toString(): string; which(): Disembargo_Context_Which; } declare class Disembargo extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptTarget(value: Orphan): void; _disownTarget(): Orphan; /** * What is to be disembargoed. * */ get target(): MessageTarget; _hasTarget(): boolean; _initTarget(): MessageTarget; set target(value: MessageTarget); get context(): Disembargo_Context; _initContext(): Disembargo_Context; toString(): string; } declare class Provide extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Question ID to be held open until the recipient has received the capability. A result will be * returned once the third party has successfully received the capability. The sender must at some * point send a `Finish` message as with any other call, and that message can be used to cancel the * whole operation. * */ get questionId(): number; set questionId(value: number); _adoptTarget(value: Orphan): void; _disownTarget(): Orphan; /** * What is to be provided to the third party. * */ get target(): MessageTarget; _hasTarget(): boolean; _initTarget(): MessageTarget; set target(value: MessageTarget); _adoptRecipient(value: Orphan): void; _disownRecipient(): Orphan; /** * Identity of the third party that is expected to pick up the capability. * */ get recipient(): Pointer; _hasRecipient(): boolean; set recipient(value: Pointer); toString(): string; } declare class Accept extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * A new question ID identifying this accept message, which will eventually receive a Return * message containing the provided capability (or the call result in the case of a redirected * return). * */ get questionId(): number; set questionId(value: number); _adoptProvision(value: Orphan): void; _disownProvision(): Orphan; /** * Identifies the provided object to be picked up. * */ get provision(): Pointer; _hasProvision(): boolean; set provision(value: Pointer); /** * If true, this accept shall be temporarily embargoed. The resulting `Return` will not be sent, * and any pipelined calls will not be delivered, until the embargo is released. The receiver * (the capability host) will expect the provider (the vat that sent the `Provide` message) to * eventually send a `Disembargo` message with the field `context.provide` set to the question ID * of the original `Provide` message. At that point, the embargo is released and the queued * messages are delivered. * * For example: * - Alice, in Vat A, holds a promise P, which currently points toward Vat B. * - Alice calls foo() on P. The `Call` message is sent to Vat B. * - The promise P in Vat B ends up resolving to Carol, in Vat C. * - Vat B sends a `Provide` message to Vat C, identifying Vat A as the recipient. * - Vat B sends a `Resolve` message to Vat A, indicating that the promise has resolved to a * `ThirdPartyCapId` identifying Carol in Vat C. * - Vat A sends an `Accept` message to Vat C to pick up the capability. Since Vat A knows that * it has an outstanding call to the promise, it sets `embargo` to `true` in the `Accept` * message. * - Vat A sends a `Disembargo` message to Vat B on promise P, with `context.accept` set. * - Alice makes a call bar() to promise P, which is now pointing towards Vat C. Alice doesn't * know anything about the mechanics of promise resolution happening under the hood, but she * expects that bar() will be delivered after foo() because that is the order in which she * initiated the calls. * - Vat A sends the bar() call to Vat C, as a pipelined call on the result of the `Accept` (which * hasn't returned yet, due to the embargo). Since calls to the newly-accepted capability * are embargoed, Vat C does not deliver the call yet. * - At some point, Vat B forwards the foo() call from the beginning of this example on to Vat C. * - Vat B forwards the `Disembargo` from Vat A on to vat C. It sets `context.provide` to the * question ID of the `Provide` message it had sent previously. * - Vat C receives foo() before `Disembargo`, thus allowing it to correctly deliver foo() * before delivering bar(). * - Vat C receives `Disembargo` from Vat B. It can now send a `Return` for the `Accept` from * Vat A, as well as deliver bar(). * */ get embargo(): boolean; set embargo(value: boolean); toString(): string; } declare class Join extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Question ID used to respond to this Join. (Note that this ID only identifies one part of the * request for one hop; each part has a different ID and relayed copies of the request have * (probably) different IDs still.) * * The receiver will reply with a `Return` whose `results` is a JoinResult. This `JoinResult` * is relayed from the joined object's host, possibly with transformation applied as needed * by the network. * * Like any return, the result must be released using a `Finish`. However, this release * should not occur until the joiner has either successfully connected to the joined object. * Vats relaying a `Join` message similarly must not release the result they receive until the * return they relayed back towards the joiner has itself been released. This allows the * joined object's host to detect when the Join operation is canceled before completing -- if * it receives a `Finish` for one of the join results before the joiner successfully * connects. It can then free any resources it had allocated as part of the join. * */ get questionId(): number; set questionId(value: number); _adoptTarget(value: Orphan): void; _disownTarget(): Orphan; /** * The capability to join. * */ get target(): MessageTarget; _hasTarget(): boolean; _initTarget(): MessageTarget; set target(value: MessageTarget); _adoptKeyPart(value: Orphan): void; _disownKeyPart(): Orphan; /** * A part of the join key. These combine to form the complete join key, which is used to establish * a direct connection. * */ get keyPart(): Pointer; _hasKeyPart(): boolean; set keyPart(value: Pointer); toString(): string; } declare const MessageTarget_Which: { /** * This message is to a capability or promise previously imported by the caller (exported by * the receiver). * */ readonly IMPORTED_CAP: 0; /** * This message is to a capability that is expected to be returned by another call that has not * yet been completed. * * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so * that initial startup doesn't require a round trip. * */ readonly PROMISED_ANSWER: 1; }; export type MessageTarget_Which = (typeof MessageTarget_Which)[keyof typeof MessageTarget_Which]; declare class MessageTarget extends Struct { static readonly IMPORTED_CAP: 0; static readonly PROMISED_ANSWER: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * This message is to a capability or promise previously imported by the caller (exported by * the receiver). * */ get importedCap(): number; get _isImportedCap(): boolean; set importedCap(value: number); _adoptPromisedAnswer(value: Orphan): void; _disownPromisedAnswer(): Orphan; /** * This message is to a capability that is expected to be returned by another call that has not * yet been completed. * * At level 0, this is supported only for addressing the result of a previous `Bootstrap`, so * that initial startup doesn't require a round trip. * */ get promisedAnswer(): PromisedAnswer; _hasPromisedAnswer(): boolean; _initPromisedAnswer(): PromisedAnswer; get _isPromisedAnswer(): boolean; set promisedAnswer(value: PromisedAnswer); toString(): string; which(): MessageTarget_Which; } declare class Payload extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _CapTable: ListCtor; _adoptContent(value: Orphan): void; _disownContent(): Orphan; /** * Some Cap'n Proto data structure. Capability pointers embedded in this structure index into * `capTable`. * */ get content(): Pointer; _hasContent(): boolean; set content(value: Pointer); _adoptCapTable(value: Orphan>): void; _disownCapTable(): Orphan>; /** * Descriptors corresponding to the cap pointers in `content`. * */ get capTable(): List; _hasCapTable(): boolean; _initCapTable(length: number): List; set capTable(value: List); toString(): string; } declare const CapDescriptor_Which: { /** * There is no capability here. This `CapDescriptor` should not appear in the payload content. * A `none` CapDescriptor can be generated when an application inserts a capability into a * message and then later changes its mind and removes it -- rewriting all of the other * capability pointers may be hard, so instead a tombstone is left, similar to the way a removed * struct or list instance is zeroed out of the message but the space is not reclaimed. * Hopefully this is unusual. * */ readonly NONE: 0; /** * The ID of a capability in the sender's export table (receiver's import table). It may be a * newly allocated table entry, or an existing entry (increments the reference count). * */ readonly SENDER_HOSTED: 1; /** * A promise that the sender will resolve later. The sender will send exactly one Resolve * message at a future point in time to replace this promise. Note that even if the same * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this * `CapDescriptor`) may choose not to send the `Resolve` at all. * */ readonly SENDER_PROMISE: 2; /** * A capability (or promise) previously exported by the receiver (imported by the sender). * */ readonly RECEIVER_HOSTED: 3; /** * A capability expected to be returned in the results of a currently-outstanding call posed * by the sender. * */ readonly RECEIVER_ANSWER: 4; /** * **(level 3)** * * A capability that lives in neither the sender's nor the receiver's vat. The sender needs * to form a direct connection to a third party to pick up the capability. * * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its * `vine` instead. * */ readonly THIRD_PARTY_HOSTED: 5; }; export type CapDescriptor_Which = (typeof CapDescriptor_Which)[keyof typeof CapDescriptor_Which]; declare class CapDescriptor extends Struct { static readonly NONE: 0; static readonly SENDER_HOSTED: 1; static readonly SENDER_PROMISE: 2; static readonly RECEIVER_HOSTED: 3; static readonly RECEIVER_ANSWER: 4; static readonly THIRD_PARTY_HOSTED: 5; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; defaultAttachedFd: DataView; }; get _isNone(): boolean; set none(_: true); /** * The ID of a capability in the sender's export table (receiver's import table). It may be a * newly allocated table entry, or an existing entry (increments the reference count). * */ get senderHosted(): number; get _isSenderHosted(): boolean; set senderHosted(value: number); /** * A promise that the sender will resolve later. The sender will send exactly one Resolve * message at a future point in time to replace this promise. Note that even if the same * `senderPromise` is received multiple times, only one `Resolve` is sent to cover all of * them. If `senderPromise` is released before the `Resolve` is sent, the sender (of this * `CapDescriptor`) may choose not to send the `Resolve` at all. * */ get senderPromise(): number; get _isSenderPromise(): boolean; set senderPromise(value: number); /** * A capability (or promise) previously exported by the receiver (imported by the sender). * */ get receiverHosted(): number; get _isReceiverHosted(): boolean; set receiverHosted(value: number); _adoptReceiverAnswer(value: Orphan): void; _disownReceiverAnswer(): Orphan; /** * A capability expected to be returned in the results of a currently-outstanding call posed * by the sender. * */ get receiverAnswer(): PromisedAnswer; _hasReceiverAnswer(): boolean; _initReceiverAnswer(): PromisedAnswer; get _isReceiverAnswer(): boolean; set receiverAnswer(value: PromisedAnswer); _adoptThirdPartyHosted(value: Orphan): void; _disownThirdPartyHosted(): Orphan; /** * **(level 3)** * * A capability that lives in neither the sender's nor the receiver's vat. The sender needs * to form a direct connection to a third party to pick up the capability. * * Level 1 and 2 implementations that receive a `thirdPartyHosted` may simply send calls to its * `vine` instead. * */ get thirdPartyHosted(): ThirdPartyCapDescriptor; _hasThirdPartyHosted(): boolean; _initThirdPartyHosted(): ThirdPartyCapDescriptor; get _isThirdPartyHosted(): boolean; set thirdPartyHosted(value: ThirdPartyCapDescriptor); /** * If the RPC message in which this CapDescriptor was delivered also had file descriptors * attached, and `fd` is a valid index into the list of attached file descriptors, then * that file descriptor should be attached to this capability. If `attachedFd` is out-of-bounds * for said list, then no FD is attached. * * For example, if the RPC message arrived over a Unix socket, then file descriptors may be * attached by sending an SCM_RIGHTS ancillary message attached to the data bytes making up the * raw message. Receivers who wish to opt into FD passing should arrange to receive SCM_RIGHTS * whenever receiving an RPC message. Senders who wish to send FDs need not verify whether the * receiver knows how to receive them, because the operating system will automatically discard * ancillary messages like SCM_RIGHTS if the receiver doesn't ask to receive them, including * automatically closing any FDs. * * It is up to the application protocol to define what capabilities are expected to have file * descriptors attached, and what those FDs mean. But, for example, an application could use this * to open a file on disk and then transmit the open file descriptor to a sandboxed process that * does not otherwise have permission to access the filesystem directly. This is usually an * optimization: the sending process could instead provide an RPC interface supporting all the * operations needed (such as reading and writing a file), but by passing the file descriptor * directly, the recipient can often perform operations much more efficiently. Application * designers are encouraged to provide such RPC interfaces and automatically fall back to them * when FD passing is not available, so that the application can still work when the parties are * remote over a network. * * An attached FD is most often associated with a `senderHosted` descriptor. It could also make * sense in the case of `thirdPartyHosted`: in this case, the sender is forwarding the FD that * they received from the third party, so that the receiver can start using it without first * interacting with the third party. This is an optional optimization -- the middleman may choose * not to forward capabilities, in which case the receiver will need to complete the handshake * with the third party directly before receiving the FD. If an implementation receives a second * attached FD after having already received one previously (e.g. both in a `thirdPartyHosted` * CapDescriptor and then later again when receiving the final capability directly from the * third party), the implementation should discard the later FD and stick with the original. At * present, there is no known reason why other capability types (e.g. `receiverHosted`) would want * to carry an attached FD, but we reserve the right to define a meaning for this in the future. * * Each file descriptor attached to the message must be used in no more than one CapDescriptor, * so that the receiver does not need to use dup() or refcounting to handle the possibility of * multiple capabilities using the same descriptor. If multiple CapDescriptors do point to the * same FD index, then the receiver can arbitrarily choose which capability ends up having the * FD attached. * * To mitigate DoS attacks, RPC implementations should limit the number of FDs they are willing to * receive in a single message to a small value. If a message happens to contain more than that, * the list is truncated. Moreover, in some cases, FD passing needs to be blocked entirely for * security or implementation reasons, in which case the list may be truncated to zero. Hence, * `attachedFd` might point past the end of the list, which the implementation should treat as if * no FD was attached at all. * * The type of this field was chosen to be UInt8 because Linux supports sending only a maximum * of 253 file descriptors in an SCM_RIGHTS message anyway, and CapDescriptor had two bytes of * padding left -- so after adding this, there is still one byte for a future feature. * Conveniently, this also means we're able to use 0xff as the default value, which will always * be out-of-range (of course, the implementation should explicitly enforce that 255 descriptors * cannot be sent at once, rather than relying on Linux to do so). * */ get attachedFd(): number; set attachedFd(value: number); toString(): string; which(): CapDescriptor_Which; } declare const PromisedAnswer_Op_Which: { /** * Does nothing. This member is mostly defined so that we can make `Op` a union even * though (as of this writing) only one real operation is defined. * */ readonly NOOP: 0; /** * Get a pointer field within a struct. The number is an index into the pointer section, NOT * a field ordinal, so that the receiver does not need to understand the schema. * */ readonly GET_POINTER_FIELD: 1; }; export type PromisedAnswer_Op_Which = (typeof PromisedAnswer_Op_Which)[keyof typeof PromisedAnswer_Op_Which]; declare class PromisedAnswer_Op extends Struct { static readonly NOOP: 0; static readonly GET_POINTER_FIELD: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isNoop(): boolean; set noop(_: true); /** * Get a pointer field within a struct. The number is an index into the pointer section, NOT * a field ordinal, so that the receiver does not need to understand the schema. * */ get getPointerField(): number; get _isGetPointerField(): boolean; set getPointerField(value: number); toString(): string; which(): PromisedAnswer_Op_Which; } declare class PromisedAnswer extends Struct { static readonly Op: typeof PromisedAnswer_Op; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Transform: ListCtor; /** * ID of the question (in the sender's question table / receiver's answer table) whose answer is * expected to contain the capability. * */ get questionId(): number; set questionId(value: number); _adoptTransform(value: Orphan>): void; _disownTransform(): Orphan>; /** * Operations / transformations to apply to the result in order to get the capability actually * being addressed. E.g. if the result is a struct and you want to call a method on a capability * pointed to by a field of the struct, you need a `getPointerField` op. * */ get transform(): List; _hasTransform(): boolean; _initTransform(length: number): List; set transform(value: List); toString(): string; } declare class ThirdPartyCapDescriptor extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptId(value: Orphan): void; _disownId(): Orphan; /** * Identifies the third-party host and the specific capability to accept from it. * */ get id(): Pointer; _hasId(): boolean; set id(value: Pointer); /** * A proxy for the third-party object exported by the sender. In CapTP terminology this is called * a "vine", because it is an indirect reference to the third-party object that snakes through the * sender vat. This serves two purposes: * * * Level 1 and 2 implementations that don't understand how to connect to a third party may * simply send calls to the vine. Such calls will be forwarded to the third-party by the * sender. * * * Level 3 implementations must release the vine only once they have successfully picked up the * object from the third party. This ensures that the capability is not released by the sender * prematurely. * * The sender will close the `Provide` request that it has sent to the third party as soon as * it receives either a `Call` or a `Release` message directed at the vine. * */ get vineId(): number; set vineId(value: number); toString(): string; } declare const Exception_Type: { /** * A generic problem occurred, and it is believed that if the operation were repeated without * any change in the state of the world, the problem would occur again. * * A client might respond to this error by logging it for investigation by the developer and/or * displaying it to the user. * */ readonly FAILED: 0; /** * The request was rejected due to a temporary lack of resources. * * Examples include: * - There's not enough CPU time to keep up with incoming requests, so some are rejected. * - The server ran out of RAM or disk space during the request. * - The operation timed out (took significantly longer than it should have). * * A client might respond to this error by scheduling to retry the operation much later. The * client should NOT retry again immediately since this would likely exacerbate the problem. * */ readonly OVERLOADED: 1; /** * The method failed because a connection to some necessary capability was lost. * * Examples include: * - The client introduced the server to a third-party capability, the connection to that third * party was subsequently lost, and then the client requested that the server use the dead * capability for something. * - The client previously requested that the server obtain a capability from some third party. * The server returned a capability to an object wrapping the third-party capability. Later, * the server's connection to the third party was lost. * - The capability has been revoked. Revocation does not necessarily mean that the client is * no longer authorized to use the capability; it is often used simply as a way to force the * client to repeat the setup process, perhaps to efficiently move them to a new back-end or * get them to recognize some other change that has occurred. * * A client should normally respond to this error by releasing all capabilities it is currently * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or * repeating the method calls used to create them originally. In other words, disconnect and * start over. This should in turn cause the server to obtain a new copy of the capability that * it lost, thus making everything work. * * If the client receives another `disconnected` error in the process of rebuilding the * capability and retrying the call, it should treat this as an `overloaded` error: the network * is currently unreliable, possibly due to load or other temporary issues. * */ readonly DISCONNECTED: 2; /** * The server doesn't implement the requested method. If there is some other method that the * client could call (perhaps an older and/or slower interface), it should try that instead. * Otherwise, this should be treated like `failed`. * */ readonly UNIMPLEMENTED: 3; }; export type Exception_Type = (typeof Exception_Type)[keyof typeof Exception_Type]; declare class Exception extends Struct { static readonly Type: { /** * A generic problem occurred, and it is believed that if the operation were repeated without * any change in the state of the world, the problem would occur again. * * A client might respond to this error by logging it for investigation by the developer and/or * displaying it to the user. * */ readonly FAILED: 0; /** * The request was rejected due to a temporary lack of resources. * * Examples include: * - There's not enough CPU time to keep up with incoming requests, so some are rejected. * - The server ran out of RAM or disk space during the request. * - The operation timed out (took significantly longer than it should have). * * A client might respond to this error by scheduling to retry the operation much later. The * client should NOT retry again immediately since this would likely exacerbate the problem. * */ readonly OVERLOADED: 1; /** * The method failed because a connection to some necessary capability was lost. * * Examples include: * - The client introduced the server to a third-party capability, the connection to that third * party was subsequently lost, and then the client requested that the server use the dead * capability for something. * - The client previously requested that the server obtain a capability from some third party. * The server returned a capability to an object wrapping the third-party capability. Later, * the server's connection to the third party was lost. * - The capability has been revoked. Revocation does not necessarily mean that the client is * no longer authorized to use the capability; it is often used simply as a way to force the * client to repeat the setup process, perhaps to efficiently move them to a new back-end or * get them to recognize some other change that has occurred. * * A client should normally respond to this error by releasing all capabilities it is currently * holding related to the one it called and then re-creating them by restoring SturdyRefs and/or * repeating the method calls used to create them originally. In other words, disconnect and * start over. This should in turn cause the server to obtain a new copy of the capability that * it lost, thus making everything work. * * If the client receives another `disconnected` error in the process of rebuilding the * capability and retrying the call, it should treat this as an `overloaded` error: the network * is currently unreliable, possibly due to load or other temporary issues. * */ readonly DISCONNECTED: 2; /** * The server doesn't implement the requested method. If there is some other method that the * client could call (perhaps an older and/or slower interface), it should try that instead. * Otherwise, this should be treated like `failed`. * */ readonly UNIMPLEMENTED: 3; }; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Human-readable failure description. * */ get reason(): string; set reason(value: string); /** * The type of the error. The purpose of this enum is not to describe the error itself, but * rather to describe how the client might want to respond to the error. * */ get type(): Exception_Type; set type(value: Exception_Type); /** * OBSOLETE. Ignore. * */ get obsoleteIsCallersFault(): boolean; set obsoleteIsCallersFault(value: boolean); /** * OBSOLETE. See `type` instead. * */ get obsoleteDurability(): number; set obsoleteDurability(value: number); /** * Stack trace text from the remote server. The format is not specified. By default, * implementations do not provide stack traces; the application must explicitly enable them * when desired. * */ get trace(): string; set trace(value: string); toString(): string; } export type CapabilityID = number; export interface Method

{ interfaceId: bigint; methodId: number; interfaceName?: string; methodName?: string; ParamsClass: StructCtor

; ResultsClass: StructCtor; } export type Call

= FuncCall | DataCall; export interface BaseCall

{ method: Method; } export type FuncCall

= BaseCall & { paramsFunc?(params: P): void; }; export type DataCall

= BaseCall & { params: P; }; export declare function isFuncCall

(call: Call): call is FuncCall; export declare function isDataCall

(call: Call): call is DataCall; export declare function copyCall

(call: Call): DataCall; export declare function placeParams

(call: Call, contentPtr: Pointer | undefined): P; declare class IDGen { i: number; free: number[]; next(): number; remove(i: number): void; } export interface PipelineOp { field: number; defaultValue?: Pointer; } export declare class Deferred { static fromPromise(p: Promise): Deferred; promise: Promise; reject: (reason?: unknown) => void; resolve: (value: T | PromiseLike) => void; constructor(); } export interface ecall { call: Call; f: Fulfiller; } export interface pcall extends ecall { transform: PipelineOp[]; } export type ecallSlot = ecall | null; declare class Ecalls { data: ecallSlot[]; constructor(data: ecallSlot[]); static copyOf(data: ecallSlot[]): Ecalls; len(): number; clear(i: number): void; copy(): Ecalls; } declare class Fulfiller implements Answer { resolved: boolean; answer?: Answer; queue: pcall[]; queueCap: number; deferred: Deferred; fulfill(s: R): void; reject(err: Error): void; peek(): Answer | undefined; struct(): Promise; pipelineCall(transform: PipelineOp[], call: Call): Answer; pipelineClose(transform: PipelineOp[]): void; emptyQueue(s: Struct): Record; } export interface Answer { struct(): Promise; pipelineCall(transform: PipelineOp[], call: Call): Answer; pipelineClose(transform: PipelineOp[]): void; } declare class AnswerEntry { id: number; conn: Conn; resultCaps: number[]; done: boolean; obj?: R; err?: Error; deferred: Deferred; queue: AnswerPCall[]; constructor(conn: Conn, id: number); fulfill(obj: R): void; reject(err: Error): void; emptyQueue(obj: R): [ { [key: number]: AnswerQCall[]; }, Error | undefined ]; queueCall

(call: Call, transform: PipelineOp[], a: AnswerEntry): void; } export type AnswerQCall = QCallRemoteCall | QCallLocalCall | QCallDisembargo; export interface QCallRemoteCall { call: Call; a: AnswerEntry; } export interface QCallLocalCall { call: Call; f: Fulfiller; } export interface QCallDisembargo { embargoID: number; embargoTarget: MessageTarget; } export interface AnswerPCall { qcall: AnswerQCall; transform: PipelineOp[]; } export type Finalize = (obj: unknown, finalizer: Finalizer) => void; export type Finalizer = () => void; declare class Ref implements Client { rc: RefCount; closeState: { closed: boolean; }; constructor(rc: RefCount, finalize: Finalize); call

(cl: Call): Answer; client(): Client; close(): void; } declare class RefCount implements Client { refs: number; finalize: Finalize; _client: Client; private constructor(); static new(c: Client, finalize: Finalize): [ RefCount, Ref ]; call

(cl: Call): Answer; client(): Client; close(): void; ref(): Client; newRef(): Ref; decref(): void; } export interface Transport { sendMessage(msg: Message$1): void; recvMessage(): Promise; close(): void; } declare enum QuestionState { IN_PROGRESS = 0, RESOLVED = 1, CANCELED = 2 } declare class Question

implements Answer { conn: Conn; id: number; method?: Method | undefined; paramCaps: number[]; state: QuestionState; obj?: R; err?: Error; derived: PipelineOp[][]; deferred: Deferred; constructor(conn: Conn, id: number, method?: Method | undefined); struct(): Promise; start(): void; fulfill(obj: Pointer): void; reject(err: Error): void; cancel(err: Error): boolean; pipelineCall(transform: PipelineOp[], call: Call): Answer; addPromise(transform: PipelineOp[]): void; pipelineClose(): void; } export interface ServerMethod

extends Method { impl(params: P, results: R): Promise; } export interface ServerCall

extends DataCall { serverMethod: ServerMethod; answer: Fulfiller; } export declare class Server implements Client { target: any; methods: Array>; constructor(target: any, methods: Array>); startCall

(call: ServerCall): void; call

(call: Call): Answer; close(): void; } export type QuestionSlot = Question | null; export declare class Conn { transport: Transport; finalize: Finalize; questionID: IDGen; questions: QuestionSlot[]; answers: { [key: number]: AnswerEntry; }; exportID: IDGen; exports: Array; imports: { [key: number]: ImportEntry; }; onError?: (err?: Error) => void; main?: Client; working: boolean; /** * Create a new connection * @param transport The transport used to receive/send messages. * @param finalize Weak reference implementation. Compatible with * the 'weak' module on node.js (just add weak as a dependency and pass * require("weak")), but alternative implementations can be provided for * other platforms like Electron. Defaults to using FinalizationRegistry if * available. * @returns A new connection. */ constructor(transport: Transport, finalize?: Finalize); bootstrap(InterfaceClass: InterfaceCtor): C; initMain>(InterfaceClass: S, target: ServerTarget): void; startWork(): void; sendReturnException(id: number, err: Error): void; handleBootstrapMessage(m: Message$1): void; handleFinishMessage(m: Message$1): void; handleMessage(m: Message$1): void; handleReturnMessage(m: Message$1): void; handleCallMessage(m: Message$1): void; routeCallMessage

(result: AnswerEntry, mt: MessageTarget, cl: Call): void; populateMessageCapTable(payload: Payload): void; addImport(id: number): Client; findExport(id: number): Export | null; addExport(client: Client): number; releaseExport(id: number, refs: number): void; error(s: string): void; newQuestion(method?: Method): Question; findQuestion

(id: number): Question | null; popQuestion

(id: number): Question | null; insertAnswer(id: number): AnswerEntry | null; popAnswer(id: number): AnswerEntry | null; shutdown(_err?: Error): void; call

(client: Client, call: Call): Answer; fillParams

(payload: Payload, cl: Call): void; makeCapTable(s: Segment, init: (length: number) => List): void; descriptorForClient(desc: CapDescriptor, _client: Client): void; sendMessage(msg: Message$1): void; private work; } export interface Export { id: number; rc: RefCount; client: Client; wireRefs: number; } export interface ImportEntry { rc: RefCount; refs: number; } export declare function answerPipelineClient(a: AnswerEntry, transform: PipelineOp[]): Client; export type ServerTarget> = ConstructorParameters[0]; export interface InterfaceCtor { readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; readonly Client: { new (client: Client): C; }; readonly Server: { new (target: any): S; }; new (segment: Segment, byteOffset: number, depthLimit?: number): Interface; } export declare class Interface extends Pointer { static readonly _capnp: { displayName: string; }; static readonly getCapID: typeof getCapID; static readonly getAsInterface: typeof getAsInterface; static readonly isInterface: typeof isInterface; static readonly getClient: typeof getClient; constructor(segment: Segment, byteOffset: number, depthLimit?: number); static fromPointer(p: Pointer): Interface | null; getCapId(): CapabilityID; getClient(): Client | null; } declare function getAsInterface(p: Pointer): Interface | null; declare function isInterface(p: Pointer): boolean; declare function getCapID(i: Interface): CapabilityID; declare function getClient(i: Interface): Client | null; export interface _Orphan { capId: number; elementSize: ListElementSize; length: number; size: ObjectSize; type: PointerType; } /** * An orphaned pointer. This object itself is technically a pointer to the original pointer's content, which was left * untouched in its original message. The original pointer data is encoded as attributes on the Orphan object, ready to * be reconstructed once another pointer is ready to adopt it. */ export declare class Orphan { /** If this member is not present then the orphan has already been adopted, or something went very wrong. */ _capnp?: _Orphan; byteOffset: number; segment: Segment; constructor(src: T); /** * Adopt (move) this orphan into the target pointer location. This will allocate far pointers in `dst` as needed. * * @param dst The destination pointer. */ _moveTo(dst: T): void; dispose(): void; } declare class Segment implements DataView { readonly id: number; readonly message: Message; buffer: ArrayBuffer; /** The number of bytes currently allocated in the segment. */ byteLength: number; /** * This value should always be zero. It's only here to satisfy the DataView interface. * * In the future the Segment implementation (or a child class) may allow accessing the buffer from a nonzero offset, * but that adds a lot of extra arithmetic. */ byteOffset: number; readonly [Symbol.toStringTag]: "DataView"; private _dv; constructor(id: number, message: Message, buffer: ArrayBuffer, byteLength?: number); /** * Attempt to allocate the requested number of bytes in this segment. If this segment is full this method will return * a pointer to freshly allocated space in another segment from the same message. * * @param byteLength The number of bytes to allocate, will be rounded up to the nearest word. * @returns A pointer to the newly allocated space. */ allocate(byteLength: number): Pointer; /** * Quickly copy a word (8 bytes) from `srcSegment` into this one at the given offset. * * @param byteOffset The offset to write the word to. * @param srcSegment The segment to copy the word from. * @param srcByteOffset The offset from the start of `srcSegment` to copy from. */ copyWord(byteOffset: number, srcSegment: Segment, srcByteOffset: number): void; /** * Quickly copy words from `srcSegment` into this one. * * @param byteOffset The offset to start copying into. * @param srcSegment The segment to copy from. * @param srcByteOffset The start offset to copy from. * @param wordLength The number of words to copy. */ copyWords(byteOffset: number, srcSegment: Segment, srcByteOffset: number, wordLength: number): void; /** * Quickly fill a number of words in the buffer with zeroes. * * @param byteOffset The first byte to set to zero. * @param wordLength The number of words (not bytes!) to zero out. */ fillZeroWords(byteOffset: number, wordLength: number): void; getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; /** * Get the total number of bytes available in this segment (the size of its underlying buffer). * * @returns The total number of bytes this segment can hold. */ getCapacity(): number; /** * Read a float32 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getFloat32(byteOffset: number): number; /** * Read a float64 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getFloat64(byteOffset: number): number; /** * Read an int16 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getInt16(byteOffset: number): number; /** * Read an int32 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getInt32(byteOffset: number): number; /** * Read an int64 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getInt64(byteOffset: number): bigint; /** * Read an int8 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getInt8(byteOffset: number): number; /** * Read a uint16 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getUint16(byteOffset: number): number; /** * Read a uint32 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getUint32(byteOffset: number): number; /** * Read a uint64 value (as a bigint) out of this segment. * NOTE: this does not copy the memory region, so updates to the underlying buffer will affect the returned value! * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getUint64(byteOffset: number): bigint; /** * Read a uint8 value out of this segment. * * @param byteOffset The offset in bytes to the value. * @returns The value. */ getUint8(byteOffset: number): number; hasCapacity(byteLength: number): boolean; /** * Quickly check the word at the given offset to see if it is equal to zero. * * PERF_V8: Fastest way to do this is by reading the whole word as a `number` (float64) in the _native_ endian format * and see if it's zero. * * Benchmark: http://jsben.ch/#/Pjooc * * @param byteOffset The offset to the word. * @returns `true` if the word is zero. */ isWordZero(byteOffset: number): boolean; /** * Swap out this segment's underlying buffer with a new one. It's assumed that the new buffer has the same content but * more free space, otherwise all existing pointers to this segment will be hilariously broken. * * @param buffer The new buffer to use. */ replaceBuffer(buffer: ArrayBuffer): void; /** * Read a float16 value from the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param littleEndian If true, read the value as little-endian, otherwise read it as big-endian. * @returns The value read from the buffer. */ getFloat16(byteOffset: number, littleEndian?: boolean | undefined): number; /** * Write an float16 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setFloat16(byteOffset: number, val: number): void; setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; /** WARNING: This function is not yet implemented. */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; /** * Write a float32 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setFloat32(byteOffset: number, val: number): void; /** * Write an float64 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setFloat64(byteOffset: number, val: number): void; /** * Write an int16 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setInt16(byteOffset: number, val: number): void; /** * Write an int32 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setInt32(byteOffset: number, val: number): void; /** * Write an int8 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setInt8(byteOffset: number, val: number): void; /** * Write an int64 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setInt64(byteOffset: number, val: bigint): void; /** * Write a uint16 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setUint16(byteOffset: number, val: number): void; /** * Write a uint32 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setUint32(byteOffset: number, val: number): void; /** * Write a uint64 value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setUint64(byteOffset: number, val: bigint): void; /** * Write a uint8 (byte) value to the specified offset. * * @param byteOffset The offset from the beginning of the buffer. * @param val The value to store. */ setUint8(byteOffset: number, val: number): void; /** * Write a zero word (8 bytes) to the specified offset. This is slightly faster than calling `setUint64` or * `setFloat64` with a zero value. * * Benchmark: http://jsben.ch/#/dUdPI * * @param byteOffset The offset of the word to set to zero. */ setWordZero(byteOffset: number): void; toString(): string; } export interface _StructCtor extends _PointerCtor { readonly id: string; readonly size: ObjectSize; } export interface StructCtor { readonly _capnp: _StructCtor; new (segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number): T; } export interface _Struct extends _Pointer { compositeIndex?: number; } export declare class Struct extends Pointer<_Struct> { static readonly _capnp: { displayName: string; }; /** * Create a new pointer to a struct. * * @param segment The segment the pointer resides in. * @param byteOffset The offset from the beginning of the segment to the beginning of the pointer data. * @param depthLimit The nesting depth limit for this object. * @param compositeIndex If set, then this pointer is actually a reference to a composite list * (`this._getPointerTargetType() === PointerType.LIST`), and this number is used as the index of the struct within * the list. It is not valid to call `initStruct()` on a composite struct – the struct contents are initialized when * the list pointer is initialized. */ constructor(segment: Segment, byteOffset: number, depthLimit?: number, compositeIndex?: number); static [Symbol.toStringTag](): string; [Symbol.toStringTag](): string; } export interface Client { call

(call: Call): Answer; close(): void; } export declare function isSameClient(c: Client, d: Client): boolean; export declare function clientFromResolution(transform: PipelineOp[], obj?: Struct, err?: Error): Client; declare class ArenaAllocationResult { /** * The newly allocated buffer. This buffer might be a copy of an existing segment's buffer with free space appended. */ readonly buffer: ArrayBuffer; /** * The id of the newly-allocated segment. */ readonly id: number; constructor(id: number, buffer: ArrayBuffer); } declare enum ArenaKind { SINGLE_SEGMENT = 0, MULTI_SEGMENT = 1 } declare class MultiSegmentArena { readonly buffers: ArrayBuffer[]; static readonly allocate: typeof allocate$1; static readonly getBuffer: typeof getBuffer$1; static readonly getNumSegments: typeof getNumSegments$1; readonly kind = ArenaKind.MULTI_SEGMENT; constructor(buffers?: ArrayBuffer[]); toString(): string; } declare function allocate$1(minSize: number, m: MultiSegmentArena): ArenaAllocationResult; declare function getBuffer$1(id: number, m: MultiSegmentArena): ArrayBuffer; declare function getNumSegments$1(m: MultiSegmentArena): number; declare class SingleSegmentArena { static readonly allocate: typeof allocate; static readonly getBuffer: typeof getBuffer; static readonly getNumSegments: typeof getNumSegments; buffer: ArrayBuffer; readonly kind = ArenaKind.SINGLE_SEGMENT; constructor(buffer?: ArrayBuffer); toString(): string; } declare function allocate(minSize: number, segments: Segment[], s: SingleSegmentArena): ArenaAllocationResult; declare function getBuffer(id: number, s: SingleSegmentArena): ArrayBuffer; declare function getNumSegments(): number; export type AnyArena = MultiSegmentArena | SingleSegmentArena; export interface _Message { readonly arena: AnyArena; segments: Segment[]; traversalLimit: number; capTable?: Array; } export declare class Message { static readonly allocateSegment: typeof allocateSegment; static readonly dump: typeof dump; static readonly getRoot: typeof getRoot; static readonly getSegment: typeof getSegment; static readonly initRoot: typeof initRoot; static readonly readRawPointer: typeof readRawPointer; static readonly toArrayBuffer: typeof toArrayBuffer; static readonly toPackedArrayBuffer: typeof toPackedArrayBuffer; readonly _capnp: _Message; /** * A Cap'n Proto message. * * SECURITY WARNING: In Node.js do not pass a Buffer's internal array buffer into this constructor. Pass the buffer * directly and everything will be fine. If not, your message will potentially be initialized with random memory * contents! * * The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer * to read from. * * @param src The source for the message. * A value of `undefined` will cause the message to initialize with a single segment arena only big enough for the * root pointer; it will expand as you go. This is a reasonable choice for most messages. * * Passing an arena will cause the message to use that arena for its segment allocation. Contents will be accepted * as-is. * * Passing an array buffer view (like `DataView`, `Uint8Array` or `Buffer`) will create a **copy** of the source * buffer; beware of the potential performance cost! * * @param packed Whether or not the message is packed. If `true` (the default), the message will be * unpacked. * * @param singleSegment If true, `src` will be treated as a message consisting of a single segment without * a framing header. * */ constructor(src?: AnyArena | ArrayBufferView | ArrayBuffer, packed?: boolean, singleSegment?: boolean); allocateSegment(byteLength: number): Segment; /** * Copies the contents of this message into an identical message with its own ArrayBuffers. * * @returns A copy of this message. */ copy(): Message; /** * Create a pretty-printed string dump of this message; incredibly useful for debugging. * * WARNING: Do not call this method on large messages! * * @returns A big steaming pile of pretty hex digits. */ dump(): string; /** * Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not * overwrite existing data. * * @param RootStruct The struct type to use as the root. * @returns A struct representing the root of the message. */ getRoot(RootStruct: StructCtor): T; /** * Get a segment by its id. * * This will lazily allocate the first segment if it doesn't already exist. * * @param id The segment id. * @returns The requested segment. */ getSegment(id: number): Segment; /** * Initialize a new message using the provided struct type as the root. * * @param RootStruct The struct type to use as the root. * @returns An initialized struct pointing to the root of the message. */ initRoot(RootStruct: StructCtor): T; /** * Set the root of the message to a copy of the given pointer. Used internally * to make copies of pointers for default values. * * @param src The source pointer to copy. */ setRoot(src: Pointer): void; /** * Combine the contents of this message's segments into a single array buffer and prepend a stream framing header * containing information about the following segment data. * * @returns An ArrayBuffer with the contents of this message. */ toArrayBuffer(): ArrayBuffer; /** * Like `toArrayBuffer()`, but also applies the packing algorithm to the output. This is typically what you want to * use if you're sending the message over a network link or other slow I/O interface where size matters. * * @returns A packed message. */ toPackedArrayBuffer(): ArrayBuffer; addCap(client: Client | null): number; toString(): string; } declare function allocateSegment(byteLength: number, m: Message): Segment; declare function dump(m: Message): string; declare function getRoot(RootStruct: StructCtor, m: Message): T; declare function getSegment(id: number, m: Message): Segment; declare function initRoot(RootStruct: StructCtor, m: Message): T; /** * Read a pointer in raw form (a packed message with framing headers). Does not * care or attempt to validate the input beyond parsing the message * segments. * * This is typically used by the compiler to load default values, but can be * useful to work with messages with an unknown schema. * * @param data The raw data to read. * @returns A root pointer. */ export declare function readRawPointer(data: ArrayBuffer): Pointer; declare function toArrayBuffer(m: Message): ArrayBuffer; declare function toPackedArrayBuffer(m: Message): ArrayBuffer; /** * A generic blob of bytes. Can be converted to a DataView or Uint8Array to access its contents using `toDataView()` and * `toUint8Array()`. Use `copyBuffer()` to copy an entire buffer at once. */ export declare class Data extends List { static fromPointer(pointer: Pointer): Data; protected static _fromPointerUnchecked(pointer: Pointer): Data; /** * Copy the contents of `src` into this Data pointer. If `src` is smaller than the length of this pointer then the * remaining bytes will be zeroed out. Extra bytes in `src` are ignored. * * @param src The source buffer. */ copyBuffer(src: ArrayBuffer | ArrayBufferView): void; /** * Read a byte from the specified offset. * * @param byteOffset The byte offset to read. * @returns The byte value. */ get(byteOffset: number): number; /** * Write a byte at the specified offset. * * @param byteOffset The byte offset to set. * @param value The byte value to set. */ set(byteOffset: number, value: number): void; /** * Creates a **copy** of the underlying buffer data and returns it as an ArrayBuffer. * * To obtain a reference to the underlying buffer instead, use `toUint8Array()` or `toDataView()`. * * @returns A copy of this data buffer. */ toArrayBuffer(): ArrayBuffer; /** * Convert this Data pointer to a DataView representing the pointer's contents. * * WARNING: The DataView references memory from a message segment, so do not venture outside the bounds of the * DataView or else BAD THINGS. * * @returns A live reference to the underlying buffer. */ toDataView(): DataView; [Symbol.toStringTag](): string; /** * Convert this Data pointer to a Uint8Array representing the pointer's contents. * * WARNING: The Uint8Array references memory from a message segment, so do not venture outside the bounds of the * Uint8Array or else BAD THINGS. * * @returns A live reference to the underlying buffer. */ toUint8Array(): Uint8Array; } declare class Node_Parameter extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get name(): string; set name(value: string); toString(): string; } declare class Node_NestedNode extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically. * * (On Zooko's triangle, this is the node's petname according to its parent scope.) * */ get name(): string; set name(value: string); /** * ID of the nested node. Typically, the target node's scopeId points back to this node, but * robust code should avoid relying on this. * */ get id(): bigint; set id(value: bigint); toString(): string; } declare class Node_SourceInfo_Member extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Doc comment on the member. * */ get docComment(): string; set docComment(value: string); toString(): string; } declare class Node_SourceInfo extends Struct { static readonly Member: typeof Node_SourceInfo_Member; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Members: ListCtor; /** * ID of the Node which this info describes. * */ get id(): bigint; set id(value: bigint); /** * The top-level doc comment for the Node. * */ get docComment(): string; set docComment(value: string); _adoptMembers(value: Orphan>): void; _disownMembers(): Orphan>; /** * Information about each member -- i.e. fields (for structs), enumerants (for enums), or * methods (for interfaces). * * This list is the same length and order as the corresponding list in the Node, i.e. * Node.struct.fields, Node.enum.enumerants, or Node.interface.methods. * */ get members(): List; _hasMembers(): boolean; _initMembers(length: number): List; set members(value: List); toString(): string; } declare class Node_Struct extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Fields: ListCtor; /** * Size of the data section, in words. * */ get dataWordCount(): number; set dataWordCount(value: number); /** * Size of the pointer section, in pointers (which are one word each). * */ get pointerCount(): number; set pointerCount(value: number); /** * The preferred element size to use when encoding a list of this struct. If this is anything * other than `inlineComposite` then the struct is one word or less in size and is a candidate * for list packing optimization. * */ get preferredListEncoding(): ElementSize; set preferredListEncoding(value: ElementSize); /** * If true, then this "struct" node is actually not an independent node, but merely represents * some named union or group within a particular parent struct. This node's scopeId refers * to the parent struct, which may itself be a union/group in yet another struct. * * All group nodes share the same dataWordCount and pointerCount as the top-level * struct, and their fields live in the same ordinal and offset spaces as all other fields in * the struct. * * Note that a named union is considered a special kind of group -- in fact, a named union * is exactly equivalent to a group that contains nothing but an unnamed union. * */ get isGroup(): boolean; set isGroup(value: boolean); /** * Number of fields in this struct which are members of an anonymous union, and thus may * overlap. If this is non-zero, then a 16-bit discriminant is present indicating which * of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be * two or more. * * Note that the fields of an unnamed union are considered fields of the scope containing the * union -- an unnamed union is not its own group. So, a top-level struct may contain a * non-zero discriminant count. Named unions, on the other hand, are equivalent to groups * containing unnamed unions. So, a named union has its own independent schema node, with * `isGroup` = true. * */ get discriminantCount(): number; set discriminantCount(value: number); /** * If `discriminantCount` is non-zero, this is the offset of the union discriminant, in * multiples of 16 bits. * */ get discriminantOffset(): number; set discriminantOffset(value: number); _adoptFields(value: Orphan>): void; _disownFields(): Orphan>; /** * Fields defined within this scope (either the struct's top-level fields, or the fields of * a particular group; see `isGroup`). * * The fields are sorted by ordinal number, but note that because groups share the same * ordinal space, the field's index in this list is not necessarily exactly its ordinal. * On the other hand, the field's position in this list does remain the same even as the * protocol evolves, since it is not possible to insert or remove an earlier ordinal. * Therefore, for most use cases, if you want to identify a field by number, it may make the * most sense to use the field's index in this list rather than its ordinal. * */ get fields(): List; _hasFields(): boolean; _initFields(length: number): List; set fields(value: List); toString(): string; } declare class Node_Enum extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Enumerants: ListCtor; _adoptEnumerants(value: Orphan>): void; _disownEnumerants(): Orphan>; /** * Enumerants ordered by numeric value (ordinal). * */ get enumerants(): List; _hasEnumerants(): boolean; _initEnumerants(length: number): List; set enumerants(value: List); toString(): string; } declare class Node_Interface extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Methods: ListCtor; static _Superclasses: ListCtor; _adoptMethods(value: Orphan>): void; _disownMethods(): Orphan>; /** * Methods ordered by ordinal. * */ get methods(): List; _hasMethods(): boolean; _initMethods(length: number): List; set methods(value: List); _adoptSuperclasses(value: Orphan>): void; _disownSuperclasses(): Orphan>; /** * Superclasses of this interface. * */ get superclasses(): List; _hasSuperclasses(): boolean; _initSuperclasses(length: number): List; set superclasses(value: List); toString(): string; } declare class Node_Const extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptType(value: Orphan): void; _disownType(): Orphan; get type(): Type; _hasType(): boolean; _initType(): Type; set type(value: Type); _adoptValue(value: Orphan): void; _disownValue(): Orphan; get value(): Value; _hasValue(): boolean; _initValue(): Value; set value(value: Value); toString(): string; } declare class Node_Annotation extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptType(value: Orphan): void; _disownType(): Orphan; get type(): Type; _hasType(): boolean; _initType(): Type; set type(value: Type); get targetsFile(): boolean; set targetsFile(value: boolean); get targetsConst(): boolean; set targetsConst(value: boolean); get targetsEnum(): boolean; set targetsEnum(value: boolean); get targetsEnumerant(): boolean; set targetsEnumerant(value: boolean); get targetsStruct(): boolean; set targetsStruct(value: boolean); get targetsField(): boolean; set targetsField(value: boolean); get targetsUnion(): boolean; set targetsUnion(value: boolean); get targetsGroup(): boolean; set targetsGroup(value: boolean); get targetsInterface(): boolean; set targetsInterface(value: boolean); get targetsMethod(): boolean; set targetsMethod(value: boolean); get targetsParam(): boolean; set targetsParam(value: boolean); get targetsAnnotation(): boolean; set targetsAnnotation(value: boolean); toString(): string; } declare const Node_Which: { readonly FILE: 0; /** * Name to present to humans to identify this Node. You should not attempt to parse this. Its * format could change. It is not guaranteed to be unique. * * (On Zooko's triangle, this is the node's nickname.) * */ readonly STRUCT: 1; /** * If you want a shorter version of `displayName` (just naming this node, without its surrounding * scope), chop off this many characters from the beginning of `displayName`. * */ readonly ENUM: 2; /** * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is * zero if the node has no parent, which is normally only the case with files, but should be * allowed for any kind of node (in order to make runtime type generation easier). * */ readonly INTERFACE: 3; /** * List of nodes nested within this node, along with the names under which they were declared. * */ readonly CONST: 4; /** * Annotations applied to this node. * */ readonly ANNOTATION: 5; }; export type Node_Which = (typeof Node_Which)[keyof typeof Node_Which]; declare class Node extends Struct { static readonly FILE: 0; static readonly STRUCT: 1; static readonly ENUM: 2; static readonly INTERFACE: 3; static readonly CONST: 4; static readonly ANNOTATION: 5; static readonly Parameter: typeof Node_Parameter; static readonly NestedNode: typeof Node_NestedNode; static readonly SourceInfo: typeof Node_SourceInfo; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Parameters: ListCtor; static _NestedNodes: ListCtor; static _Annotations: ListCtor; get id(): bigint; set id(value: bigint); /** * Name to present to humans to identify this Node. You should not attempt to parse this. Its * format could change. It is not guaranteed to be unique. * * (On Zooko's triangle, this is the node's nickname.) * */ get displayName(): string; set displayName(value: string); /** * If you want a shorter version of `displayName` (just naming this node, without its surrounding * scope), chop off this many characters from the beginning of `displayName`. * */ get displayNamePrefixLength(): number; set displayNamePrefixLength(value: number); /** * ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back * at this node, but robust code should avoid relying on this (and, in fact, group nodes are not * listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is * zero if the node has no parent, which is normally only the case with files, but should be * allowed for any kind of node (in order to make runtime type generation easier). * */ get scopeId(): bigint; set scopeId(value: bigint); _adoptParameters(value: Orphan>): void; _disownParameters(): Orphan>; /** * If this node is parameterized (generic), the list of parameters. Empty for non-generic types. * */ get parameters(): List; _hasParameters(): boolean; _initParameters(length: number): List; set parameters(value: List); /** * True if this node is generic, meaning that it or one of its parent scopes has a non-empty * `parameters`. * */ get isGeneric(): boolean; set isGeneric(value: boolean); _adoptNestedNodes(value: Orphan>): void; _disownNestedNodes(): Orphan>; /** * List of nodes nested within this node, along with the names under which they were declared. * */ get nestedNodes(): List; _hasNestedNodes(): boolean; _initNestedNodes(length: number): List; set nestedNodes(value: List); _adoptAnnotations(value: Orphan>): void; _disownAnnotations(): Orphan>; /** * Annotations applied to this node. * */ get annotations(): List; _hasAnnotations(): boolean; _initAnnotations(length: number): List; set annotations(value: List); get _isFile(): boolean; set file(_: true); get struct(): Node_Struct; _initStruct(): Node_Struct; get _isStruct(): boolean; set struct(_: true); get enum(): Node_Enum; _initEnum(): Node_Enum; get _isEnum(): boolean; set enum(_: true); get interface(): Node_Interface; _initInterface(): Node_Interface; get _isInterface(): boolean; set interface(_: true); get const(): Node_Const; _initConst(): Node_Const; get _isConst(): boolean; set const(_: true); get annotation(): Node_Annotation; _initAnnotation(): Node_Annotation; get _isAnnotation(): boolean; set annotation(_: true); toString(): string; which(): Node_Which; } declare class Field_Slot extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * Offset, in units of the field's size, from the beginning of the section in which the field * resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the * beginning of the data section. * */ get offset(): number; set offset(value: number); _adoptType(value: Orphan): void; _disownType(): Orphan; get type(): Type; _hasType(): boolean; _initType(): Type; set type(value: Type); _adoptDefaultValue(value: Orphan): void; _disownDefaultValue(): Orphan; get defaultValue(): Value; _hasDefaultValue(): boolean; _initDefaultValue(): Value; set defaultValue(value: Value); /** * Whether the default value was specified explicitly. Non-explicit default values are always * zero or empty values. Usually, whether the default value was explicit shouldn't matter. * The main use case for this flag is for structs representing method parameters: * explicitly-defaulted parameters may be allowed to be omitted when calling the method. * */ get hadExplicitDefault(): boolean; set hadExplicitDefault(value: boolean); toString(): string; } declare class Field_Group extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * The ID of the group's node. * */ get typeId(): bigint; set typeId(value: bigint); toString(): string; } declare const Field_Ordinal_Which: { readonly IMPLICIT: 0; /** * The original ordinal number given to the field. You probably should NOT use this; if you need * a numeric identifier for a field, use its position within the field array for its scope. * The ordinal is given here mainly just so that the original schema text can be reproduced given * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job. * */ readonly EXPLICIT: 1; }; export type Field_Ordinal_Which = (typeof Field_Ordinal_Which)[keyof typeof Field_Ordinal_Which]; declare class Field_Ordinal extends Struct { static readonly IMPLICIT: 0; static readonly EXPLICIT: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isImplicit(): boolean; set implicit(_: true); /** * The original ordinal number given to the field. You probably should NOT use this; if you need * a numeric identifier for a field, use its position within the field array for its scope. * The ordinal is given here mainly just so that the original schema text can be reproduced given * the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job. * */ get explicit(): number; get _isExplicit(): boolean; set explicit(value: number); toString(): string; which(): Field_Ordinal_Which; } declare const Field_Which: { readonly SLOT: 0; /** * Indicates where this member appeared in the code, relative to other members. * Code ordering may have semantic relevance -- programmers tend to place related fields * together. So, using code ordering makes sense in human-readable formats where ordering is * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum * value is count(members) - 1. Fields that are members of a union are only ordered relative to * the other members of that union, so the maximum value there is count(union.members). * */ readonly GROUP: 1; }; export type Field_Which = (typeof Field_Which)[keyof typeof Field_Which]; declare class Field extends Struct { static readonly NO_DISCRIMINANT = 65535; static readonly SLOT: 0; static readonly GROUP: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; defaultDiscriminantValue: DataView; }; static _Annotations: ListCtor; get name(): string; set name(value: string); /** * Indicates where this member appeared in the code, relative to other members. * Code ordering may have semantic relevance -- programmers tend to place related fields * together. So, using code ordering makes sense in human-readable formats where ordering is * otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum * value is count(members) - 1. Fields that are members of a union are only ordered relative to * the other members of that union, so the maximum value there is count(union.members). * */ get codeOrder(): number; set codeOrder(value: number); _adoptAnnotations(value: Orphan>): void; _disownAnnotations(): Orphan>; get annotations(): List; _hasAnnotations(): boolean; _initAnnotations(length: number): List; set annotations(value: List); /** * If the field is in a union, this is the value which the union's discriminant should take when * the field is active. If the field is not in a union, this is 0xffff. * */ get discriminantValue(): number; set discriminantValue(value: number); /** * A regular, non-group, non-fixed-list field. * */ get slot(): Field_Slot; _initSlot(): Field_Slot; get _isSlot(): boolean; set slot(_: true); /** * A group. * */ get group(): Field_Group; _initGroup(): Field_Group; get _isGroup(): boolean; set group(_: true); get ordinal(): Field_Ordinal; _initOrdinal(): Field_Ordinal; toString(): string; which(): Field_Which; } declare class Enumerant extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Annotations: ListCtor; get name(): string; set name(value: string); /** * Specifies order in which the enumerants were declared in the code. * Like utils.Field.codeOrder. * */ get codeOrder(): number; set codeOrder(value: number); _adoptAnnotations(value: Orphan>): void; _disownAnnotations(): Orphan>; get annotations(): List; _hasAnnotations(): boolean; _initAnnotations(length: number): List; set annotations(value: List); toString(): string; } declare class Superclass extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get id(): bigint; set id(value: bigint); _adoptBrand(value: Orphan): void; _disownBrand(): Orphan; get brand(): Brand; _hasBrand(): boolean; _initBrand(): Brand; set brand(value: Brand); toString(): string; } declare class Method$1 extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _ImplicitParameters: ListCtor; static _Annotations: ListCtor; get name(): string; set name(value: string); /** * Specifies order in which the methods were declared in the code. * Like utils.Field.codeOrder. * */ get codeOrder(): number; set codeOrder(value: number); _adoptImplicitParameters(value: Orphan>): void; _disownImplicitParameters(): Orphan>; /** * The parameters listed in [] (typically, type / generic parameters), whose bindings are intended * to be inferred rather than specified explicitly, although not all languages support this. * */ get implicitParameters(): List; _hasImplicitParameters(): boolean; _initImplicitParameters(length: number): List; set implicitParameters(value: List); /** * ID of the parameter struct type. If a named parameter list was specified in the method * declaration (rather than a single struct parameter type) then a corresponding struct type is * auto-generated. Such an auto-generated type will not be listed in the interface's * `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace. * (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes * this a situation where you can't just climb the scope chain to find where a particular * generic parameter was introduced. Making the `scopeId` zero was a mistake.) * */ get paramStructType(): bigint; set paramStructType(value: bigint); _adoptParamBrand(value: Orphan): void; _disownParamBrand(): Orphan; /** * Brand of param struct type. * */ get paramBrand(): Brand; _hasParamBrand(): boolean; _initParamBrand(): Brand; set paramBrand(value: Brand); /** * ID of the return struct type; similar to `paramStructType`. * */ get resultStructType(): bigint; set resultStructType(value: bigint); _adoptResultBrand(value: Orphan): void; _disownResultBrand(): Orphan; /** * Brand of result struct type. * */ get resultBrand(): Brand; _hasResultBrand(): boolean; _initResultBrand(): Brand; set resultBrand(value: Brand); _adoptAnnotations(value: Orphan>): void; _disownAnnotations(): Orphan>; get annotations(): List; _hasAnnotations(): boolean; _initAnnotations(length: number): List; set annotations(value: List); toString(): string; } declare class Type_List extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; _adoptElementType(value: Orphan): void; _disownElementType(): Orphan; get elementType(): Type; _hasElementType(): boolean; _initElementType(): Type; set elementType(value: Type); toString(): string; } declare class Type_Enum extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get typeId(): bigint; set typeId(value: bigint); _adoptBrand(value: Orphan): void; _disownBrand(): Orphan; get brand(): Brand; _hasBrand(): boolean; _initBrand(): Brand; set brand(value: Brand); toString(): string; } declare class Type_Struct extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get typeId(): bigint; set typeId(value: bigint); _adoptBrand(value: Orphan): void; _disownBrand(): Orphan; get brand(): Brand; _hasBrand(): boolean; _initBrand(): Brand; set brand(value: Brand); toString(): string; } declare class Type_Interface extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get typeId(): bigint; set typeId(value: bigint); _adoptBrand(value: Orphan): void; _disownBrand(): Orphan; get brand(): Brand; _hasBrand(): boolean; _initBrand(): Brand; set brand(value: Brand); toString(): string; } declare const Type_AnyPointer_Unconstrained_Which: { /** * truly AnyPointer * */ readonly ANY_KIND: 0; /** * AnyStruct * */ readonly STRUCT: 1; /** * AnyList * */ readonly LIST: 2; /** * Capability * */ readonly CAPABILITY: 3; }; export type Type_AnyPointer_Unconstrained_Which = (typeof Type_AnyPointer_Unconstrained_Which)[keyof typeof Type_AnyPointer_Unconstrained_Which]; declare class Type_AnyPointer_Unconstrained extends Struct { static readonly ANY_KIND: 0; static readonly STRUCT: 1; static readonly LIST: 2; static readonly CAPABILITY: 3; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isAnyKind(): boolean; set anyKind(_: true); get _isStruct(): boolean; set struct(_: true); get _isList(): boolean; set list(_: true); get _isCapability(): boolean; set capability(_: true); toString(): string; which(): Type_AnyPointer_Unconstrained_Which; } declare class Type_AnyPointer_Parameter extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * ID of the generic type whose parameter we're referencing. This should be a parent of the * current scope. * */ get scopeId(): bigint; set scopeId(value: bigint); /** * Index of the parameter within the generic type's parameter list. * */ get parameterIndex(): number; set parameterIndex(value: number); toString(): string; } declare class Type_AnyPointer_ImplicitMethodParameter extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get parameterIndex(): number; set parameterIndex(value: number); toString(): string; } declare const Type_AnyPointer_Which: { /** * A regular AnyPointer. * * The name "unconstrained" means as opposed to constraining it to match a type parameter. * In retrospect this name is probably a poor choice given that it may still be constrained * to be a struct, list, or capability. * */ readonly UNCONSTRAINED: 0; /** * This is actually a reference to a type parameter defined within this scope. * */ readonly PARAMETER: 1; /** * This is actually a reference to an implicit (generic) parameter of a method. The only * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand. * */ readonly IMPLICIT_METHOD_PARAMETER: 2; }; export type Type_AnyPointer_Which = (typeof Type_AnyPointer_Which)[keyof typeof Type_AnyPointer_Which]; declare class Type_AnyPointer extends Struct { static readonly UNCONSTRAINED: 0; static readonly PARAMETER: 1; static readonly IMPLICIT_METHOD_PARAMETER: 2; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * A regular AnyPointer. * * The name "unconstrained" means as opposed to constraining it to match a type parameter. * In retrospect this name is probably a poor choice given that it may still be constrained * to be a struct, list, or capability. * */ get unconstrained(): Type_AnyPointer_Unconstrained; _initUnconstrained(): Type_AnyPointer_Unconstrained; get _isUnconstrained(): boolean; set unconstrained(_: true); /** * This is actually a reference to a type parameter defined within this scope. * */ get parameter(): Type_AnyPointer_Parameter; _initParameter(): Type_AnyPointer_Parameter; get _isParameter(): boolean; set parameter(_: true); /** * This is actually a reference to an implicit (generic) parameter of a method. The only * legal context for this type to appear is inside Method.paramBrand or Method.resultBrand. * */ get implicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter; _initImplicitMethodParameter(): Type_AnyPointer_ImplicitMethodParameter; get _isImplicitMethodParameter(): boolean; set implicitMethodParameter(_: true); toString(): string; which(): Type_AnyPointer_Which; } declare const Type_Which: { readonly VOID: 0; readonly BOOL: 1; readonly INT8: 2; readonly INT16: 3; readonly INT32: 4; readonly INT64: 5; readonly UINT8: 6; readonly UINT16: 7; readonly UINT32: 8; readonly UINT64: 9; readonly FLOAT32: 10; readonly FLOAT64: 11; readonly TEXT: 12; readonly DATA: 13; readonly LIST: 14; readonly ENUM: 15; readonly STRUCT: 16; readonly INTERFACE: 17; readonly ANY_POINTER: 18; }; export type Type_Which = (typeof Type_Which)[keyof typeof Type_Which]; declare class Type extends Struct { static readonly VOID: 0; static readonly BOOL: 1; static readonly INT8: 2; static readonly INT16: 3; static readonly INT32: 4; static readonly INT64: 5; static readonly UINT8: 6; static readonly UINT16: 7; static readonly UINT32: 8; static readonly UINT64: 9; static readonly FLOAT32: 10; static readonly FLOAT64: 11; static readonly TEXT: 12; static readonly DATA: 13; static readonly LIST: 14; static readonly ENUM: 15; static readonly STRUCT: 16; static readonly INTERFACE: 17; static readonly ANY_POINTER: 18; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isVoid(): boolean; set void(_: true); get _isBool(): boolean; set bool(_: true); get _isInt8(): boolean; set int8(_: true); get _isInt16(): boolean; set int16(_: true); get _isInt32(): boolean; set int32(_: true); get _isInt64(): boolean; set int64(_: true); get _isUint8(): boolean; set uint8(_: true); get _isUint16(): boolean; set uint16(_: true); get _isUint32(): boolean; set uint32(_: true); get _isUint64(): boolean; set uint64(_: true); get _isFloat32(): boolean; set float32(_: true); get _isFloat64(): boolean; set float64(_: true); get _isText(): boolean; set text(_: true); get _isData(): boolean; set data(_: true); get list(): Type_List; _initList(): Type_List; get _isList(): boolean; set list(_: true); get enum(): Type_Enum; _initEnum(): Type_Enum; get _isEnum(): boolean; set enum(_: true); get struct(): Type_Struct; _initStruct(): Type_Struct; get _isStruct(): boolean; set struct(_: true); get interface(): Type_Interface; _initInterface(): Type_Interface; get _isInterface(): boolean; set interface(_: true); get anyPointer(): Type_AnyPointer; _initAnyPointer(): Type_AnyPointer; get _isAnyPointer(): boolean; set anyPointer(_: true); toString(): string; which(): Type_Which; } declare const Brand_Scope_Which: { /** * ID of the scope to which these params apply. * */ readonly BIND: 0; /** * List of parameter bindings. * */ readonly INHERIT: 1; }; export type Brand_Scope_Which = (typeof Brand_Scope_Which)[keyof typeof Brand_Scope_Which]; declare class Brand_Scope extends Struct { static readonly BIND: 0; static readonly INHERIT: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Bind: ListCtor; /** * ID of the scope to which these params apply. * */ get scopeId(): bigint; set scopeId(value: bigint); _adoptBind(value: Orphan>): void; _disownBind(): Orphan>; /** * List of parameter bindings. * */ get bind(): List; _hasBind(): boolean; _initBind(length: number): List; get _isBind(): boolean; set bind(value: List); get _isInherit(): boolean; set inherit(_: true); toString(): string; which(): Brand_Scope_Which; } declare const Brand_Binding_Which: { readonly UNBOUND: 0; readonly TYPE: 1; }; export type Brand_Binding_Which = (typeof Brand_Binding_Which)[keyof typeof Brand_Binding_Which]; declare class Brand_Binding extends Struct { static readonly UNBOUND: 0; static readonly TYPE: 1; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isUnbound(): boolean; set unbound(_: true); _adoptType(value: Orphan): void; _disownType(): Orphan; get type(): Type; _hasType(): boolean; _initType(): Type; get _isType(): boolean; set type(value: Type); toString(): string; which(): Brand_Binding_Which; } declare class Brand extends Struct { static readonly Scope: typeof Brand_Scope; static readonly Binding: typeof Brand_Binding; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Scopes: ListCtor; _adoptScopes(value: Orphan>): void; _disownScopes(): Orphan>; /** * For each of the target type and each of its parent scopes, a parameterization may be included * in this list. If no parameterization is included for a particular relevant scope, then either * that scope has no parameters or all parameters should be considered to be `AnyPointer`. * */ get scopes(): List; _hasScopes(): boolean; _initScopes(length: number): List; set scopes(value: List); toString(): string; } declare const Value_Which: { readonly VOID: 0; readonly BOOL: 1; readonly INT8: 2; readonly INT16: 3; readonly INT32: 4; readonly INT64: 5; readonly UINT8: 6; readonly UINT16: 7; readonly UINT32: 8; readonly UINT64: 9; readonly FLOAT32: 10; readonly FLOAT64: 11; readonly TEXT: 12; readonly DATA: 13; readonly LIST: 14; readonly ENUM: 15; readonly STRUCT: 16; /** * The only interface value that can be represented statically is "null", whose methods always * throw exceptions. * */ readonly INTERFACE: 17; readonly ANY_POINTER: 18; }; export type Value_Which = (typeof Value_Which)[keyof typeof Value_Which]; declare class Value extends Struct { static readonly VOID: 0; static readonly BOOL: 1; static readonly INT8: 2; static readonly INT16: 3; static readonly INT32: 4; static readonly INT64: 5; static readonly UINT8: 6; static readonly UINT16: 7; static readonly UINT32: 8; static readonly UINT64: 9; static readonly FLOAT32: 10; static readonly FLOAT64: 11; static readonly TEXT: 12; static readonly DATA: 13; static readonly LIST: 14; static readonly ENUM: 15; static readonly STRUCT: 16; static readonly INTERFACE: 17; static readonly ANY_POINTER: 18; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get _isVoid(): boolean; set void(_: true); get bool(): boolean; get _isBool(): boolean; set bool(value: boolean); get int8(): number; get _isInt8(): boolean; set int8(value: number); get int16(): number; get _isInt16(): boolean; set int16(value: number); get int32(): number; get _isInt32(): boolean; set int32(value: number); get int64(): bigint; get _isInt64(): boolean; set int64(value: bigint); get uint8(): number; get _isUint8(): boolean; set uint8(value: number); get uint16(): number; get _isUint16(): boolean; set uint16(value: number); get uint32(): number; get _isUint32(): boolean; set uint32(value: number); get uint64(): bigint; get _isUint64(): boolean; set uint64(value: bigint); get float32(): number; get _isFloat32(): boolean; set float32(value: number); get float64(): number; get _isFloat64(): boolean; set float64(value: number); get text(): string; get _isText(): boolean; set text(value: string); _adoptData(value: Orphan): void; _disownData(): Orphan; get data(): Data; _hasData(): boolean; _initData(length: number): Data; get _isData(): boolean; set data(value: Data); _adoptList(value: Orphan): void; _disownList(): Orphan; get list(): Pointer; _hasList(): boolean; get _isList(): boolean; set list(value: Pointer); get enum(): number; get _isEnum(): boolean; set enum(value: number); _adoptStruct(value: Orphan): void; _disownStruct(): Orphan; get struct(): Pointer; _hasStruct(): boolean; get _isStruct(): boolean; set struct(value: Pointer); get _isInterface(): boolean; set interface(_: true); _adoptAnyPointer(value: Orphan): void; _disownAnyPointer(): Orphan; get anyPointer(): Pointer; _hasAnyPointer(): boolean; get _isAnyPointer(): boolean; set anyPointer(value: Pointer); toString(): string; which(): Value_Which; } declare class Annotation extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * ID of the annotation node. * */ get id(): bigint; set id(value: bigint); _adoptBrand(value: Orphan): void; _disownBrand(): Orphan; /** * Brand of the annotation. * * Note that the annotation itself is not allowed to be parameterized, but its scope might be. * */ get brand(): Brand; _hasBrand(): boolean; _initBrand(): Brand; set brand(value: Brand); _adoptValue(value: Orphan): void; _disownValue(): Orphan; get value(): Value; _hasValue(): boolean; _initValue(): Value; set value(value: Value); toString(): string; } declare const ElementSize: { /** * aka "void", but that's a keyword. * */ readonly EMPTY: 0; readonly BIT: 1; readonly BYTE: 2; readonly TWO_BYTES: 3; readonly FOUR_BYTES: 4; readonly EIGHT_BYTES: 5; readonly POINTER: 6; readonly INLINE_COMPOSITE: 7; }; export type ElementSize = (typeof ElementSize)[keyof typeof ElementSize]; declare class CapnpVersion extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; get major(): number; set major(value: number); get minor(): number; set minor(value: number); get micro(): number; set micro(value: number); toString(): string; } declare class CodeGeneratorRequest_RequestedFile_Import extends Struct { static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; /** * ID of the imported file. * */ get id(): bigint; set id(value: bigint); /** * Name which *this* file used to refer to the foreign file. This may be a relative name. * This information is provided because it might be useful for code generation, e.g. to * generate #include directives in C++. We don't put this in Node.file because this * information is only meaningful at compile time anyway. * * (On Zooko's triangle, this is the import's petname according to the importing file.) * */ get name(): string; set name(value: string); toString(): string; } declare class CodeGeneratorRequest_RequestedFile extends Struct { static readonly Import: typeof CodeGeneratorRequest_RequestedFile_Import; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Imports: ListCtor; /** * ID of the file. * */ get id(): bigint; set id(value: bigint); /** * Name of the file as it appeared on the command-line (minus the src-prefix). You may use * this to decide where to write the output. * */ get filename(): string; set filename(value: string); _adoptImports(value: Orphan>): void; _disownImports(): Orphan>; /** * List of all imported paths seen in this file. * */ get imports(): List; _hasImports(): boolean; _initImports(length: number): List; set imports(value: List); toString(): string; } declare class CodeGeneratorRequest extends Struct { static readonly RequestedFile: typeof CodeGeneratorRequest_RequestedFile; static readonly _capnp: { displayName: string; id: string; size: ObjectSize; }; static _Nodes: ListCtor; static _SourceInfo: ListCtor; static _RequestedFiles: ListCtor; _adoptCapnpVersion(value: Orphan): void; _disownCapnpVersion(): Orphan; /** * Version of the `capnp` executable. Generally, code generators should ignore this, but the code * generators that ship with `capnp` itself will print a warning if this mismatches since that * probably indicates something is misconfigured. * * The first version of 'capnp' to set this was 0.6.0. So, if it's missing, the compiler version * is older than that. * */ get capnpVersion(): CapnpVersion; _hasCapnpVersion(): boolean; _initCapnpVersion(): CapnpVersion; set capnpVersion(value: CapnpVersion); _adoptNodes(value: Orphan>): void; _disownNodes(): Orphan>; /** * All nodes parsed by the compiler, including for the files on the command line and their * imports. * */ get nodes(): List; _hasNodes(): boolean; _initNodes(length: number): List; set nodes(value: List); _adoptSourceInfo(value: Orphan>): void; _disownSourceInfo(): Orphan>; /** * Information about the original source code for each node, where available. This array may be * omitted or may be missing some nodes if no info is available for them. * */ get sourceInfo(): List; _hasSourceInfo(): boolean; _initSourceInfo(length: number): List; set sourceInfo(value: List); _adoptRequestedFiles(value: Orphan>): void; _disownRequestedFiles(): Orphan>; /** * Files which were listed on the command line. * */ get requestedFiles(): List; _hasRequestedFiles(): boolean; _initRequestedFiles(length: number): List; set requestedFiles(value: List); toString(): string; } export interface CodeGeneratorFileContext { readonly nodes: Node[]; readonly imports: CodeGeneratorRequest_RequestedFile_Import[]; concreteLists: Array<[ string, Field ]>; generatedNodeIds: Set; generatedResultsPromiseIds: Set; tsPath: string; codeParts?: string[]; constructor: any; toString: () => string; } export declare class CodeGeneratorContext { files: CodeGeneratorFileContext[]; } export interface CapnpcCLIOptions { noTs?: boolean; js?: boolean; dts?: boolean; noDts?: boolean; schema?: string; output?: string; importPath?: string; tsconfig?: string; skipGenerateId?: boolean; noStandardImport?: boolean; projectRoot?: string; workspaceRoot?: string; tty?: boolean; } export type CapnpcOptions = Omit & { schemas: string | string[]; } & ({ tsconfig: ParsedCommandLine; tsconfigPath?: string; } | { tsconfig?: ParsedCommandLine; tsconfigPath: string; }); export type CapnpcResolvedOptions = Omit & Required> & { ts: boolean; importPath: string[]; schemas: string[]; tsconfig: ParsedCommandLine; }; export interface CapnpcResult { ctx: CodeGeneratorContext; files: Map; } /** * Compiles Cap'n Proto schemas into TypeScript files. * * @param options - The options for the compilation process. * @returns A promise that resolves to the compilation result. */ export declare function capnpc(options: CapnpcResolvedOptions): Promise; /** * Compiles Cap'n Proto schemas into TypeScript files. * * @param dataBuf - The buffer containing the Cap'n Proto schema data. * @param options - The options for the compilation process. * @returns A promise that resolves to the compilation result. */ export declare function compile(dataBuf: Buffer, options: CapnpcOptions): Promise<{ ctx: { files: { readonly req: CodeGeneratorRequest; readonly file: CodeGeneratorRequest_RequestedFile; readonly nodes: Node[]; readonly imports: CodeGeneratorRequest_RequestedFile_Import[]; concreteLists: Array<[ string, Field ]>; generatedNodeIds: Set; generatedResultsPromiseIds: Set; tsPath: string; codeParts: string[]; toString(): string; }[]; }; files: Map; } | undefined>; declare class PipelineClient implements Client { pipeline: Pipeline; constructor(pipeline: Pipeline); transform(): PipelineOp[]; call(call: Call): Answer; close(): void; } /** * A Pipeline is a generic wrapper for an answer */ export declare class Pipeline { ResultsClass: StructCtor; answer: Answer; parent?: Pipeline | undefined; op: PipelineOp; pipelineClient?: PipelineClient; constructor(ResultsClass: StructCtor, answer: Answer, op?: PipelineOp, parent?: Pipeline | undefined); transform(): PipelineOp[]; struct(): Promise; client(): PipelineClient; getPipeline(ResultsClass: StructCtor, off: number, defaultValue?: Pointer): Pipeline; } export declare abstract class DeferredTransport implements Transport { protected d?: Deferred; protected closed: boolean; abstract sendMessage(msg: Message$1): void; close(): void; recvMessage(): Promise; protected reject: (err: unknown) => void; protected resolve: (buf: ArrayBuffer) => void; } export declare class ErrorClient implements Client { err: Error; constructor(err: Error); call

(_call: Call): Answer; close(): void; } export declare function clientOrNull(client: Client | null): Client; export interface InterfaceDefinition { methods: Array>; } export declare class Registry { static readonly interfaces: Map; static register(id: bigint, def: InterfaceDefinition): void; static lookup(id: bigint): InterfaceDefinition | undefined; } export declare class Text extends List { static fromPointer(pointer: Pointer): Text; /** * Read a utf-8 encoded string value from this pointer. * * @param index The index at which to start reading; defaults to zero. * @returns The string value. */ get(index?: number): string; /** * Get the number of utf-8 encoded bytes in this text. This does **not** include the NUL byte. * * @returns The number of bytes allocated for the text. */ get length(): number; /** * Write a utf-8 encoded string value starting at the specified index. * * @param index The index at which to start copying the string. Note that if this is not zero the bytes * before `index` will be left as-is. All bytes after `index` will be overwritten. * @param value The string value to set. */ set(index: number, value: string): void; toString(): string; toJSON(): string; [Symbol.toPrimitive](): string; [Symbol.toStringTag](): string; } export declare class Void extends Struct { static readonly _capnp: _StructCtor; } declare function initStruct(size: ObjectSize, s: Struct): void; declare function initStructAt(index: number, StructClass: StructCtor, p: Pointer): T; declare function checkPointerBounds(index: number, s: Struct): void; declare function getInterfaceClientOrNullAt(index: number, s: Struct): Client; declare function getInterfaceClientOrNull(p: Pointer): Client; declare function resize(dstSize: ObjectSize, s: Struct): void; declare function getAs(StructClass: StructCtor, s: Struct): T; declare function getBit(bitOffset: number, s: Struct, defaultMask?: DataView): boolean; declare function getData(index: number, s: Struct, defaultValue?: Pointer): Data; declare function getDataSection(s: Struct): Pointer; declare function getFloat32(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getFloat64(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getInt16(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getInt32(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getInt64(byteOffset: number, s: Struct, defaultMask?: DataView): bigint; declare function getInt8(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getList(index: number, ListClass: ListCtor, s: Struct, defaultValue?: Pointer): List; declare function getPointer(index: number, s: Struct): Pointer; declare function getPointerAs(index: number, PointerClass: PointerCtor, s: Struct): T; declare function getPointerSection(s: Struct): Pointer; declare function getSize(s: Struct): ObjectSize; declare function getStruct(index: number, StructClass: StructCtor, s: Struct, defaultValue?: Pointer): T; declare function getText(index: number, s: Struct, defaultValue?: string): string; declare function getUint16(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getUint32(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function getUint64(byteOffset: number, s: Struct, defaultMask?: DataView): bigint; declare function getUint8(byteOffset: number, s: Struct, defaultMask?: DataView): number; declare function initData(index: number, length: number, s: Struct): Data; declare function initList(index: number, ListClass: ListCtor, length: number, s: Struct): List; declare function setBit(bitOffset: number, value: boolean, s: Struct, defaultMask?: DataView): void; declare function setFloat32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setFloat64(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setInt16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setInt32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setInt64(byteOffset: number, value: bigint, s: Struct, defaultMask?: DataView): void; declare function setInt8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setText(index: number, value: string, s: Struct): void; declare function setUint16(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setUint32(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function setUint64(byteOffset: number, value: bigint, s: Struct, defaultMask?: DataView): void; declare function setUint8(byteOffset: number, value: number, s: Struct, defaultMask?: DataView): void; declare function testWhich(name: string, found: number, wanted: number, s: Struct): void; declare function checkDataBounds(byteOffset: number, byteLength: number, s: Struct): void; declare function adopt(src: Orphan, p: T): void; declare function disown(p: T): Orphan; declare function dump$1(p: Pointer): string; declare function getListByteLength(elementSize: ListElementSize, length: number, compositeSize?: ObjectSize): number; declare function getListElementByteLength(elementSize: ListElementSize): number; declare function add(offset: number, p: Pointer): Pointer; declare function copyFrom(src: Pointer, p: Pointer): void; declare function erase(p: Pointer): void; declare function erasePointer(p: Pointer): void; declare function followFar(p: Pointer): Pointer; declare function followFars(p: Pointer): Pointer; declare function getCapabilityId(p: Pointer): number; declare function getContent(p: Pointer, ignoreCompositeIndex?: boolean): Pointer; declare function getFarSegmentId(p: Pointer): number; declare function getListElementSize(p: Pointer): ListElementSize; declare function getListLength(p: Pointer): number; declare function getOffsetWords(p: Pointer): number; declare function getPointerType(p: Pointer): PointerType; declare function getStructDataWords(p: Pointer): number; declare function getStructPointerLength(p: Pointer): number; declare function getStructSize(p: Pointer): ObjectSize; declare function getTargetCompositeListTag(p: Pointer): Pointer; declare function getTargetCompositeListSize(p: Pointer): ObjectSize; declare function getTargetListElementSize(p: Pointer): ListElementSize; declare function getTargetListLength(p: Pointer): number; declare function getTargetPointerType(p: Pointer): PointerType; declare function getTargetStructSize(p: Pointer): ObjectSize; declare function initPointer(contentSegment: Segment, contentOffset: number, p: Pointer): PointerAllocationResult; declare function isDoubleFar(p: Pointer): boolean; declare function isNull(p: Pointer): boolean; declare function relocateTo(dst: Pointer, src: Pointer): void; declare function setFarPointer(doubleFar: boolean, offsetWords: number, segmentId: number, p: Pointer): void; declare function setInterfacePointer(capId: number, p: Pointer): void; declare function getInterfacePointer(p: Pointer): number; declare function setListPointer(offsetWords: number, size: ListElementSize, length: number, p: Pointer, compositeSize?: ObjectSize): void; declare function setStructPointer(offsetWords: number, size: ObjectSize, p: Pointer): void; declare function validate(pointerType: PointerType, p: Pointer, elementSize?: ListElementSize): void; declare function copyFromInterface(src: Pointer, dst: Pointer): void; declare function copyFromList(src: Pointer, dst: Pointer): void; declare function copyFromStruct(src: Pointer, dst: Pointer): void; declare function trackPointerAllocation(message: Message, p: Pointer): void; declare class PointerAllocationResult { readonly pointer: Pointer; readonly offsetWords: number; constructor(pointer: Pointer, offsetWords: number); } export declare namespace utils { export { PointerAllocationResult, add, adopt, checkDataBounds, checkPointerBounds, copyFrom, copyFromInterface, copyFromList, copyFromStruct, disown, dump$1, erase, erasePointer, followFar, followFars, getAs, getBit, getCapabilityId, getContent, getData, getDataSection, getFarSegmentId, getFloat32, getFloat64, getInt16, getInt32, getInt64, getInt8, getInterfaceClientOrNull, getInterfaceClientOrNullAt, getInterfacePointer, getList, getListByteLength, getListElementByteLength, getListElementSize, getListLength, getOffsetWords, getPointer, getPointerAs, getPointerSection, getPointerType, getSize, getStruct, getStructDataWords, getStructPointerLength, getStructSize, getTargetCompositeListSize, getTargetCompositeListTag, getTargetListElementSize, getTargetListLength, getTargetPointerType, getTargetStructSize, getText, getUint16, getUint32, getUint64, getUint8, initData, initList, initPointer, initStruct, initStructAt, isDoubleFar, isNull, relocateTo, resize, setBit, setFarPointer, setFloat32, setFloat64, setInt16, setInt32, setInt64, setInt8, setInterfacePointer, setListPointer, setStructPointer, setText, setUint16, setUint32, setUint64, setUint8, testWhich, trackPointerAllocation, validate }; } export declare const AnyPointerList: ListCtor; export declare class BoolList extends List { static readonly _capnp: _ListCtor; get(index: number): boolean; set(index: number, value: boolean): void; [Symbol.toStringTag](): string; } export declare function CompositeList(CompositeClass: StructCtor): ListCtor; export declare const DataList: ListCtor; export declare class Float32List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Float64List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Int8List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Int16List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Int32List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Int64List extends List { static readonly _capnp: _ListCtor; get(index: number): bigint; set(index: number, value: bigint): void; [Symbol.toStringTag](): string; } export declare const InterfaceList: ListCtor; export declare function PointerList(PointerClass: PointerCtor): ListCtor; export declare class TextList extends List { static readonly _capnp: _ListCtor; get(index: number): string; set(index: number, value: string): void; [Symbol.toStringTag](): string; } export declare class Uint8List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Uint16List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Uint32List extends List { static readonly _capnp: _ListCtor; get(index: number): number; set(index: number, value: number): void; [Symbol.toStringTag](): string; } export declare class Uint64List extends List { static readonly _capnp: _ListCtor; get(index: number): bigint; set(index: number, value: bigint): void; [Symbol.toStringTag](): string; } export declare const VoidList: ListCtor; export declare const getFloat32Mask: (x: number) => DataView; export declare const getFloat64Mask: (x: number) => DataView; export declare const getInt16Mask: (x: number) => DataView; export declare const getInt32Mask: (x: number) => DataView; export declare const getInt64Mask: (x: bigint) => DataView; export declare const getInt8Mask: (x: number) => DataView; export declare const getUint16Mask: (x: number) => DataView; export declare const getUint32Mask: (x: number) => DataView; export declare const getUint64Mask: (x: bigint) => DataView; export declare const getUint8Mask: (x: number) => DataView; export declare function getBitMask(value: boolean, bitOffset: number): DataView; export {};