encoding

package
v0.0.0-...-8072013 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package encoding is used to encode/decode data going to/from the bolt protocol.

Index

Constants

View Source
const (
	// NilMarker represents the encoding marker byte for a nil object
	NilMarker = 0xC0

	// TrueMarker represents the encoding marker byte for a true boolean object
	TrueMarker = 0xC3
	// FalseMarker represents the encoding marker byte for a false boolean object
	FalseMarker = 0xC2

	// Int8Marker represents the encoding marker byte for a int8 object
	Int8Marker = 0xC8
	// Int16Marker represents the encoding marker byte for a int16 object
	Int16Marker = 0xC9
	// Int32Marker represents the encoding marker byte for a int32 object
	Int32Marker = 0xCA
	// Int64Marker represents the encoding marker byte for a int64 object
	Int64Marker = 0xCB

	// FloatMarker represents the encoding marker byte for a float32/64 object
	FloatMarker = 0xC1

	// TinyStringMarker represents the encoding marker byte for a string object
	TinyStringMarker = 0x80
	// String8Marker represents the encoding marker byte for a string object
	String8Marker = 0xD0
	// String16Marker represents the encoding marker byte for a string object
	String16Marker = 0xD1
	// String32Marker represents the encoding marker byte for a string object
	String32Marker = 0xD2

	// TinySliceMarker represents the encoding marker byte for a slice object
	TinySliceMarker = 0x90
	// Slice8Marker represents the encoding marker byte for a slice object
	Slice8Marker = 0xD4
	// Slice16Marker represents the encoding marker byte for a slice object
	Slice16Marker = 0xD5
	// Slice32Marker represents the encoding marker byte for a slice object
	Slice32Marker = 0xD6

	// TinyMapMarker represents the encoding marker byte for a map object
	TinyMapMarker = 0xA0
	// Map8Marker represents the encoding marker byte for a map object
	Map8Marker = 0xD8
	// Map16Marker represents the encoding marker byte for a map object
	Map16Marker = 0xD9
	// Map32Marker represents the encoding marker byte for a map object
	Map32Marker = 0xDA

	// TinyStructMarker represents the encoding marker byte for a struct object
	TinyStructMarker = 0xB0
	// Struct8Marker represents the encoding marker byte for a struct object
	Struct8Marker = 0xDC
	// Struct16Marker represents the encoding marker byte for a struct object
	Struct16Marker = 0xDD
)

Variables

View Source
var (
	// EndMessage is the data to send to end a message
	EndMessage = []byte{byte(0x00), byte(0x00)}
)

Functions

func Marshal

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

Marshal is used to marshal an object to the bolt interface encoded bytes

func Unmarshal

func Unmarshal(b []byte) (interface{}, error)

Unmarshal is used to marshal an object to the bolt interface encoded bytes

Types

type Decoder

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

Decoder decodes a message from the bolt protocol stream Attempts to support all builtin golang types, when it can be confidently mapped to a data type from: http://alpha.neohq.net/docs/server-manual/bolt-serialization.html#bolt-packstream-structures (version v3.1.0-M02 at the time of writing this.

Maps and Slices are a special case, where only map[string]interface{} and []interface{} are supported. The interface for maps and slices may be more permissive in the future.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder Creates a new Decoder object

func (Decoder) Decode

func (d Decoder) Decode() (interface{}, error)

Decode decodes the stream to an object

type Encoder

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

Encoder encodes objects of different types to the given stream. Attempts to support all builtin golang types, when it can be confidently mapped to a data type from: http://alpha.neohq.net/docs/server-manual/bolt-serialization.html#bolt-packstream-structures (version v3.1.0-M02 at the time of writing this.

Maps and Slices are a special case, where only map[string]interface{} and []interface{} are supported. The interface for maps and slices may be more permissive in the future.

func NewEncoder

func NewEncoder(w io.Writer, chunkSize uint16) Encoder

NewEncoder Creates a new Encoder object

func (Encoder) Encode

func (e Encoder) Encode(iVal interface{}) error

Encode encodes an object to the stream

func (Encoder) Write

func (e Encoder) Write(p []byte) (n int, err error)

write writes to the writer. Buffers the writes using chunkSize.

Jump to

Keyboard shortcuts

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