codec

package
v0.0.0-...-d9723d1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

Jump to

Keyboard shortcuts

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