Help us shape the future of Go! Take the 2026 Go Developer Survey

zapcodec

package
v1.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

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

View Source
const DefaultTagName = reflectcodec.DefaultTagName

DefaultTagName is the struct tag this codec honours (same as linearcodec: "serialize").

Variables

View Source
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

type Codec interface {
	codec.Registry
	codec.Codec
	SkipRegistrations(int)
}

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

func New(tagNames []string) Codec

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL