codec

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteDecode

func ByteDecode(bs []byte, obj interface{}, config ByteCodecConfig) error

func ByteEncode

func ByteEncode(m interface{}, config ByteCodecConfig) ([]byte, error)

func Bytes2IntFunc

func Bytes2IntFunc(bs []byte, config ByteCodecItemConfig) (int64, error)

func GetDecodeFunc

func GetDecodeFunc(str string) func(bs []byte, config ByteCodecItemConfig) (int64, error)

func GetEncodeFunc

func GetEncodeFunc(str string) func(v interface{}, config ByteCodecItemConfig) ([]byte, error)

func Int2BytesFunc

func Int2BytesFunc(v interface{}, config ByteCodecItemConfig) ([]byte, error)

Types

type ByteCodecConfig

type ByteCodecConfig struct {
	Key        string                `json:"key"`        // 转换标识
	Total      uint                  `json:"total"`      //总长度 字节的长度
	StructName string                `json:"structName"` // 结构体的全路径
	DspVersion string                `json:"dspVersion"` // 下位机的版本
	Items      []ByteCodecItemConfig `json:"items"`      //每项的设置
}

type ByteCodecItemConfig

type ByteCodecItemConfig struct {
	Name       string `json:"name"`       // 字段名   TODO:如果有层级,以逗号分隔
	Index      uint   `json:"index"`      // 初始位置(从0开始)
	Size       uint   `json:"size"`       // 长度 字节数 就是几个字节
	EncodeFunc string `json:"encodeFunc"` // 编码的方法名
	DecodeFunc string `json:"decodeFunc"` // 解码的方法名
	Desc       string `json:"desc"`       //解释
}

Jump to

Keyboard shortcuts

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