interface · Browser and Node
BodyCodec
@toip-tools/trust-coreView sourceimport { type BodyCodec } from "@toip-tools/trust-core";
Declaration
interface BodyCodec {
/** The body's first byte: 0x7B for JSON, 0x01 for CTT1. */
readonly format: number;
/** The body bytes, or null when this codec can't carry `doc` exactly (use JSON). */
encode(doc: TrustTaskDocument<unknown>, ctx: BodyContext): Uint8Array | null;
decode(body: Uint8Array, ctx: BodyContext): TrustTaskDocument<unknown>;
}
Properties
formatrequired · readonlynumberThe body's first byte: 0x7B for JSON, 0x01 for CTT1.
Methods
encode
The body bytes, or null when this codec can't carry doc exactly (use JSON).
encode(doc: TrustTaskDocument<unknown>, ctx: BodyContext): Uint8Array | null;
Parameters
docrequiredTrustTaskDocument<unknown>ctxrequiredBodyContext
Returns
Uint8Array<ArrayBufferLike> | nulldecode
decode(body: Uint8Array, ctx: BodyContext): TrustTaskDocument<unknown>;
Parameters
bodyrequiredUint8Array<ArrayBufferLike>ctxrequiredBodyContext
Returns
TrustTaskDocument<unknown>