codec

package
v0.0.0-...-5e9c659 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ICodec

type ICodec interface {
	Encode(interface{}) ([]byte, error)
	Decode([]byte, interface{}) error
	String() string
}

Codec defines the interface that decode/encode payload.

func IdentifyCodec

func IdentifyCodec(st SerializeType) ICodec

type SerializeType

type SerializeType byte

SerializeType defines serialization type of payload.

var Bytes SerializeType = RegisterCodec("Bytes", &byteCodec{})

Bytes only support []byte and string data type

var Gob SerializeType = RegisterCodec("Gob", newGobCodec())
var JSON SerializeType = RegisterCodec("Json", new(jsonCodec))
var MsgPack SerializeType = RegisterCodec("MsgPack", &msgpackCodec{})
var ProtoBuffer SerializeType = RegisterCodec("ProtoBuffer", &pbCodec{})

func HashName

func HashName(s string) SerializeType

func RegisterCodec

func RegisterCodec(name string, codec ICodec) SerializeType

RegisterCodec register customized codec.

func Use

func Use(name string) SerializeType

提供编码类型

func (SerializeType) String

func (self SerializeType) String() string

Jump to

Keyboard shortcuts

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