Optionallimits: DecodeLimitsFixlen subtype of the header last accepted by readHeader — one of
FixlenSubtype — when its wire is WireType.Fixlen or
WireType.ArrayFixlen; -1 otherwise (a non-fixlen field, or a
fixlen field whose subtype word is truncated away).
The four fixlen subtypes (fp32, fp64, string, blob) all share one
wire type, so wire alone cannot separate them. This is the
companion accessor that can: a generated guard reads it right after
readHeader to skip a field whose delivered subtype contradicts the
schema (MESSAGE_SPEC §7.3), exactly as it already does on wire for
the other kinds:
case 9: if (c.wire !== WireType.Fixlen || c.fixSub !== FixlenSubtype.Fp64) {
c.skip(c.wire); break;
} o.somefp64 = c.readFp64(); break;
It is peeked — the subtype word is not consumed — so the matching typed
reader (or skip) still reads and validates it, and a malformed or
truncated word surfaces INVALID / INCOMPLETE there as before.
Field id of the header last accepted by readHeader.
Wire type of the header last accepted by readHeader.
Read a blob scalar (wire WireType.Fixlen, subtype blob) as a zero-copy Uint8Array view into the source buffer.
OptionalschemaMaxlen: numberRead a 32-bit float scalar (wire WireType.Fixlen, subtype fp32).
Read an fp32 array (wire WireType.ArrayFixlen, element subtype fp32).
OptionalschemaCount: numberRead an fp32 array as its raw little-endian element payload (count * 4
bytes), zero-copy — the bit-preserving companion to readFp32Array.
Widening each element to a JS number quiets an fp32 signaling NaN just as
on the scalar path (§4.6; see readFp32Raw), so bit-exact decode reads
the whole payload here and re-emits it with OStream.writeFp32ArrayRaw
(corelib-ts#66). The header (element subtype fp32, size 4) is validated
exactly as in readFp32Array; the returned view aliases the source
buffer, like readBlob.
OptionalschemaCount: numberRead a 32-bit float scalar as its raw 4 wire bytes (little-endian), zero-copy — the bit-preserving companion to readFp32.
readFp32 returns a JS number (a 64-bit double), and widening an
fp32 signaling NaN into a double quiets it (0x7F800001 → 0x7FC00001), so a
value consumer can never round-trip one bit-for-bit (§4.6). Generated
bit-exact decode reads the bytes here instead and re-emits them verbatim with
OStream.writeFixlen (subtype fp32) — mirroring the visitor raw
channel on the push paths (fast.ts / state.ts), which the pull path was
missing (corelib-ts#66).
The header (subtype fp32, length 4) is validated exactly as in readFp32; the returned view aliases the source buffer, valid only until it is reused, like readBlob.
Read a 64-bit float scalar (wire WireType.Fixlen, subtype fp64).
Read an fp64 array (wire WireType.ArrayFixlen, element subtype fp64).
OptionalschemaCount: numberAdvance to the next field header. Returns true and sets id /
wire when a field follows; returns false — consuming the marker —
at the end of the buffer or at the sequence-end that closes the sequence
this decoder is reading. So a generated per-type decoder loops uniformly:
while (c.readHeader()) {
switch (c.id) {
case 4: this.u32 = Number(c.readUnsigned()); break;
case 10: this.child = Child.decodeFrom(c); break; // nested sequence
default: c.skip(c.wire); break; // unknown field
}
}
At the root the loop ends at end-of-buffer; inside a nested sequence it ends
at the matching WireType.SequenceEnd (which is consumed). A field
whose id is out of range throws SofabError (INVALID_MSG).
Read a signed scalar (wire WireType.Signed), zig-zag, number-first.
Read a signed array (wire WireType.ArraySigned), zig-zag, number-first per element.
OptionalschemaCount: numberRead a UTF-8 string scalar (wire WireType.Fixlen, subtype string).
Pass the schema maxlen (byte length) for a bounded string so an
over-length is rejected as INVALID at the header, before the payload is
taken (see fixlenLen); the wire length is exactly the UTF-8 byte
length, so the check is exact. Omit for an unbounded string.
OptionalschemaMaxlen: numberRead an unsigned scalar (wire WireType.Unsigned), number-first.
Read an unsigned array (wire WireType.ArrayUnsigned), number-first
per element. Pass the schema count for a bounded array so an over-count is
rejected as INVALID at the header (see arrayCount); omit it for an
unbounded array (today's behavior).
OptionalschemaCount: numberRead an unsigned 64-bit array into Long[] — the bigint-free path.
Each element keeps the raw lo/hi halves; call Long.toBigInt to
materialise only the values the caller actually needs.
OptionalschemaCount: numberConsume the value of the field whose header readHeader just accepted,
discarding it — for a default: branch that keeps the cursor in sync on an
unknown id. Pass wire. A WireType.SequenceStart skips the
whole nested sequence.
A pull decoder over a complete message held in one contiguous buffer.
Usage from generated code: loop on readHeader; for each field switch on id and call the matching
read*(which consumes that field's value and advances the cursor); recurse into a child type's decoder on a nested sequence; fall through to skip for an unknown id. See readHeader.Pass DecodeLimits to cap array counts and string / blob lengths; an over-limit field throws SofabError (
LIMIT_EXCEEDED) at its header, before it is materialized. Omit for no caps (the default).