encoding

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: BSD-2-Clause Imports: 11 Imported by: 2

README

go-encoding

An encoding and decoding library with multiple implementations for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshaler
	Unmarshaler
}

Codec is a combination of Unmarshaler and Marshaler

type Compressor

type Compressor interface {
	Compress([]byte) ([]byte, error)
	Decompress([]byte) ([]byte, error)
}

Compressor compress and decompress the given data

func NewGzipCompressor

func NewGzipCompressor() Compressor

func NewS2Compressor

func NewS2Compressor() Compressor

type DefaultCompressor

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

func (*DefaultCompressor) Compress

func (c *DefaultCompressor) Compress(data []byte) ([]byte, error)

func (*DefaultCompressor) Decompress

func (c *DefaultCompressor) Decompress(data []byte) ([]byte, error)

type GobCodec

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

func NewGobCodec

func NewGobCodec(compressor Compressor) *GobCodec

func (*GobCodec) Marshal

func (c *GobCodec) Marshal(value interface{}) ([]byte, error)

func (*GobCodec) Unmarshal

func (c *GobCodec) Unmarshal(byt []byte, ptr interface{}) (err error)

type JsonCodec

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

func NewJsonCodec

func NewJsonCodec(compressor Compressor) *JsonCodec

func (*JsonCodec) Marshal

func (c *JsonCodec) Marshal(value interface{}) ([]byte, error)

func (*JsonCodec) Unmarshal

func (c *JsonCodec) Unmarshal(byt []byte, ptr interface{}) (err error)

type Marshaler

type Marshaler interface {
	Marshal(interface{}) ([]byte, error)
}

Marshaler transforms the given value into bytes

type MsgPackCodec

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

func NewMsgPackCodec

func NewMsgPackCodec(compressor Compressor) *MsgPackCodec

func (*MsgPackCodec) Marshal

func (c *MsgPackCodec) Marshal(value interface{}) ([]byte, error)

func (*MsgPackCodec) Unmarshal

func (c *MsgPackCodec) Unmarshal(byt []byte, ptr interface{}) (err error)

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte, interface{}) error
}

Unmarshaler transforms bytes produced by Marshal back into a Go object

Jump to

Keyboard shortcuts

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