Package serializer

import "github.com/byte-mug/golibs/serializer"

Overview

Index

func Cast

func Cast(t reflect.Type, i interface{}) (v reflect.Value)

-

func CastV

func CastV(t reflect.Type, v reflect.Value) reflect.Value

-

func Deserialize

func Deserialize(ce CodecElement, r preciseio.PreciseReader) (interface{}, error)

-

func GetInterface

func GetInterface(v reflect.Value) interface{}

-

func Serialize

func Serialize(ce CodecElement, w *preciseio.PreciseWriter, i interface{}) error

-

type CodecElement

type CodecElement interface {
	Read(r preciseio.PreciseReader, v reflect.Value) error
	Write(w *preciseio.PreciseWriter, v reflect.Value) error
}

-

func AddPtr

func AddPtr(i interface{}) CodecElement

-

func AddPtrWith

func AddPtrWith(i interface{}, ce CodecElement) CodecElement

-

func ForContainerWith

func ForContainerWith(i interface{}, ce CodecElement) CodecElement

Obtains the serializer for reflect.TypeOf(i) and ce as the serializer for the contained elements.

func ForContainerWithDepth

func ForContainerWithDepth(i interface{}, depth int, ce CodecElement) CodecElement

Obtains the serializer for reflect.TypeOf(i) and ce as the serializer for the contained elements (after depth).

For example:

ForContainerWithDepth([][]*Bar{},2,fooBar)

is equivalent to:

ForContainerWith([][]*Bar{},ForContainerWith([]*Bar{},fooBar)))

func ForContainerWithDepthP

func ForContainerWithDepthP(i interface{}, depth int, ce CodecElement) CodecElement

Obtains the serializer for reflect.TypeOf(i).Elem() and ce as the serializer for the contained elements (after depth).

For example:

ForContainerWithDepthP(new([2][2]*Bar),2,fooBar)

is equivalent to:

ForContainerWithP(new([2][2]*Bar),ForContainerWithP(new([2]*Bar),fooBar))

func ForContainerWithP

func ForContainerWithP(i interface{}, ce CodecElement) CodecElement

Obtains the serializer for reflect.TypeOf(i).Elem() and ce as the serializer for the contained elements.

func ForType

func ForType(i interface{}) CodecElement

Obtains the serializer for reflect.TypeOf(i)

func ForTypeP

func ForTypeP(i interface{}) CodecElement

Obtains the serializer for reflect.TypeOf(i).Elem()

func StripawayPtr

func StripawayPtr(i interface{}) CodecElement

-

func StripawayPtrWith

func StripawayPtrWith(i interface{}, ce CodecElement) CodecElement

-

type StructBuilder

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

-

func With

func With(i interface{}) *StructBuilder

-

func WithInline

func WithInline(i interface{}) *StructBuilder

-

func (*StructBuilder) Field

func (s *StructBuilder) Field(name string) *StructBuilder

-

func (*StructBuilder) FieldContainerWith

func (s *StructBuilder) FieldContainerWith(name string, ce CodecElement) *StructBuilder

-

func (*StructBuilder) FieldContainerWithDepth

func (s *StructBuilder) FieldContainerWithDepth(name string, depth int, ce CodecElement) *StructBuilder

-

func (*StructBuilder) FieldWith

func (s *StructBuilder) FieldWith(name string, ce CodecElement) *StructBuilder

-

func (*StructBuilder) Read

func (s *StructBuilder) Read(r preciseio.PreciseReader, v reflect.Value) error

-

func (*StructBuilder) Write

func (s *StructBuilder) Write(w *preciseio.PreciseWriter, v reflect.Value) error

-

type TypeSwitch

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

Creates a type-mapping for up to 255 different types. The type is indicated by the first byte.

func Switch

func Switch(def byte) *TypeSwitch

Starts a new type switching. A default key must be specified.

func (*TypeSwitch) AddType

func (t *TypeSwitch) AddType(b byte, i interface{}) *TypeSwitch

-

func (*TypeSwitch) AddTypeContainerWith

func (t *TypeSwitch) AddTypeContainerWith(b byte, i interface{}, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) AddTypeContainerWithDepth

func (t *TypeSwitch) AddTypeContainerWithDepth(b byte, i interface{}, depth int, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) AddTypeContainerWithDepthP

func (t *TypeSwitch) AddTypeContainerWithDepthP(b byte, i interface{}, depth int, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) AddTypeContainerWithP

func (t *TypeSwitch) AddTypeContainerWithP(b byte, i interface{}, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) AddTypeP

func (t *TypeSwitch) AddTypeP(b byte, i interface{}) *TypeSwitch

-

func (*TypeSwitch) AddTypeWith

func (t *TypeSwitch) AddTypeWith(b byte, i interface{}, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) AddTypeWithP

func (t *TypeSwitch) AddTypeWithP(b byte, i interface{}, ce CodecElement) *TypeSwitch

-

func (*TypeSwitch) Read

func (t *TypeSwitch) Read(r preciseio.PreciseReader, v reflect.Value) error

-

func (*TypeSwitch) Write

func (t *TypeSwitch) Write(w *preciseio.PreciseWriter, v reflect.Value) error

-

Dependencies