encode

package
v0.0.0-...-c340371 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Package encode is Encoder and Decoder for pkg

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(header *pkg.Header, content interface{}) ([]byte, error)

Marshal encode header and content into binary data

func Regist

func Regist(e pkg.EncodingType, ed EncodeDecoder)

Regist new EncodeDecoder

Types

type Base

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

func (*Base) Marshal

func (b *Base) Marshal(obj interface{}) ([]byte, error)

func (*Base) Unmarshal

func (b *Base) Unmarshal(data []byte, content interface{}) error

type Bson

type Bson struct {
}

func (Bson) Marshal

func (self Bson) Marshal(obj interface{}) ([]byte, error)

func (Bson) Unmarshal

func (self Bson) Unmarshal(data []byte, content interface{}) error

type Decoder

type Decoder interface {
	Unmarshal(data []byte, content interface{}) error
}

type EncodeDecoder

type EncodeDecoder interface {
	Encoder
	Decoder
}

func GetEncodeDecoder

func GetEncodeDecoder(encoding pkg.EncodingType) EncodeDecoder

GetEncodeDecoder gets EncodeDecoder by pkg.EncodingType

func GetMd5EncodeDecoder

func GetMd5EncodeDecoder() EncodeDecoder

func NewBson

func NewBson() EncodeDecoder

func NewGob

func NewGob() EncodeDecoder

func NewJson

func NewJson() EncodeDecoder

func NewProtobuf

func NewProtobuf() EncodeDecoder

type Encoder

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

type Gob

type Gob struct {
}

func (Gob) Marshal

func (self Gob) Marshal(obj interface{}) ([]byte, error)

func (Gob) Unmarshal

func (self Gob) Unmarshal(data []byte, content interface{}) error

type Json

type Json struct {
}

Json encoder/decoder

func (Json) Marshal

func (self Json) Marshal(obj interface{}) ([]byte, error)

func (Json) Unmarshal

func (self Json) Unmarshal(data []byte, content interface{}) error

type Protobuf

type Protobuf struct {
}

Protobuf encoder/decoder

func (Protobuf) Marshal

func (self Protobuf) Marshal(obj interface{}) ([]byte, error)

func (Protobuf) Unmarshal

func (self Protobuf) Unmarshal(data []byte, content interface{}) error

Jump to

Keyboard shortcuts

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