Skip to content

Codec

Defined in: packages/format-core/src/codec.ts:15

Bidirectional codec.

In and Out are separate so asymmetric protocols stay type-safe: an HTTP client decodes responses and encodes requests, and a send path must not accept a response type.

In

The decoded value type.

Out = In

The value type to encode.

View = Uint8Array

Backing representation of the accumulated input/output.

decode(view, context): DecodeResult<In, never>

Defined in: packages/format-core/src/decoder.ts:28

Attempt to decode one value from the front of view.

view is a window into the driver’s buffer and is invalidated as soon as this call returns. Copy anything retained in the returned value.

View

DecodeContext

DecodeResult<In, never>

Decoder.decode


encode(value): View | readonly View[]

Defined in: packages/format-core/src/encoder.ts:21

Encode a value into one or more output chunks.

Returning an array defers concatenation to a vectored write, so a length-prefixed protocol can emit [header, payload] without copying the payload.

Out

View | readonly View[]

Encoder.encode


optional reset(): void

Defined in: packages/format-core/src/decoder.ts:31

Discard accumulated decode state ahead of a protocol mode switch.

void

Decoder.reset