encoding

package
v0.0.0-...-242f3d8 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCodec

func RegisterCodec(codec Codec)

RegisterCodec registers new Codec processor.

Types

type Codec

type Codec interface {
	// Marshal returns the special codec format of v.
	Marshal(v interface{}) ([]byte, error)

	// Unmarshal parses the special codec format into v.
	Unmarshal(data []byte, v interface{}) error

	// Name return the codec's name.
	Name() CodecType
}

Codec defines the interface that nginet uses to encode and decode messages. a Codec's methods can be called from concurrent goroutines.

func GetCodec

func GetCodec(name CodecType) Codec

GetCodec return registered codec by name. Note: if codec with name 'name' not registered, a nil codec will returned.

func MustGetCodec

func MustGetCodec(name CodecType) Codec

MustGetCodec the same with GetCodec. but it will panic when the codec of name 'name' not registred.

type CodecType

type CodecType string

A CodecType is a string codec type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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