DecodeDriver
Defined in: packages/format-core/src/decode-driver.ts:45
Drives a Decoder over a DecodeBuffer, dispatching every outcome to a DecodeSink.
This is the one engine shared by every consumption shape: decodeAll
(one-shot, idle: {kind: "exhausted"}), DecodeStream (Web Streams, idle: {kind: "exhausted"} at flush time), and net/core’s FrameLink (live,
idle: {kind: "timer", schedule} backed by a real clock). Before this
existed, the same accumulate-and-dispatch loop was hand-written three times —
Framer.drain/Framer.handleSilenceTimeout, CborSequenceDecoder, and
NdjsonParseStream — each slightly differently.
Message-mode datagrams (one transport delivery = one complete value, no state
carried between deliveries) are deliberately out of scope: call the decoder
directly for that case, as FrameLink does. A buffer that never accumulates
across calls gains nothing from this class.
Type Parameters
Section titled “Type Parameters”T
The decoded value type.
View = Uint8Array
What the decoder reads. Matches the buffer’s view type.
Chunk = View
What write accepts. Matches the buffer’s chunk type.
W = never
The decoder’s warning type.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DecodeDriver<
T,View,Chunk,W>(options):DecodeDriver<T,View,Chunk,W>
Defined in: packages/format-core/src/decode-driver.ts:59
Parameters
Section titled “Parameters”options
Section titled “options”DecodeDriverOptions<T, View, Chunk, W>
Returns
Section titled “Returns”DecodeDriver<T, View, Chunk, W>
Accessors
Section titled “Accessors”buffered
Section titled “buffered”Get Signature
Section titled “Get Signature”get buffered():
number
Defined in: packages/format-core/src/decode-driver.ts:67
Unconsumed input currently held.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: packages/format-core/src/decode-driver.ts:96
Discard buffered input and decoder state, ahead of a mode switch.
Returns
Section titled “Returns”void
close()
Section titled “close()”close():
void
Defined in: packages/format-core/src/decode-driver.ts:85
No more input will ever arrive. Triggers a final decode attempt and, if the decoder is still inconclusive, reports DecodeSink.onTruncated.
Returns
Section titled “Returns”void
discardBuffer()
Section titled “discardBuffer()”discardBuffer():
void
Defined in: packages/format-core/src/decode-driver.ts:124
Discard buffered input without touching decoder state.
Returns
Section titled “Returns”void
resync()
Section titled “resync()”resync():
void
Defined in: packages/format-core/src/decode-driver.ts:108
Cancel any pending idle timer and reset the incomplete-hint, without discarding buffered input. Used ahead of an operation that changes decode semantics mid-stream (a codec or transport swap) but must keep unconsumed input for whatever reads it next.
Returns
Section titled “Returns”void
swapDecoder()
Section titled “swapDecoder()”swapDecoder(
decoder):void
Defined in: packages/format-core/src/decode-driver.ts:118
Replace the decoder, keeping buffered input for the new one to interpret (an RTMP handshake completing, an SMTP session negotiating a new mode).
Parameters
Section titled “Parameters”decoder
Section titled “decoder”Decoder<T, View, W>
Returns
Section titled “Returns”void
takeResidue()
Section titled “takeResidue()”takeResidue():
Chunk
Defined in: packages/format-core/src/decode-driver.ts:130
Remove and return the buffered input without discarding decoder state.
Returns
Section titled “Returns”Chunk
write()
Section titled “write()”write(
chunk):void
Defined in: packages/format-core/src/decode-driver.ts:72
New input arrived: append it and decode as much as possible.
Parameters
Section titled “Parameters”Chunk
Returns
Section titled “Returns”void