nson

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 9 Imported by: 32

Documentation

Index

Constants

View Source
const (
	MAX_NSON_SIZE = 64 * 1024 * 1024 // 64 MB
	MIN_NSON_SIZE = 4 + 1
)
View Source
const (
	TAG_F32       uint8 = 0x01
	TAG_F64       uint8 = 0x02
	TAG_I32       uint8 = 0x03
	TAG_I64       uint8 = 0x04
	TAG_U32       uint8 = 0x05
	TAG_U64       uint8 = 0x06
	TAG_STRING    uint8 = 0x07
	TAG_ARRAY     uint8 = 0x08
	TAG_MAP       uint8 = 0x09
	TAG_BOOL      uint8 = 0x0A
	TAG_NULL      uint8 = 0x0B
	TAG_BINARY    uint8 = 0x0C
	TAG_TIMESTAMP uint8 = 0x0D
	TAG_ID        uint8 = 0x0E

	// Deprecated: use TAG_MAP
	TAG_MESSAGE uint8 = TAG_MAP
	// Deprecated: use TAG_ID
	TAG_MESSAGE_ID uint8 = TAG_ID
)

Variables

This section is empty.

Functions

func EncodeValue added in v0.6.0

func EncodeValue(buf *bytes.Buffer, value Value) error

func Uint64To4Bytes added in v0.2.0

func Uint64To4Bytes(i uint64) []byte

uint64 to 8 bytes

Types

type Array

type Array []Value

func (Array) Decode

func (self Array) Decode(buf *bytes.Buffer) (Value, error)

func (Array) Encode

func (self Array) Encode(buff *bytes.Buffer) error

func (Array) IntoValue added in v0.2.0

func (self Array) IntoValue() Value

func (*Array) Push added in v0.2.0

func (self *Array) Push(value Value)

func (Array) String

func (self Array) String() string

func (Array) Tag

func (self Array) Tag() uint8

Array

type Binary

type Binary []byte

func (Binary) Decode

func (self Binary) Decode(buf *bytes.Buffer) (Value, error)

func (Binary) Encode

func (self Binary) Encode(buf *bytes.Buffer) error

func (Binary) String

func (self Binary) String() string

func (Binary) Tag

func (self Binary) Tag() uint8

type Bool

type Bool bool

func (Bool) Decode

func (self Bool) Decode(buf *bytes.Buffer) (Value, error)

func (Bool) Encode

func (self Bool) Encode(buf *bytes.Buffer) error

func (Bool) String

func (self Bool) String() string

func (Bool) Tag

func (self Bool) Tag() uint8

type F32

type F32 float32

func (F32) Decode

func (self F32) Decode(buf *bytes.Buffer) (Value, error)

func (F32) Encode

func (self F32) Encode(buf *bytes.Buffer) error

func (F32) String

func (self F32) String() string

func (F32) Tag

func (self F32) Tag() uint8

Float 32

type F64

type F64 float64

func (F64) Decode

func (self F64) Decode(buf *bytes.Buffer) (Value, error)

func (F64) Encode

func (self F64) Encode(buf *bytes.Buffer) error

func (F64) String

func (self F64) String() string

func (F64) Tag

func (self F64) Tag() uint8

Float 64

type I32

type I32 int32

func (I32) Decode

func (self I32) Decode(buf *bytes.Buffer) (Value, error)

func (I32) Encode

func (self I32) Encode(buf *bytes.Buffer) error

func (I32) String

func (self I32) String() string

func (I32) Tag

func (self I32) Tag() uint8

Int 32

type I64

type I64 int64

func (I64) Decode

func (self I64) Decode(buf *bytes.Buffer) (Value, error)

func (I64) Encode

func (self I64) Encode(buf *bytes.Buffer) error

func (I64) String

func (self I64) String() string

func (I64) Tag

func (self I64) Tag() uint8

Int 64

type Id added in v0.7.0

type Id []byte

func IdFromHex added in v0.7.0

func IdFromHex(s string) (Id, error)

func NewId added in v0.7.0

func NewId() Id

Create unique incrementing Id.

+---+---+---+---+---+---+---+---+---+---+---+---+
|       timestamp       | count |    random     |
+---+---+---+---+---+---+---+---+---+---+---+---+
  0   1   2   3   4   5   6   7   8   9   10  11

func (Id) Decode added in v0.7.0

func (self Id) Decode(buf *bytes.Buffer) (Value, error)

func (Id) Encode added in v0.7.0

func (self Id) Encode(buf *bytes.Buffer) error

func (Id) Hex added in v0.7.0

func (self Id) Hex() string

func (Id) String added in v0.7.0

func (self Id) String() string

func (Id) Tag added in v0.7.0

