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.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”In
The decoded value type.
Out = In
The value type to encode.
View = Uint8Array
Backing representation of the accumulated input/output.
Methods
Section titled “Methods”decode()
Section titled “decode()”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.
Parameters
Section titled “Parameters”View
context
Section titled “context”Returns
Section titled “Returns”DecodeResult<In, never>
Inherited from
Section titled “Inherited from”encode()
Section titled “encode()”encode(
value):View| readonlyView[]
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.
Parameters
Section titled “Parameters”Out
Returns
Section titled “Returns”View | readonly View[]
Inherited from
Section titled “Inherited from”reset()?
Section titled “reset()?”
optionalreset():void
Defined in: packages/format-core/src/decoder.ts:31
Discard accumulated decode state ahead of a protocol mode switch.
Returns
Section titled “Returns”void