Перейти к содержимому
Русский

CborSerializer

Это содержимое пока не доступно на вашем языке.

Defined in: src/serialization/CborSerializer.ts:25

CBOR serializer — compact binary format, used by default for system messages (heartbeats, gossip, handoff) and available for any user type that benefits from smaller payloads than JSON.

It carries the SAME rich types as JsonSerializerDate, Map, Set, BidirectionalMap, bigint, Uint8Array, RegExp, URL, Error, every typed array, NaN/Infinity/-0 — as real instances, just in compact binary rather than tagged JSON text. The two are asserted equal by tests/unit/serialization/RichTypeParity.test.ts; they used to disagree, silently and lossily, until #1036.

One deliberate difference: undefined is carried natively (CBOR simple value 23), including as an object property, where JsonSerializer rejects it outright. That makes this the more permissive of the two.

Manifests are not used by the CBOR serializer itself — the caller is expected to round-trip compatible shapes. A user CLASS still decodes to a plain object unless the framework tags it; register a dedicated serializer via SerializationExtension for that.

new CborSerializer(): CborSerializer

CborSerializer

readonly id: 2 = 2

Defined in: src/serialization/CborSerializer.ts:26

Stable identifier that is embedded in every frame. Numbers 1..99 are reserved for the actor-ts built-ins (JSON=1, CBOR=2). User-defined serializers SHOULD use IDs ≥ RESERVED_SERIALIZER_IDS_BELOW.

Serializer.id


readonly includesManifest: false = false

Defined in: src/serialization/CborSerializer.ts:28

True when this serializer is willing to encode the given value.

Serializer.includesManifest


readonly name: "cbor" = 'cbor'

Defined in: src/serialization/CborSerializer.ts:27

Human-readable name, surfaced in diagnostics.

Serializer.name

fromBinary(bytes, _manifest): unknown

Defined in: src/serialization/CborSerializer.ts:36

Decode from binary. manifest is whatever was produced on the other side (or ” when the serializer does not use one).

Uint8Array

string

unknown

Serializer.fromBinary


manifest(_obj): string

Defined in: src/serialization/CborSerializer.ts:30

Return a tag describing the concrete type of obj so the decoder knows how to reconstruct it. Typical values: class name, event ID, “map”, “null”, etc. May return an empty string for serializers that don’t need a manifest.

unknown

string

Serializer.manifest


toBinary(obj): Uint8Array

Defined in: src/serialization/CborSerializer.ts:32

Encode to binary.

unknown

Uint8Array

Serializer.toBinary