edf

package
v1.999.330 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 14 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBinaryTooLong    = fmt.Errorf("binary too long - max allowed length is 2^32-1 bytes (4GB)")
	ErrStructTooLong    = fmt.Errorf("struct too long - max allowed encoded length is 2^32-1 bytes (4GB) with schema evolution enabled")
	ErrStringTooLong    = fmt.Errorf("string too long - max allowed length is 2^16-1 (65535) bytes")
	ErrAtomTooLong      = fmt.Errorf("atom too long - max allowed length is 255 bytes")
	ErrErrorTooLong     = fmt.Errorf("error too long - max allowed length is 32767 bytes")
	ErrMaxDepthExceeded = fmt.Errorf("max encoding depth exceeded (cyclic reference?)")
)

Functions

func Decode

func Decode(packet []byte, options Options) (_ any, _ []byte, ret error)

Decode

func Encode

func Encode(x any, b *lib.Buffer, options Options) (ret error)

Encode

func GetAtomCache

func GetAtomCache() map[uint16]gen.Atom

func GetErrCache

func GetErrCache() map[uint16]error

func GetRegCache

func GetRegCache() map[uint16]string

func LookupType added in v1.999.330

func LookupType(name string) (reflect.Type, bool)

LookupType returns the reflect.Type registered under the canonical EDF name ("#pkgpath/TypeName"), matched exactly. The old short-name fallback took the first suffix hit over a sync.Map, so the same name could resolve to a different package's type on every call. Search by short name over RegisteredTypes instead.

func MakeEncodeRegTypeCache

func MakeEncodeRegTypeCache(names []string) *sync.Map

func RegisterAtom

func RegisterAtom(a gen.Atom) error

func RegisterError

func RegisterError(e error) error

func RegisterTypeOf

func RegisterTypeOf(v any) error

func RegisterTypesOf added in v1.999.330

func RegisterTypesOf(types []any) error

RegisterTypesOf registers a batch with iterative resolve. Order-agnostic: types with unresolved dependencies are retried while progress is made. Returns error listing types that cannot be resolved after exhausting passes.

func RegisteredAtoms added in v1.999.330

func RegisteredAtoms() []gen.RegisteredAtomInfo

RegisteredAtoms lists the atom cache entries, ordered by cache id. An unregistered atom is absent here and encoded in full on every hop, so an atom missing from this list is a wire-size cost, never a correctness problem.

The cache is process-global, not per-node: two nodes in one process report the same list.

func RegisteredErrors added in v1.999.330

func RegisteredErrors() []gen.RegisteredErrorInfo

RegisteredErrors lists the sentinel errors in the wire-format error cache, ordered by cache id. Framework sentinels pre-registered at init are included, so the result is the whole dictionary this process would offer at handshake - not only what the caller registered.

The cache is process-global, not per-node: two nodes in one process report the same list.

func RegisteredTypes added in v1.999.330

func RegisteredTypes() []gen.RegisteredTypeInfo

RegisteredTypes returns all registered EDF type metadata in registration order. Each entry is a value snapshot of the underlying *gen.RegisteredTypeInfo; counter fields reflect their values at snapshot time.

Types

type Marshaler

type Marshaler interface {
	MarshalEDF(io.Writer) error
}

type Options

type Options struct {
	AtomCache   *sync.Map // atom => id (encoding), id => atom (decoding)
	AtomMapping *sync.Map // atomX => atomY (encoding/decoding)
	RegCache    *sync.Map // type/name => id (encoding), id => type (for decoding)
	ErrCache    *sync.Map // error => id (for encoder), id => error (for decoder)
	Cache       *sync.Map // common cache (caching reflect.Type => encoder, string([]byte) => decoder)
	MaxDepth    int       // max encoding depth for pointers (default 100)
	// WrappedErrorsSupported: peer supports *gen.Error wrapped wire format.
	WrappedErrorsSupported bool
	// SchemaEvolution: length-prefix encoded structs so a peer with a different
	// field count tolerates the difference (extra skipped, missing zero-valued).
	SchemaEvolution bool
}

Options for encoding/decoding

type Unmarshaler

type Unmarshaler interface {
	UnmarshalEDF([]byte) error
}

Jump to

Keyboard shortcuts

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