serialize

package
v0.0.0-...-e70b4cf Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EasyKeyType_SYSTEM EasyKeyType = 0
	EasyKeyType_USER   EasyKeyType = 1

	EasyValueType_INT32  EasyValueType = 0
	EasyValueType_STRING EasyValueType = 1
	EasyValueType_BYTES  EasyValueType = 2

	MAX_KEY_COUNT    = 128
	MAX_KEY_LEN      = 64
	MAX_VALUE_LEN    = 1024 * 1024
	MIN_LEN          = 20
	EC_MAGIC_NUM_LEN = 4
	EC_VERSION_LEN   = 4
	EC_RESERVED_LEN  = 8
)

Variables

This section is empty.

Functions

func EasyCodecItemToJsonStr

func EasyCodecItemToJsonStr(items []*EasyCodecItem) string

EasyCodecItemToJsonStr simple json, no nesting, rule: int32->strconv.itoa(val) []byte->string([]byte)

func EasyCodecItemToParamsMap

func EasyCodecItemToParamsMap(items []*EasyCodecItem) map[string][]byte

EasyCodecItemToParamsMap easyCodecItem converter

func EasyMarshal

func EasyMarshal(items []*EasyCodecItem) []byte

EasyMarshal serialize item into binary

Types

type EasyCodec

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

func NewEasyCodec

func NewEasyCodec() *EasyCodec

func NewEasyCodecWithBytes

func NewEasyCodecWithBytes(value []byte) *EasyCodec

func NewEasyCodecWithItems

func NewEasyCodecWithItems(items []*EasyCodecItem) *EasyCodec

func NewEasyCodecWithMap

func NewEasyCodecWithMap(value map[string][]byte) *EasyCodec

func (*EasyCodec) AddBytes

func (e *EasyCodec) AddBytes(key string, value []byte)

func (*EasyCodec) AddInt32

func (e *EasyCodec) AddInt32(key string, value int32)

func (*EasyCodec) AddItem

func (e *EasyCodec) AddItem(item *EasyCodecItem)

func (*EasyCodec) AddMap

func (e *EasyCodec) AddMap(value map[string][]byte)

func (*EasyCodec) AddString

func (e *EasyCodec) AddString(key string, value string)

func (*EasyCodec) AddValue

func (e *EasyCodec) AddValue(keyType EasyKeyType, key string, valueType EasyValueType, value interface{})

func (*EasyCodec) GetBytes

func (e *EasyCodec) GetBytes(key string) ([]byte, error)

func (*EasyCodec) GetInt32

func (e *EasyCodec) GetInt32(key string) (int32, error)

func (*EasyCodec) GetItem

func (e *EasyCodec) GetItem(key string, keyType EasyKeyType) (*EasyCodecItem, error)

func (*EasyCodec) GetItems

func (e *EasyCodec) GetItems() []*EasyCodecItem

func (*EasyCodec) GetString

func (e *EasyCodec) GetString(key string) (string, error)

func (*EasyCodec) GetValue

func (e *EasyCodec) GetValue(key string, keyType EasyKeyType) (interface{}, error)

func (*EasyCodec) Marshal

func (e *EasyCodec) Marshal() []byte

func (*EasyCodec) RemoveKey

func (e *EasyCodec) RemoveKey(key string)

func (*EasyCodec) ToJson

func (e *EasyCodec) ToJson() string

toJson simple json, no nesting, rule: int32->strconv.itoa(val) []byte->string([]byte)

func (*EasyCodec) ToMap

func (e *EasyCodec) ToMap() map[string][]byte

type EasyCodecItem

type EasyCodecItem struct {
	KeyType EasyKeyType
	Key     string

	ValueType EasyValueType
	Value     interface{}
}

func EasyUnmarshal

func EasyUnmarshal(data []byte) []*EasyCodecItem

EasyUnmarshal Deserialized from binary to item

func ParamsMapToEasyCodecItem

func ParamsMapToEasyCodecItem(params map[string][]byte) []*EasyCodecItem

ParamsMapToEasyCodecItem Params map converter

func (*EasyCodecItem) GetValue

func (e *EasyCodecItem) GetValue(key string, keyType EasyKeyType) (interface{}, bool)

GetValue get value from item

type EasyKeyType

type EasyKeyType int32

var ecHeader = []byte{99, 109, 101, 99, 118, 49, 46, 48, 255, 255, 255, 255, 255, 255, 255, 255}

type EasyValueType

type EasyValueType int32

Jump to

Keyboard shortcuts

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