codec2

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSON_CODEC = iota
)

Variables

This section is empty.

Functions

func JsonMarshal

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

func JsonUnmarshal

func JsonUnmarshal(data []byte, v any) error

Types

type Codec2

type Codec2 interface {
	CodecID() byte // 标识当前是哪个Codec
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

Codec2 新的Codec

type JsonCodec

type JsonCodec struct {
}

func NewJsonCodec

func NewJsonCodec() *JsonCodec

func (*JsonCodec) CodecID

func (jc *JsonCodec) CodecID() byte

func (*JsonCodec) Marshal

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

func (*JsonCodec) Unmarshal

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

Jump to

Keyboard shortcuts

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