encoding

package
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCodec

func RegisterCodec(codec Codec)

RegisterCodec registers the provided Codec for use with all Transport clients and servers.

Types

type Codec

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

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(contentSubtype string) Codec

GetCodec returns a registered Codec by content-subtype, or nil if no Codec is registered for the content-subtype.

The content-subtype is expected to be lowercase.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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