codec

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	EncodeTypeHmSET        = 1
	EncodeTypeRedisArg     = 2
	EncodeTypeInsertData   = 3
	EncodeTypeInsertDatas  = 4
	EncodeTypeReplaceData  = 5
	EncodeTypeReplaceDatas = 6
	EncodeTypeUpdateData   = 7
)

Variables

View Source
var (
	DefaultTag   = "orm"
	DefaultCodec = NewDefaultCodec(jsonMarshal, jsonUnmarshal, DefaultTag, true, true, true)
)
View Source
var DefaultMap2Structure = &Map2Structure{DefaultTag, true, true}

Functions

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader returns reader with the default buffer size.

func SetDefaultTag

func SetDefaultTag(tag string)

SetDefaultTag change the default tag

Types

type Codec

type Codec interface {
	SetMarshal(m Marshal, um Unmarshal) // marshal/unmarshal for single item
	GetMarshal() Marshal                // get marshal
	GetUnmarshal() Unmarshal            // get unmarshal

	SetTag(tag string) // set tag
	GetTag() string    // get tag

	Encode(typ int, v interface{}) (interface{}, error)        // encode
	Decode(typ int, src interface{}, dest []interface{}) error // decode
}

func NewDefaultCodec

func NewDefaultCodec(m Marshal, um Unmarshal, tag string, omitEmpty, weaklyType, squash bool) Codec

type Framer

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

Framer frame reader

func NewFramer

func NewFramer(reader io.Reader) *Framer

NewFramer create framer

func (*Framer) ReadFrame

func (f *Framer) ReadFrame() (respBuf []byte, err error)

ReadFrame read response buffer from frame

type Map2Structure

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

func (*Map2Structure) Decode

func (m *Map2Structure) Decode(src, dest interface{}) error

type Marshal

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

type Unmarshal

type Unmarshal func(data []byte, v interface{}) error

Jump to

Keyboard shortcuts

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