UNPKG

@metamask/ocap-kernel

Version:
50 lines 1.53 kB
import type { CapData } from "@endo/marshal"; import type { KRef } from "../types.mjs"; type ObjectStandin = { getKref: () => string; iface: () => string; }; export type SlotValue = ObjectStandin | Promise<unknown>; /** * Obtain a value serializable via `kser` for a given KRef. * * @param kref - The KRef string to get a value for. * @param iface - Option interface type descriptor string. * * @returns A `kser` serializable value for `kref`. */ export declare function kslot(kref: string, iface?: string): SlotValue; /** * Obtain the KRef associated with a value that was serialized with `kser`. * * @param obj - The value of interest. * * @returns a KRef string for `obj`. */ export declare function krefOf(obj: SlotValue): string; /** * Serialize a value in kernel space. * * @param value - The value to be serialized. * * @returns a capdata object that can be deserialized with `kunser`. */ export declare function kser(value: unknown): CapData<KRef>; /** * Deserialize a value that was serialized with `kser`. * * @param serializedValue -- The value to deserialize. * * @returns the deserialization of `serializedValue`. */ export declare function kunser(serializedValue: CapData<KRef>): unknown; /** * Produce a serialized form of an Error. * * @param message - The error message to construct the Error with. * * @returns The resulting error after serialization. */ export declare function makeError(message: string): CapData<KRef>; export {}; //# sourceMappingURL=kernel-marshal.d.mts.map