encoding

package
v0.1.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterCodec deprecated

func RegisterCodec(codec Codec)

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

Deprecated: use RegisterEncoder and RegisterDecoder

func RegisterDecoder

func RegisterDecoder(decoder Decoder, contentTypes ...string)

RegisterDecoder registers the provided Decoder with specific content types for use with all Transport clients and servers.

func RegisterEncoder

func RegisterEncoder(encoder Encoder, contentTypes ...string)

RegisterEncoder registers the provided Encoder with specific content types for use with all Transport clients and servers.

Types

type Codec deprecated

type Codec interface {
	Encoder
	Decoder
	// 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
}

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.

Deprecated: use Encoder and Decoder

func GetCodec deprecated

func GetCodec(contentSubtype string) Codec

GetCodec gets 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.

Deprecated: use GetEncoders and GetDecoders

type Decoder

type Decoder interface {
	// Unmarshal parses the wire format into v.
	Unmarshal(data []byte, v interface{}) error
}

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

func GetDecoders

func GetDecoders(contentType string) []Decoder

GetDecoders gets registered Decoders by content-type, or none if no Decoder is registered for the content-type.

type Encoder

type Encoder interface {
	// Marshal returns the wire format of v.
	Marshal(v interface{}) ([]byte, error)
}

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

func GetEncoders

func GetEncoders(contentType string) []Encoder

GetEncoders gets registered Encoders by content-type, or none if no Encoder is registered for the content-type.

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