Documentation
¶
Overview ¶
Package zapcodec is a drop-in replacement for linearcodec that emits the ZAP-native little-endian wire layout. It implements the same codec.GeneralCodec (= codec.Registry + codec.Codec) surface so a codec.Manager can host both side by side.
Wire-format delta vs linearcodec:
- All multi-byte integers are little-endian. (linearcodec is big- endian.) x86_64 and arm64 hardware is LE-native, so LE writes map to single MOV instructions where BE writes need BSWAP.
- Interface type-id prefixes are uint32 LE (linearcodec also uses uint32 but in BE).
- String length prefix is uint16 LE (linearcodec uses uint16 BE).
- All else is byte-equivalent to linearcodec: slice/map length prefixes are uint32, bool is a single byte, struct fields are emitted in serialize-tag order.
What is NOT in this codec:
- No ZAP wire header. The codec.Manager prepends a uint16 codec version (PackShort) and that BigEndian-encoded short is the only BE bytes in a zapcodec-encoded blob. Everything the codec itself writes is little-endian.
- No deferred-write/zero-copy ZAP Object/List machinery. That's a separate concern handled by zap_native at the platformvm tx layer. zapcodec is the generic reflection-driven codec that hosts all platformvm tx types — same role linearcodec plays today.
Index ¶
Constants ¶
const DefaultTagName = reflectcodec.DefaultTagName
DefaultTagName is the struct tag this codec honours (same as linearcodec: "serialize").
Variables ¶
var ( // ErrInsufficientLength indicates the packer ran out of room (either // growing past MaxSize on write, or reading past the buffer on read). ErrInsufficientLength = errors.New("zapcodec: packer has insufficient length") )
Functions ¶
This section is empty.
Types ¶
type Codec ¶
Codec is the zapcodec local interface — codec.GeneralCodec extended with SkipRegistrations so call sites can preserve linearcodec slot layouts during a coexistence window.
func New ¶
New returns a zapcodec instance that honours the given struct tag names. Concurrency-safe.
func NewDefault ¶
func NewDefault() Codec
NewDefault is the standard constructor — uses the "serialize" tag.