msgpack

package
v0.0.0-...-388d6c9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package msgpack provides a msgpack codec for encoding and decoding

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(b []byte, value any) error

Decode wrap for msgpack.Decode

func Encode

func Encode(item any) ([]byte, error)

Encode wrap for msgpack.Encode

func S2Compress

func S2Compress(data []byte) []byte

S2Compress compresses a byte array using s2.

func S2Decompress

func S2Decompress(b []byte) ([]byte, error)

S2Decompress decompresses a byte array using s2.

Types

type CompressFunc

type CompressFunc func(data []byte) []byte

CompressFunc is a function that compresses a byte array.

type DecompressFunc

type DecompressFunc func(b []byte) ([]byte, error)

DecompressFunc is a function that decompresses a byte array.

type MarshalFunc

type MarshalFunc func(any) ([]byte, error)

MarshalFunc is a function that marshals a value into a byte array.

type MsgPack

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

MsgPack is a msgpack codec.

func New

func New(opts ...OptionFunc) *MsgPack

New creates a new MsgPack.

func (*MsgPack) Decode

func (p *MsgPack) Decode(b []byte, value any) error

Decode a msgpack encoded byte array

func (*MsgPack) Encode

func (p *MsgPack) Encode(item any) ([]byte, error)

Encode wraps msgpack.Marshal and compresses the result.

type OptionFunc

type OptionFunc func(*MsgPack)

OptionFunc is a function that configures a MsgPack.

func WithCompressFunc

func WithCompressFunc(fnc CompressFunc, fnd DecompressFunc) OptionFunc

WithCompressFunc sets the compress function.

func WithMarshalFunc

func WithMarshalFunc(fnm MarshalFunc, fnu UnmarshalFunc) OptionFunc

WithMarshalFunc sets the marshal function.

type UnmarshalFunc

type UnmarshalFunc func([]byte, any) error

UnmarshalFunc is a function that unmarshals a byte array into a value.

Jump to

Keyboard shortcuts

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