codec

package
v0.0.0-...-74ea078 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Name() string
	Marshal(val any) ([]byte, error)
	Unmarshal(data []byte, val any) error
}

Codec 是消息编码/解码接口。 注:

Codec 用于将 websocket 连接收发的消息进行编码/解码。
即前端 ( 业务客户端 ) 和网关之间收发的消息进行编码/解码。

type JSONCodec

type JSONCodec struct{}

func NewJSONCodec

func NewJSONCodec() *JSONCodec

func (*JSONCodec) Marshal

func (c *JSONCodec) Marshal(val any) ([]byte, error)

func (*JSONCodec) Name

func (c *JSONCodec) Name() string

func (*JSONCodec) Unmarshal

func (c *JSONCodec) Unmarshal(data []byte, val any) error

type ProtoCodec

type ProtoCodec struct{}

func NewProtoCodec

func NewProtoCodec() *ProtoCodec

func (*ProtoCodec) Marshal

func (c *ProtoCodec) Marshal(val any) ([]byte, error)

func (*ProtoCodec) Name

func (c *ProtoCodec) Name() string

func (*ProtoCodec) Unmarshal

func (c *ProtoCodec) Unmarshal(data []byte, val any) error

Jump to

Keyboard shortcuts

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