@hazae41/jsonrpc
Version:
Rust-like JSON-RPC for TypeScript
16 lines (13 loc) • 700 B
TypeScript
import { Ok, Err, Result } from '@hazae41/result';
import { RpcErrInit, RpcErr } from './err.js';
import { RpcOkInit, RpcOk } from './ok.js';
import { RpcId } from './request.js';
type RpcResponseInit<T = unknown> = RpcOkInit<T> | RpcErrInit;
type RpcResponse<T = unknown> = RpcOk<T> | RpcErr;
declare namespace RpcResponse {
function from<T>(init: RpcResponseInit<T>): RpcErr | RpcOk<T>;
function rewrap<T extends Ok.Infer<T>>(id: RpcId, result: T): RpcOk<Ok.Inner<T>>;
function rewrap<T extends Err.Infer<T>>(id: RpcId, result: T): RpcErr;
function rewrap<T extends Result.Infer<T>>(id: RpcId, result: T): RpcResponse<Ok.Inner<T>>;
}
export { RpcResponse, type RpcResponseInit };