@stryke/capnp
Version:
A package to assist in running the Cap'n Proto compiler and creating Cap'n Proto serialization protocol schemas.
172 lines (170 loc) • 4.23 kB
JavaScript
import {
Interface,
ObjectSize,
Pipeline,
Registry,
Server,
Struct,
utils
} from "./chunk-SCCB7KM2.js";
import {
__name
} from "./chunk-SHUYVCID.js";
// schemas/persistent.ts
var _capnpFileId = BigInt("0xb8630836983feed7");
var Persistent_SaveParams = class extends Struct {
static {
__name(this, "Persistent_SaveParams");
}
static _capnp = {
displayName: "SaveParams",
id: "f76fba59183073a5",
size: new ObjectSize(0, 1)
};
_adoptSealFor(value) {
utils.adopt(value, utils.getPointer(0, this));
}
_disownSealFor() {
return utils.disown(this.sealFor);
}
/**
* Seal the SturdyRef so that it can only be restored by the specified Owner. This is meant
* to mitigate damage when a SturdyRef is leaked. See comments above.
*
* Leaving this value null may or may not be allowed; it is up to the realm to decide. If a
* realm does allow a null owner, this should indicate that anyone is allowed to restore the
* ref.
*
*/
get sealFor() {
return utils.getPointer(0, this);
}
_hasSealFor() {
return !utils.isNull(utils.getPointer(0, this));
}
set sealFor(value) {
utils.copyFrom(value, utils.getPointer(0, this));
}
toString() {
return "Persistent_SaveParams_" + super.toString();
}
};
var Persistent_SaveResults = class extends Struct {
static {
__name(this, "Persistent_SaveResults");
}
static _capnp = {
displayName: "SaveResults",
id: "b76848c18c40efbf",
size: new ObjectSize(0, 1)
};
_adoptSturdyRef(value) {
utils.adopt(value, utils.getPointer(0, this));
}
_disownSturdyRef() {
return utils.disown(this.sturdyRef);
}
get sturdyRef() {
return utils.getPointer(0, this);
}
_hasSturdyRef() {
return !utils.isNull(utils.getPointer(0, this));
}
set sturdyRef(value) {
utils.copyFrom(value, utils.getPointer(0, this));
}
toString() {
return "Persistent_SaveResults_" + super.toString();
}
};
var Persistent_SaveResults$Promise = class {
static {
__name(this, "Persistent_SaveResults$Promise");
}
pipeline;
constructor(pipeline) {
this.pipeline = pipeline;
}
async promise() {
return await this.pipeline.struct();
}
};
var Persistent$Client = class _Persistent$Client {
static {
__name(this, "Persistent$Client");
}
client;
static interfaceId = BigInt("0xc8cb212fcd9f5691");
constructor(client) {
this.client = client;
}
static methods = [
{
ParamsClass: Persistent_SaveParams,
ResultsClass: Persistent_SaveResults,
interfaceId: _Persistent$Client.interfaceId,
methodId: 0,
interfaceName: "packages/capnp/schemas/persistent.capnp:Persistent",
methodName: "save"
}
];
/**
* Save a capability persistently so that it can be restored by a future connection. Not all
* capabilities can be saved -- application interfaces should define which capabilities support
* this and which do not.
*
*/
save(paramsFunc) {
const answer = this.client.call({
method: _Persistent$Client.methods[0],
paramsFunc
});
const pipeline = new Pipeline(Persistent_SaveResults, answer);
return new Persistent_SaveResults$Promise(pipeline);
}
};
Registry.register(Persistent$Client.interfaceId, Persistent$Client);
var Persistent$Server = class extends Server {
static {
__name(this, "Persistent$Server");
}
target;
constructor(target) {
super(target, [
{
...Persistent$Client.methods[0],
impl: target.save
}
]);
this.target = target;
}
client() {
return new Persistent$Client(this);
}
};
var Persistent = class extends Interface {
static {
__name(this, "Persistent");
}
static SaveParams = Persistent_SaveParams;
static SaveResults = Persistent_SaveResults;
static Client = Persistent$Client;
static Server = Persistent$Server;
static _capnp = {
displayName: "Persistent",
id: "c8cb212fcd9f5691",
size: new ObjectSize(0, 0)
};
toString() {
return "Persistent_" + super.toString();
}
};
export {
Persistent,
Persistent$Client,
Persistent$Server,
Persistent_SaveParams,
Persistent_SaveResults,
Persistent_SaveResults$Promise,
_capnpFileId
};