gocodec

package module
v0.0.0-...-36ed743 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: Apache-2.0 Imports: 8 Imported by: 2

README

gocodec

inplace decoding go language value, read data off memory mapped file without copying or allocation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{}.Froze()
View Source
var ReadonlyConfig = Config{ReadonlyDecode: true}.Froze()

Functions

func Marshal

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

func Unmarshal

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

func UnmarshalCandidates

func UnmarshalCandidates(buf []byte, candidatePointers ...interface{}) (interface{}, error)

Types

type API

type API interface {
	Marshal(val interface{}) ([]byte, error)
	Unmarshal(buf []byte, candidatePointer interface{}) (interface{}, error)
	UnmarshalCandidates(buf []byte, candidatePointers ...interface{}) (interface{}, error)
	NewIterator(buf []byte) *Iterator
	NewStream(buf []byte) *Stream
}

type Allocator

type Allocator interface {
	Allocate(ObjectSeq, []byte) []byte
}

type BaseCodec

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

func (*BaseCodec) Decode

func (codec *BaseCodec) Decode(iter *Iterator)

func (*BaseCodec) Encode

func (codec *BaseCodec) Encode(stream *Stream)

func (*BaseCodec) HasPointer

func (codec *BaseCodec) HasPointer() bool

func (*BaseCodec) IsNoop

func (codec *BaseCodec) IsNoop() bool

func (*BaseCodec) Signature

func (codec *BaseCodec) Signature() uint32

func (*BaseCodec) Type

func (codec *BaseCodec) Type() reflect.Type

type Config

type Config struct {
	ReadonlyDecode bool
}

func (Config) Froze

func (cfg Config) Froze() API

type DefaultAllocator

type DefaultAllocator struct {
}

func (*DefaultAllocator) Allocate

func (allocator *DefaultAllocator) Allocate(objectSeq ObjectSeq, original []byte) []byte

type Iterator

type Iterator struct {
	Error error
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator(buf []byte) *Iterator

func (*Iterator) Allocator

func (iter *Iterator) Allocator(allocator Allocator)

func (*Iterator) Buffer

func (iter *Iterator) Buffer() []byte

func (*Iterator) CopyThenUnmarshal

func (iter *Iterator) CopyThenUnmarshal(candidatePointer interface{}) interface{}

func (*Iterator) CopyThenUnmarshalCandidates

func (iter *Iterator) CopyThenUnmarshalCandidates(candidatePointers ...interface{}) interface{}

func (*Iterator) NextSize

func (iter *Iterator) NextSize() uint32

func (*Iterator) ObjectSeq

func (iter *Iterator) ObjectSeq(objectSeq ObjectSeq)

func (*Iterator) ReportError

func (iter *Iterator) ReportError(operation string, err error)

func (*Iterator) Reset

func (iter *Iterator) Reset(buf []byte)

func (*Iterator) Skip

func (iter *Iterator) Skip() []byte

func (*Iterator) Unmarshal

func (iter *Iterator) Unmarshal(candidatePointer interface{}) interface{}

func (*Iterator) UnmarshalCandidates

func (iter *Iterator) UnmarshalCandidates(candidatePointers ...interface{}) interface{}

type NoopCodec

type NoopCodec struct {
	BaseCodec
}

func (*NoopCodec) Decode

func (codec *NoopCodec) Decode(iter *Iterator)

func (*NoopCodec) Encode

func (codec *NoopCodec) Encode(ptr unsafe.Pointer, stream *Stream)

func (*NoopCodec) IsNoop

func (codec *NoopCodec) IsNoop() bool

type ObjectSeq

type ObjectSeq uint64

type RootDecoder

type RootDecoder interface {
	Type() reflect.Type
	Signature() uint32
	DecodeEmptyInterface(ptr *emptyInterface, iter *Iterator)
}

type RootEncoder

type RootEncoder interface {
	Type() reflect.Type
	Signature() uint32
	EncodeEmptyInterface(ptr unsafe.Pointer, stream *Stream)
}

type Stream

type Stream struct {
	Error error
	// contains filtered or unexported fields
}

func NewStream

func NewStream(buf []byte) *Stream

func (*Stream) Buffer

func (stream *Stream) Buffer() []byte

func (*Stream) Marshal

func (stream *Stream) Marshal(val interface{}) uint32

func (*Stream) ReportError

func (stream *Stream) ReportError(operation string, err error)

func (*Stream) Reset

func (stream *Stream) Reset(buf []byte)

type ValDecoder

type ValDecoder interface {
	Decode(iter *Iterator)
	Type() reflect.Type
	IsNoop() bool
	Signature() uint32
	HasPointer() bool
}

type ValEncoder

type ValEncoder interface {
	Encode(ptr unsafe.Pointer, stream *Stream)
	Type() reflect.Type
	IsNoop() bool
	Signature() uint32
}

Jump to

Keyboard shortcuts

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