Documentation
¶
Overview ¶
Package msgpackwire provides bounded MessagePack decoding and deterministic encoding.
Decoding accepts exactly one object. Untyped maps require string keys while typed map targets may declare other comparable key types. Integer widths are preserved unless NormalizeNumericWidths is selected. The standard timestamp extension is supported; unknown extension IDs are rejected. A structural preflight rejects truncated objects and impossible collection lengths before target allocation. MessagePack is deliberately excluded from wire.DetectFormat because arbitrary binary bytes cannot be identified reliably.
Index ¶
- Constants
- Variables
- func Decode(payload []byte, target any, options DecodeOptions) error
- func DecodeReader(reader io.Reader, target any, options DecodeOptions) error
- func Encode(value any, options EncodeOptions) ([]byte, error)
- func EncodeWriter(writer io.Writer, value any, options EncodeOptions) error
- type DecodeOptions
- type EncodeOptions
Constants ¶
const ( // DefaultMaxNestedLevels bounds recursive arrays and maps. DefaultMaxNestedLevels = 32 // DefaultMaxArrayElements bounds allocation amplification from arrays. DefaultMaxArrayElements = 128 << 10 // DefaultMaxMapPairs bounds allocation amplification from maps. DefaultMaxMapPairs = 64 << 10 )
const DefaultMaxBytes int64 = 1 << 20
DefaultMaxBytes is the default maximum MessagePack object size.
Variables ¶
var ErrPayloadTooLarge = errors.New("payload exceeds size limit")
ErrPayloadTooLarge identifies MessagePack objects over the byte limit.
Functions ¶
func Decode ¶
func Decode(payload []byte, target any, options DecodeOptions) error
Decode parses exactly one MessagePack object into target.
func DecodeReader ¶
func DecodeReader(reader io.Reader, target any, options DecodeOptions) error
DecodeReader reads one bounded MessagePack object into target.
func Encode ¶
func Encode(value any, options EncodeOptions) ([]byte, error)
Encode serializes value with lexically sorted map keys.
func EncodeWriter ¶
func EncodeWriter(writer io.Writer, value any, options EncodeOptions) error
EncodeWriter serializes value and writes one complete MessagePack object.