Skip to content
API reference

rpc

Import
import * as api from "@fungi.computer/agar/rpc";
Kind Export Description
constant rpcVoid A method that decodes and releases an empty RPC result.
function rpcHandleSchema() Cap’n Web stubs are callable proxies, not records. Select only owner methods and bind their receiver before the maintained function schemas wrap them.
function rpcDataSchema() Copy an owned data result through its domain decoder, then release the RPC envelope. Live resources use their own handle schemas instead.
function rpcMethod() Wrap an RPC method’s result schema into a Zod function schema: the decoded value resolves on success, and a malformed result is rethrown as a PROTOCOL AppError after releasing the raw RPC envelope.

rpcVoidconstant

Section titled “rpcVoid”
Signature
const rpcVoid: ZodFunction<
$ZodFunctionArgs,
ZodPromise<ZodPipe<ZodUnknown, ZodTransform<void, unknown>>>
>;

A method that decodes and releases an empty RPC result.

rpcHandleSchema()function

Section titled “rpcHandleSchema()”
Signature
function rpcHandleSchema<S>(
methods,
): ZodPipe<
ZodUnknown,
ZodTransform<
Awaited<
$InferObjectOutput<
{ -readonly [P in string | number | symbol]: S[P] },
{}
> &
object
>,
unknown
>
>;

Cap’n Web stubs are callable proxies, not records. Select only owner methods and bind their receiver before the maintained function schemas wrap them.

Type Parameter
S extends Readonly<{ [k: string]: $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }>
Parameter Type
methods S

ZodPipe<ZodUnknown, ZodTransform<Awaited<$InferObjectOutput<{ -readonly [P in string | number | symbol]: S[P] }, { }> & object>, unknown>>


rpcDataSchema()function

Section titled “rpcDataSchema()”
Signature
function rpcDataSchema<T>(
result,
): ZodPipe<ZodUnknown, ZodTransform<Awaited<T>, unknown>>;

Copy an owned data result through its domain decoder, then release the RPC envelope. Live resources use their own handle schemas instead.

Type Parameter
T
Parameter Type
result ZodType<T>

ZodPipe<ZodUnknown, ZodTransform<Awaited<T>, unknown>>


Signature
function rpcMethod<T>(
result,
): ZodFunction<
$ZodFunctionArgs,
ZodPromise<ZodPipe<ZodUnknown, ZodTransform<Awaited<T>, unknown>>>
>;

Wrap an RPC method’s result schema into a Zod function schema: the decoded value resolves on success, and a malformed result is rethrown as a PROTOCOL AppError after releasing the raw RPC envelope.

Type Parameter
T
Parameter Type
result ZodType<T>

ZodFunction<$ZodFunctionArgs, ZodPromise<ZodPipe<ZodUnknown, ZodTransform<Awaited<T>, unknown>>>>