encoding

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Codecs

func Codecs() []string

Codecs returns a sorted list of the names of the registered Codec.

func Register

func Register(codec Codec)

Register registers the provided Codec. if register called twice for Codec name, it will overwrite previous Codec.

Types

type Codec

type Codec interface {
	// Name returns the name of the Codec implementation. The returned string
	// will be used as part of content type in transmission.  The result must be
	// static; the result cannot change between calls.
	Name() string
	// Marshal returns the wire format of v.
	Marshal(v any) ([]byte, error)
	// Unmarshal parses the wire format into v.
	Unmarshal(data []byte, v any) error
}

Codec defines the interface Transport uses to encode and decode messages. Note that implementations of this interface must be thread safe; a Codec's methods can be called from concurrent goroutines.

func GetCodec

func GetCodec(name string) Codec

GetCodec gets a registered Codec by name, or nil if no Codec is registered for the name.

Directories

Path Synopsis
Package proto defines the protobuf codec.
Package proto defines the protobuf codec.

Jump to

Keyboard shortcuts

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