codecs

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSONCodecName = "application/json"
	// check https://tools.ietf.org/html/draft-rfernando-protocol-buffers-00 for more information.
	// but it still a draft, so this constant can be renamed in any future release:
	// when some mime type for protobuf will be accepted as a standard.
	ProtoCodecName  = "application/protobuf"
	ProtoCodecName1 = "application/x-protobuf"        // will be linked to ProtoCodecName in future release.
	ProtoCodecName2 = "application/x-google-protobuf" // will be linked to ProtoCodecName in future release.
	XMLCodecName    = "application/xml"
)

Variables

View Source
var NotProtoMessage = errors.New("not proto message")
View Source
var Register = register{/* contains filtered or unexported fields */}

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encoder
	Decoder
}

Codec is an interface that encodes message on pub and decodes it on sub.

type Decoder

type Decoder interface {
	Decode([]byte, interface{}) error
}

type Encoder

type Encoder interface {
	Encode(interface{}) ([]byte, error)
}

type JSONCodec

type JSONCodec struct{}

func (*JSONCodec) Decode

func (c *JSONCodec) Decode(data []byte, v interface{}) error

func (*JSONCodec) Encode

func (c *JSONCodec) Encode(v interface{}) ([]byte, error)

type ProtobufCodec

type ProtobufCodec struct{}

func (*ProtobufCodec) Decode

func (c *ProtobufCodec) Decode(data []byte, v interface{}) error

func (*ProtobufCodec) Encode

func (c *ProtobufCodec) Encode(v interface{}) ([]byte, error)

type XMLCodec

type XMLCodec struct{}

func (*XMLCodec) Decode

func (c *XMLCodec) Decode(data []byte, v interface{}) error

func (*XMLCodec) Encode

func (c *XMLCodec) Encode(v interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

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