msgpack

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package msgpack implements EDB's MessagePack struct encoding. Like Fast1, MessagePack remains supported, with migration to Fast2 or Compact2 intended.

Index

Constants

This section is empty.

Variables

View Source
var ErrDepth = errors.New("MessagePack nesting exceeds 256")
View Source
var ErrFormat = errors.New("invalid MessagePack value")

Functions

func Decode

func Decode(src []byte, value reflect.Value)

Decode panics on error. Use TryDecode to handle errors explicitly.

func Encode

func Encode(dst []byte, value reflect.Value) []byte

Encode panics on error. Use TryEncode to handle errors explicitly.

func TryDecode

func TryDecode(src []byte, value reflect.Value) error

func TryEncode

func TryEncode(dst []byte, value reflect.Value) ([]byte, error)

Types

type FieldEdit

type FieldEdit struct {
	Name  string
	Value []byte
}

FieldEdit replaces a string-keyed map field. A nil Value deletes the field; []byte{0xc0} stores explicit null. Values must contain one complete value.

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator borrows successive encoded children. Maps return keys and values; arrays return a missing key. No Go map, slice or element is decoded.

func (*Iterator) Len

func (it *Iterator) Len() int

func (*Iterator) Next

func (it *Iterator) Next() (key, value View, ok bool)

type View

type View struct {
	// contains filtered or unexported fields
}

View borrows one encoded MessagePack value. It never constructs a Go object. Trusted is for stored bytes; accessors still check boundaries before reading.

func BuildArray

func BuildArray(capacity int, entries iter.Seq[View]) View

BuildArray copies raw elements into one new array.

func BuildMap

func BuildMap(capacity int, entries iter.Seq2[View, View]) View

BuildMap copies raw entries into one new map, preserving their encodings. capacity is a sizing hint; nil values represent MessagePack null.

func Open

func Open(raw []byte) View

Open panics on error. Use TryOpen to handle errors explicitly.

func Trusted

func Trusted(raw []byte) View

func TryOpen

func TryOpen(raw []byte) (v View, err error)

func (View) Apply

func (v View) Apply(edits []FieldEdit) View

Apply copies the enclosing map once, preserving untouched bytes and key order. Repeated edits to a name use the last edit, including for duplicate wire keys. The input and result never share writable storage.

func (View) Bool

func (v View) Bool() bool

func (View) Bytes

func (v View) Bytes() []byte

func (View) Delete

func (v View) Delete(name string) View

Delete removes all occurrences of a map key, preserving every other encoded entry verbatim. An absent key leaves the original view unchanged.

func (View) Float

func (v View) Float() float64

func (View) Int

func (v View) Int() int64

func (View) Iter

func (v View) Iter() Iterator

func (View) Lookup

func (v View) Lookup(name string) View

Lookup scans encoded field boundaries and borrows only the selected value. It checks all keys so duplicate keys retain MessagePack's last-value semantics.

func (View) Missing

func (v View) Missing() bool

func (View) Nil

func (v View) Nil() bool

func (View) Raw

func (v View) Raw() []byte

func (View) Set

func (v View) Set(name string, value []byte) View

Set replaces a map field while copying every untouched key and value verbatim. The result is owned, and does not mutate or retain spare capacity in the input.

func (View) Time

func (v View) Time() values.Value

Time reads the standard 32/64/96-bit integer timestamp extensions, the historical [seconds,nanoseconds] format, and RFC3339 text. It borrows bytes for wide dates instead of decoding a Go object or allocating a timestamp.

func (View) Uint

func (v View) Uint() uint64

Jump to

Keyboard shortcuts

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