codec

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCodec

func RegisterCodec(c Codec)

RegisterCodec 该调用是线程安全的

Types

type Codec

type Codec interface {
	Scheme() string
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

type JsonCodec

type JsonCodec struct{}

func (JsonCodec) Marshal

func (j JsonCodec) Marshal(v interface{}) ([]byte, error)

func (JsonCodec) Scheme

func (j JsonCodec) Scheme() string

func (JsonCodec) Unmarshal

func (j JsonCodec) Unmarshal(data []byte, v interface{}) error

type Wrapper

type Wrapper interface {
	Scheme() string
	Index() int
	Instance() Codec
}

Wrapper Codec的包装器 主要提供给client&server标注其Codec在一个抽象的表中的位置

func GetCodecFromIndex

func GetCodecFromIndex(index int) Wrapper

GetCodecFromIndex 该调用是线程安全的,且可以安全的使用任何数值来作为索引

func GetCodecFromScheme

func GetCodecFromScheme(scheme string) Wrapper

GetCodecFromScheme 该调用是线程安全的

Jump to

Keyboard shortcuts

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