serializer

package
v0.0.0-...-7ef7dd6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Codec = NewSerializer()

Codec is an instance of Serializer.

Functions

This section is empty.

Types

type ContentType

type ContentType string

ContentType is a defined type.

const (
	// ContentTypeJSON is a json ContentType.
	ContentTypeJSON ContentType = "application/json"
)

func (ContentType) String

func (c ContentType) String() string

String return ContentType as string type.

type Object

type Object interface{}

Object is an interface to define object.

type Serialization

type Serialization struct {
}

Serialization is the default implement of interface Serializer.

func (*Serialization) Decode

func (s *Serialization) Decode(data []byte, obj Object) error

Decode is used to decode obj from date.

func (*Serialization) DecodeFromStream

func (s *Serialization) DecodeFromStream(r io.Reader, obj Object) error

DecodeFromStream is used to decode obj from stream.

func (*Serialization) Encode

func (s *Serialization) Encode(obj Object) ([]byte, error)

Encode is used to encode obj.

func (*Serialization) EncodeToStream

func (s *Serialization) EncodeToStream(w io.Writer, obj Object) error

EncodeToStream is used to encode obj to stream.

type Serializer

type Serializer interface {
	Encode(obj Object) ([]byte, error)
	Decode(data []byte, obj Object) error
	EncodeToStream(w io.Writer, obj Object) error
	DecodeFromStream(r io.Reader, obj Object) error
}

Serializer is an interface generalizes object serialize operation.

func NewSerializer

func NewSerializer() Serializer

NewSerializer returns Serializer instance.

Jump to

Keyboard shortcuts

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