codec

package
v0.0.0-...-984c388 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ContentTypeJSON = "application/json"
View Source
const ContentTypeProtobuf = "application/protocol-buffers"

Variables

View Source
var (
	ErrInvalidData = errors.New("codec: invalid data")
)

Functions

func DecodeJSON

func DecodeJSON(src []byte, v any) error

func DecodeProtobuf

func DecodeProtobuf(src []byte, v any) error

func EncodeJSON

func EncodeJSON(v any) ([]byte, error)

func EncodeProtobuf

func EncodeProtobuf(v any) ([]byte, error)

Types

type Codec

type Codec interface {
	Encode(v any) ([]byte, error)
	Decode(src []byte, v any) error
}

type DecodeFunc

type DecodeFunc func(src []byte, v any) error

type EncodeFunc

type EncodeFunc func(v any) ([]byte, error)

type JSON

type JSON struct{}

func (JSON) Decode

func (p JSON) Decode(src []byte, v any) error

func (JSON) Encode

func (p JSON) Encode(v any) ([]byte, error)

type Protobuf

type Protobuf struct{}

func (Protobuf) Decode

func (p Protobuf) Decode(src []byte, v any) error

func (Protobuf) Encode

func (p Protobuf) Encode(v any) ([]byte, error)

Jump to

Keyboard shortcuts

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