codec

package
v0.5.1-0...-236ff9b Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NilCodecId byte = 0
)

Variables

View Source
var (
	ErrInvalidLengthempty = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowempty   = fmt.Errorf("proto: integer overflow")
)
View Source
var Empty = new(empty)

Functions

func ProtoMarshal

func ProtoMarshal(v interface{}) ([]byte, error)

func ProtoUnmarshal

func ProtoUnmarshal(b []byte, v interface{}) error

func Reg

func Reg(codec Codec)

Reg registers Codec

Types

type Codec

type Codec interface {
	// Id returns codec id.
	Id() byte
	// Name returns codec name.
	Name() string
	// NewEncoder returns a new encoder that writes to writer.
	NewEncoder(writer io.Writer) Encoder
	// NewDecoder returns a new decoder that reads from limit reader.
	NewDecoder(limitReader io.Reader) Decoder
}

Codec makes Encoder and Decoder

func GetById

func GetById(id byte) (Codec, error)

GetById returns Codec

func GetByName

func GetByName(name string) (Codec, error)

GetByName returns Codec

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

Decoder decodes data

func NewDecoderById

func NewDecoderById(id byte, limitReader io.Reader) (Decoder, error)

NewDecoderById returns a new decoder that reads from limit reader.

func NewDecoderByName

func NewDecoderByName(name string, limitReader io.Reader) (Decoder, error)

NewDecoderByName returns a new decoder that reads from limit reader.

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder encodes data

func NewEncoderById

func NewEncoderById(id byte, writer io.Writer) (Encoder, error)

NewEncoderById returns a new encoder that writes to writer.

func NewEncoderByName

func NewEncoderByName(name string, writer io.Writer) (Encoder, error)

NewEncoderByName returns a new encoder that writes to writer.

type JsonCodec

type JsonCodec struct{}

JsonCodec json codec

func (*JsonCodec) Id

func (j *JsonCodec) Id() byte

Id returns codec id

func (*JsonCodec) Name

func (j *JsonCodec) Name() string

Name returns codec name

func (*JsonCodec) NewDecoder

func (*JsonCodec) NewDecoder(limitReader io.Reader) Decoder

NewDecoder returns a new json decoder that reads from limit reader.

func (*JsonCodec) NewEncoder

func (*JsonCodec) NewEncoder(writer io.Writer) Encoder

NewEncoder returns a new json encoder that writes to writer.

type JsonDecoder

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

JsonDecoder json decoder

func (*JsonDecoder) Decode

func (p *JsonDecoder) Decode(v interface{}) error

Decode reads the next json-encoded value from its input and stores it in the value pointed to by v.

type JsonEncoder

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

JsonEncoder json decoder

func (*JsonEncoder) Encode

func (p *JsonEncoder) Encode(v interface{}) error

Encode writes the json encoding of v to the writer.

type JsoniterCodec

type JsoniterCodec struct{}

JsoniterCodec json codec

func (*JsoniterCodec) Id

func (j *JsoniterCodec) Id() byte

Id returns codec id

func (*JsoniterCodec) Name

func (j *JsoniterCodec) Name() string

Name returns codec name

func (*JsoniterCodec) NewDecoder

func (*JsoniterCodec) NewDecoder(limitReader io.Reader) Decoder

NewDecoder returns a new json decoder that reads from limit reader.

func (*JsoniterCodec) NewEncoder

func (*JsoniterCodec) NewEncoder(writer io.Writer) Encoder

NewEncoder returns a new json encoder that writes to writer.

type JsoniterDecoder

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

JsoniterDecoder json decoder

func (*JsoniterDecoder) Decode

func (p *JsoniterDecoder) Decode(v interface{}) error

Decode reads the next json-encoded value from its input and stores it in the value pointed to by v.

type JsoniterEncoder

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

JsoniterEncoder json decoder

func (*JsoniterEncoder) Encode

func (p *JsoniterEncoder) Encode(v interface{}) error

Encode writes the json encoding of v to the writer.

type ProtoCodec

type ProtoCodec struct{}

ProtoCodec protobuf codec

func (*ProtoCodec) Id

func (p *ProtoCodec) Id() byte

Id returns codec id

func (*ProtoCodec) Name

func (p *ProtoCodec) Name() string

Name returns codec name

func (*ProtoCodec) NewDecoder

func (*ProtoCodec) NewDecoder(limitReader io.Reader) Decoder

NewDecoder returns a new protobuf decoder that reads from limit reader.

func (*ProtoCodec) NewEncoder

func (*ProtoCodec) NewEncoder(writer io.Writer) Encoder

NewEncoder returns a new protobuf encoder that writes to writer.

type ProtoDecoder

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

ProtoDecoder proto decoder

func (*ProtoDecoder) Decode

func (p *ProtoDecoder) Decode(v interface{}) error

Decode reads the next Protobuf-encoded value from its input and stores it in the value pointed to by v.

type ProtoEncoder

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

ProtoEncoder proto decoder

func (*ProtoEncoder) Encode

func (p *ProtoEncoder) Encode(v interface{}) error

Encode writes the Protobuf encoding of v to the writer.

type StringCodec

type StringCodec struct{}

StringCodec string codec

func (*StringCodec) Id

func (p *StringCodec) Id() byte

Id returns codec id

func (*StringCodec) Name

func (p *StringCodec) Name() string

Name returns codec name

func (*StringCodec) NewDecoder

func (*StringCodec) NewDecoder(limitReader io.Reader) Decoder

NewDecoder returns a new string decoder that reads from limit reader.

func (*StringCodec) NewEncoder

func (*StringCodec) NewEncoder(writer io.Writer) Encoder

NewEncoder returns a new string encoder that writes to writer.

type StringDecoder

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

StringDecoder string decoder

func (*StringDecoder) Decode

func (p *StringDecoder) Decode(v interface{}) error

Decode reads the next string-encoded value from its input and stores it in the value pointed to by v.

type StringEncoder

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

StringEncoder string decoder

func (*StringEncoder) Encode

func (p *StringEncoder) Encode(v interface{}) error

Encode writes the string encoding of v to the writer.

Jump to

Keyboard shortcuts

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