func (self Id) Tag() uint8

func (Id) Time added in v0.7.0

func (self Id) Time() time.Time

func (Id) Timestamp added in v0.7.0

func (self Id) Timestamp() int64

type Map added in v0.7.0

type Map map[string]Value

func (*Map) Contains added in v0.7.0

func (self *Map) Contains(key string) bool

func (Map) Decode added in v0.7.0

func (self Map) Decode(buf *bytes.Buffer) (Value, error)

func (Map) Encode added in v0.7.0

func (self Map) Encode(buff *bytes.Buffer) error

func (*Map) Extend added in v0.7.0

func (self *Map) Extend(other Map)

func (*Map) Get added in v0.7.0

func (self *Map) Get(key string) (Value, bool)

func (*Map) GetArray added in v0.7.0

func (self *Map) GetArray(key string) (Array, error)

func (*Map) GetBinary added in v0.7.0

func (self *Map) GetBinary(key string) ([]byte, error)

func (*Map) GetBool added in v0.7.0

func (self *Map) GetBool(key string) (bool, error)

func (*Map) GetF32 added in v0.7.0

func (self *Map) GetF32(key string) (float32, error)

func (*Map) GetF64 added in v0.7.0

func (self *Map) GetF64(key string) (float64, error)

func (*Map) GetI32 added in v0.7.0

func (self *Map) GetI32(key string) (int32, error)

func (*Map) GetI64 added in v0.7.0

func (self *Map) GetI64(key string) (int64, error)

func (*Map) GetMap added in v0.7.0

func (self *Map) GetMap(key string) (Map, error)

func (*Map) GetMapId added in v0.7.0

func (self *Map) GetMapId(key string) (Id, error)

func (*Map) GetString added in v0.7.0

func (self *Map) GetString(key string) (string, error)

func (*Map) GetTimestamp added in v0.7.0

func (self *Map) GetTimestamp(key string) (int64, error)

func (*Map) GetU32 added in v0.7.0

func (self *Map) GetU32(key string) (uint32, error)

func (*Map) GetU64 added in v0.7.0

func (self *Map) GetU64(key string) (uint64, error)

func (*Map) Insert added in v0.7.0

func (self *Map) Insert(key string, value Value)

func (*Map) IsNull added in v0.7.0

func (self *Map) IsNull(key string) bool

func (*Map) Len added in v0.7.0

func (self *Map) Len() int

func (*Map) Remove added in v0.7.0

func (self *Map) Remove(key string) bool

func (Map) String added in v0.7.0

func (self Map) String() string

func (Map) Tag added in v0.7.0

func (self Map) Tag() uint8

Message

type Message deprecated

type Message = Map

Deprecated: use Map

type MessageId deprecated

type MessageId = Id

Deprecated: use Id

type Null

type Null struct{}

func (Null) Decode

func (self Null) Decode(buf *bytes.Buffer) (Value, error)

func (Null) Encode

func (self Null) Encode(buf *bytes.Buffer) error

func (Null) String

func (self Null) String() string

func (Null) Tag

func (self Null) Tag() uint8

type String

type String string

func (String) Decode

func (self String) Decode(buf *bytes.Buffer) (Value, error)

func (String) Encode

func (self String) Encode(buf *bytes.Buffer) error

func (String) String

func (self String) String() string

func (String) Tag

func (self String) Tag() uint8

String

type Timestamp

type Timestamp uint64

func (Timestamp) Decode

func (self Timestamp) Decode(buf *bytes.Buffer) (Value, error)

func (Timestamp) Encode

func (self Timestamp) Encode(buf *bytes.Buffer) error

func (Timestamp) String

func (self Timestamp) String() string

func (Timestamp) Tag

func (self Timestamp) Tag() uint8

Timestamp

type U32

type U32 uint32

func (U32) Decode

func (self U32) Decode(buf *bytes.Buffer) (Value, error)

func (U32) Encode

func (self U32) Encode(buf *bytes.Buffer) error

func (U32) String

func (self U32) String() string

func (U32) Tag

func (self U32) Tag() uint8

Uint 32

type U64

type U64 uint64

func (U64) Decode

func (self U64) Decode(buf *bytes.Buffer) (Value, error)

func (U64) Encode

func (self U64) Encode(buf *bytes.Buffer) error

func (U64) String

func (self U64) String() string

func (U64) Tag

func (self U64) Tag() uint8

Uint 64

type Value

type Value interface {
	Tag() uint8
	String() string
	Encode(*bytes.Buffer) error
	Decode(*bytes.Buffer) (Value, error)
}

func DecodeValue added in v0.5.0

func DecodeValue(buf *bytes.Buffer) (Value, error)

Jump to

Keyboard shortcuts

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