AvroSerializer
Defined in: src/serialization/AvroSerializer.ts:39
Avro Serializer — compact, schema-driven binary for a single type.
The schema library stays the user’s: pass a compiled avsc type (or
anything with the same toBuffer/fromBuffer pair) and this class owns
the parts that are easy to get wrong when wiring one up by hand —
the Buffer coercion avsc needs on the read path (a plain
Uint8Array, which is what base64 framing yields, throws deep inside
the decoder), byte ownership, the manifest, and errors that name the
serializer instead of surfacing a library-internal message.
import avsc from 'avsc';
const avroType = avsc.Type.forSchema({ name: 'Deposited', type: 'record', fields: [{ name: 'amount', type: 'int' }],});const avroOptions = AvroSerializerOptions.create<Deposited>() .withAvroType(avroType) .withId(100);const serializer = new AvroSerializer(avroOptions);Reaches stored rows through a store’s withSerializer(...) (one format
for the whole store) or, per (manifest, version), through
serializerCodec(serializer) and the SchemaRegistry.
Stateless and safe to share: every method reads only the compiled type.
Type Parameters
Section titled “Type Parameters”T = unknown
Implements
Section titled “Implements”Serializer<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AvroSerializer<
T>(options):AvroSerializer<T>
Defined in: src/serialization/AvroSerializer.ts:47
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”AvroSerializer<T>
Properties
Section titled “Properties”
readonlyid:number
Defined in: src/serialization/AvroSerializer.ts:40
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.
Implementation of
Section titled “Implementation of”includesManifest
Section titled “includesManifest”
readonlyincludesManifest:boolean
Defined in: src/serialization/AvroSerializer.ts:42
True when this serializer is willing to encode the given value.
Implementation of
Section titled “Implementation of”
readonlyname:string
Defined in: src/serialization/AvroSerializer.ts:41
Human-readable name, surfaced in diagnostics.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”fromBinary()
Section titled “fromBinary()”fromBinary(
bytes,manifest):T
Defined in: src/serialization/AvroSerializer.ts:70
Decode from binary. manifest is whatever was produced on the other
side (or ” when the serializer does not use one).
Parameters
Section titled “Parameters”Uint8Array
manifest
Section titled “manifest”string
Returns
Section titled “Returns”T
Implementation of
Section titled “Implementation of”manifest()
Section titled “manifest()”manifest(
_obj):string
Defined in: src/serialization/AvroSerializer.ts:60
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.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”toBinary()
Section titled “toBinary()”toBinary(
obj):Uint8Array
Defined in: src/serialization/AvroSerializer.ts:62
Encode to binary.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”Uint8Array
