codec

package
v0.0.0-...-6600a07 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2014 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Initiate a codec.
	Initial() error

	// Register a message type.
	RegisterMessage(msg interface{}) error

	// Marshal a message into bytes.
	Marshal(msg interface{}) ([]byte, error)

	// Unmarshal a message from bytes.
	Unmarshal(data []byte) (interface{}, error)

	// Destroy a codec, release the resource.
	Destroy() error
}

Codec defines the interface that a codec should implement. A codec should be able to marshal/unmarshal messages from the given bytes.

type GoGoProtobufCodec

type GoGoProtobufCodec struct {
	// contains filtered or unexported fields
}

GoGoProtobufCodec implements the codec interface for Codec. We use reflect to make it a 'self-explained' codec.

func NewGoGoProtobufCodec

func NewGoGoProtobufCodec() *GoGoProtobufCodec

NewGoGoProtobufCodec creates a new gogpprotobuf codec.

func (*GoGoProtobufCodec) Destroy

func (c *GoGoProtobufCodec) Destroy() error

Destroy the gogoprotobuf codec (no-op for now).

func (*GoGoProtobufCodec) Initial

func (c *GoGoProtobufCodec) Initial() error

Initial the gogoprotobuf codec (no-op for now).

func (*GoGoProtobufCodec) Marshal

func (c *GoGoProtobufCodec) Marshal(msg interface{}) ([]byte, error)

Marshal a message into a byte slice. The msg must be a pointer type.

func (*GoGoProtobufCodec) RegisterMessage

func (c *GoGoProtobufCodec) RegisterMessage(msg interface{}) error

RegisterMessage regists a message type.

func (*GoGoProtobufCodec) Unmarshal

func (c *GoGoProtobufCodec) Unmarshal(data []byte) (interface{}, error)

Unmarshal a message from a byte slice.

Directories

Path Synopsis
Package protobuf is a generated protocol buffer package.
Package protobuf is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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