decoder

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

编码器

介绍

  • 2022/11/28
  • 编码器模块

帮助

  • 我们要做什么?
  • 只专注于2件事即可,编码与解码

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonDecoderBytes

func JsonDecoderBytes(bytes []byte) messages.Message

JsonDecoderBytes 工具方法

func ProtoDecoderBytes

func ProtoDecoderBytes(bytes []byte) messages.Message

ProtoDecoderBytes 工具方法

Types

type Decoder

type Decoder interface {
	//  收到客户端的数据
	Decoder(bytes []byte) messages.Message
	//  封装编码
	Encode(result any) []byte
	// Tool 工具方法
	Data(cmd, subCmd int64, body any) []byte
}

Decoder 对数据的解码器

type JsonDecoder

type JsonDecoder struct {
}

func (JsonDecoder) Data added in v0.0.42

func (d JsonDecoder) Data(cmd, subCmd int64, body interface{}) []byte

Tool 工具方法

func (JsonDecoder) Decoder added in v0.0.42

func (d JsonDecoder) Decoder(bytes []byte) messages.Message

DecoderBytes 处理客户端返回的数据

func (JsonDecoder) Encode added in v0.0.42

func (d JsonDecoder) Encode(result interface{}) []byte

EncodeBytes 编码为字节

type ProtoDecoder

type ProtoDecoder struct {
}

func (ProtoDecoder) Data added in v0.0.42

func (p ProtoDecoder) Data(cmd, subCmd int64, body any) []byte

Data 工具方法,用于简化编码,减少代码量

func (ProtoDecoder) Decoder added in v0.0.42

func (p ProtoDecoder) Decoder(bytes []byte) messages.Message

func (ProtoDecoder) Encode added in v0.0.42

func (p ProtoDecoder) Encode(result interface{}) []byte

Jump to

Keyboard shortcuts

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