codec

package
v0.0.0-...-7592eae Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: GPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Msgpack

Default is the default CodecFunc

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(val any) error
	Decode(val any) error
	Unmarshal(data []byte, v any) error
	Marshal(v any) ([]byte, error)
}

Codec is able to encode and decode messages to/from the given io.ReadWriter

func Gob

func Gob(rw io.ReadWriter) Codec

Gob is a CodecFunc that creates a Gob Codec

func JSON

func JSON(rw io.ReadWriter) Codec

JSON is a CodecFunc that creates a JSON Codec

func Msgpack

func Msgpack(rw io.ReadWriter) Codec

Msgpack is a CodecFunc that creates a Msgpack Codec

type CodecFunc

type CodecFunc func(io.ReadWriter) Codec

CodecFunc is a function that returns a new Codec bound to the given io.ReadWriter

type GobCodec

type GobCodec struct {
	*gob.Encoder
	*gob.Decoder
}

func (GobCodec) Marshal

func (GobCodec) Marshal(v any) ([]byte, error)

func (GobCodec) Unmarshal

func (GobCodec) Unmarshal(data []byte, v any) error

type JsonCodec

type JsonCodec struct {
	*json.Encoder
	*json.Decoder
}

func (JsonCodec) Marshal

func (JsonCodec) Marshal(v any) ([]byte, error)

func (JsonCodec) Unmarshal

func (JsonCodec) Unmarshal(data []byte, v any) error

type MsgpackCodec

type MsgpackCodec struct {
	*msgpack.Encoder
	*msgpack.Decoder
}

func (MsgpackCodec) Marshal

func (MsgpackCodec) Marshal(v any) ([]byte, error)

func (MsgpackCodec) Unmarshal

func (MsgpackCodec) Unmarshal(data []byte, v any) error

Jump to

Keyboard shortcuts

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