inspect

package module
v0.0.0-...-397cff2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2022 License: MIT Imports: 4 Imported by: 0

README

C++ Actor framework inspired serialization abstraction layer

Documentation

Index

Constants

View Source
const (
	ErrNoField inspectError = iota
	ErrReaderCantWrite
	ErrWriterCantRead
)

Variables

This section is empty.

Functions

func Array

func Array[PT InspectablePtr[T], T any](array *[]T, inspector *Inspector, name string,
	elementName string, description string)

func ArrayPtr

func ArrayPtr[T any, PT InspectablePtr[T]](array *[]PT, inspector *Inspector, name string,
	elementName string, description string)

func Map

func Map[K comparable, PK InspectablePtr[K], T any, PT InspectablePtr[T]](value *map[K]T, inspector *Inspector,
	name string, keyName string, elementName string, description string)

func MapPtr

func MapPtr[K comparable, PK InspectablePtr[K], T any, PT InspectablePtr[T]](value *map[K]PT, inspector *Inspector,
	name string, keyName string, elementName string, description string)

func StringMap

func StringMap[T Inspectable](value *map[string]T, inspector *Inspector,
	name string, elementName string, description string)

Types

type BinaryReadInspector

type BinaryReadInspector[R Reader] struct {
	ReadInspector[R]
}

func (*BinaryReadInspector[R]) PropertyValue

func (r *BinaryReadInspector[R]) PropertyValue(name string, value RawValue, mandatory bool, description string)

func (*BinaryReadInspector[R]) Value

func (r *BinaryReadInspector[R]) Value(value RawValue)

type BinaryWriteInspector

type BinaryWriteInspector[W any, PW WriterPtr[W]] struct {
	WriteInspector[W, PW]
}

func (*BinaryWriteInspector[W, PW]) PropertyValue

func (w *BinaryWriteInspector[W, PW]) PropertyValue(name string, value RawValue, mandatory bool, description string)

func (*BinaryWriteInspector[W, PW]) Value

func (w *BinaryWriteInspector[W, PW]) Value(value RawValue)

type Inspectable

type Inspectable interface {
	Inspect(*Inspector)
}

type InspectablePtr

type InspectablePtr[T any] interface {
	Inspectable
	*T
}

type Inspector

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

func NewInspector

func NewInspector(impl InspectorInterface) *Inspector

func (*Inspector) ByteString

func (i *Inspector) ByteString(value *[]byte)

func (*Inspector) Bytes

func (i *Inspector) Bytes(value *[]byte)

func (*Inspector) EndArray

func (i *Inspector) EndArray()

func (*Inspector) EndMap

func (i *Inspector) EndMap()

func (*Inspector) Float32

func (i *Inspector) Float32(value *float32, format byte, precision int)

func (*Inspector) Float64

func (i *Inspector) Float64(value *float64, format byte, precision int)

func (*Inspector) Flush

func (i *Inspector) Flush()

func (*Inspector) HaveNext

func (i *Inspector) HaveNext() bool

func (*Inspector) Int

func (i *Inspector) Int(value *int)

func (*Inspector) Int32

func (i *Inspector) Int32(value *int32)

func (*Inspector) Int64

func (i *Inspector) Int64(value *int64)

func (*Inspector) IsReading

func (i *Inspector) IsReading() bool

func (*Inspector) LastError

func (i *Inspector) LastError() error

func (*Inspector) ReadArray

func (i *Inspector) ReadArray() int

func (*Inspector) ReadMap

func (i *Inspector) ReadMap() int

func (*Inspector) ReadNextKey

func (i *Inspector) ReadNextKey() string

func (*Inspector) SetReader

func (i *Inspector) SetReader(reader io.Reader)

func (*Inspector) SetWriter

func (i *Inspector) SetWriter(writer io.Writer, bufferSize int)

func (*Inspector) StartObject

func (i *Inspector) StartObject(name string, description string) *ObjectInspector

func (*Inspector) String

func (i *Inspector) String(value *string)

func (*Inspector) Value

func (i *Inspector) Value(value RawValue)

func (*Inspector) WriteArray

func (i *Inspector) WriteArray(name string, elementName string, length int, description string)

func (*Inspector) WriteMap

func (i *Inspector) WriteMap(name string, elementName string, length int, description string)

func (*Inspector) WriteNextKey

func (i *Inspector) WriteNextKey(key string)

type InspectorInterface

type InspectorInterface interface {
	LastError() error
	SetReader(io.Reader)
	SetWriter(writer io.Writer, bufferSize int)
	Int32(value *int32)
	Int64(value *int64)
	Int(value *int)
	Float32(value *float32, format byte, precision int)
	Float64(value *float64, format byte, precision int)
	String(value *string)
	Bytes(value *[]byte)
	ByteString(value *[]byte)
	Value(value RawValue)
	StartObject(name string, description string)
	Property(name string, mandatory bool, description string) bool
	PropertyInt32(name string, value *int32, mandatory bool, description string)
	PropertyInt64(name string, value *int64, mandatory bool, description string)
	PropertyInt(name string, value *int, mandatory bool, description string)
	PropertyFloat32(name string, value *float32, format byte, precision int, mandatory bool, description string)
	PropertyFloat64(name string, value *float64, format byte, precision int, mandatory bool, description string)
	PropertyString(name string, value *string, mandatory bool, description string)
	PropertyBytes(name string, value *[]byte, mandatory bool, description string)
	PropertyByteString(name string, value *[]byte, mandatory bool, description string)
	PropertyValue(name string, value RawValue, mandatory bool, description string)
	EndObject()
	ReadArray() int
	WriteArray(name string, elementName string, length int, description string)
	HaveNext() bool
	EndArray()
	ReadMap() int
	WriteMap(name string, elementName string, length int, description string)
	ReadNextKey() string
	WriteNextKey(key string)
	EndMap()
	IsReading() bool
	Flush()
}

type ObjectInspector

type ObjectInspector Inspector

func (*ObjectInspector) ByteString

func (o *ObjectInspector) ByteString(name string, value *[]byte, mandatory bool, description string)

func (*ObjectInspector) Bytes

func (o *ObjectInspector) Bytes(name string, value *[]byte, mandatory bool, description string)

func (*ObjectInspector) End

func (o *ObjectInspector) End() *Inspector

func (*ObjectInspector) Float32

func (o *ObjectInspector) Float32(name string, value *float32, format byte, precision int, mandatory bool, description string)

func (*ObjectInspector) Float64

func (o *ObjectInspector) Float64(name string, value *float64, format byte, precision int, mandatory bool, description string)

func (*ObjectInspector) Flush

func (o *ObjectInspector) Flush()

func (*ObjectInspector) Int

func (o *ObjectInspector) Int(name string, value *int, mandatory bool, description string)

func (*ObjectInspector) Int32

func (o *ObjectInspector) Int32(name string, value *int32, mandatory bool, description string)

func (*ObjectInspector) Int64

func (o *ObjectInspector) Int64(name string, value *int64, mandatory bool, description string)

func (*ObjectInspector) IsReading

func (o *ObjectInspector) IsReading() bool

func (*ObjectInspector) Property

func (o *ObjectInspector) Property(name string, mandatory bool, description string) *Inspector

func (*ObjectInspector) String

func (o *ObjectInspector) String(name string, value *string, mandatory bool, description string)

func (*ObjectInspector) Value

func (o *ObjectInspector) Value(name string, value RawValue, mandatory bool, description string)

type ReadInspector

type ReadInspector[R Reader] struct {
	// contains filtered or unexported fields
}

func (*ReadInspector[R]) ByteString

func (r *ReadInspector[R]) ByteString(value *[]byte)

func (*ReadInspector[R]) Bytes

func (r *ReadInspector[R]) Bytes(value *[]byte)

func (*ReadInspector[R]) EndArray

func (r *ReadInspector[R]) EndArray()

func (*ReadInspector[R]) EndMap

func (r *ReadInspector[R]) EndMap()

func (*ReadInspector[R]) EndObject

func (r *ReadInspector[R]) EndObject()

func (*ReadInspector[R]) Float32

func (r *ReadInspector[R]) Float32(value *float32, format byte, precision int)

func (*ReadInspector[R]) Float64

func (r *ReadInspector[R]) Float64(value *float64, format byte, precision int)

func (*ReadInspector[R]) HaveNext

func (r *ReadInspector[R]) HaveNext() bool

func (*ReadInspector[R]) Int

func (r *ReadInspector[R]) Int(value *int)

func (*ReadInspector[R]) Int32

func (r *ReadInspector[R]) Int32(value *int32)

func (*ReadInspector[R]) Int64

func (r *ReadInspector[R]) Int64(value *int64)

func (*ReadInspector[R]) IsReading

func (r *ReadInspector[R]) IsReading() bool

func (*ReadInspector[R]) LastError

func (r *ReadInspector[R]) LastError() error

func (*ReadInspector[R]) Property

func (r *ReadInspector[R]) Property(name string, mandatory bool, description string) bool

func (*ReadInspector[R]) PropertyByteString

func (r *ReadInspector[R]) PropertyByteString(name string, value *[]byte, mandatory bool, description string)

func (*ReadInspector[R]) PropertyBytes

func (r *ReadInspector[R]) PropertyBytes(name string, value *[]byte, mandatory bool, description string)

func (*ReadInspector[R]) PropertyFloat32

func (r *ReadInspector[R]) PropertyFloat32(name string, value *float32, format byte, precision int, mandatory bool, description string)

func (*ReadInspector[R]) PropertyFloat64

func (r *ReadInspector[R]) PropertyFloat64(name string, value *float64, format byte, precision int, mandatory bool, description string)

func (*ReadInspector[R]) PropertyInt

func (r *ReadInspector[R]) PropertyInt(name string, value *int, mandatory bool, description string)

func (*ReadInspector[R]) PropertyInt32

func (r *ReadInspector[R]) PropertyInt32(name string, value *int32, mandatory bool, description string)

func (*ReadInspector[R]) PropertyInt64

func (r *ReadInspector[R]) PropertyInt64(name string, value *int64, mandatory bool, description string)

func (*ReadInspector[R]) PropertyString

func (r *ReadInspector[R]) PropertyString(name string, value *string, mandatory bool, description string)

func (*ReadInspector[R]) ReadArray

func (r *ReadInspector[R]) ReadArray(name string, elementName string) int

func (*ReadInspector[R]) ReadMap

func (r *ReadInspector[R]) ReadMap(name string, elementName string, description string) int

func (*ReadInspector[R]) ReadNextKey

func (r *ReadInspector[R]) ReadNextKey() string

func (*ReadInspector[R]) SetReader

func (r *ReadInspector[R]) SetReader(reader io.Reader)

func (*ReadInspector[R]) SetWriter

func (r *ReadInspector[R]) SetWriter(io.Writer)

func (*ReadInspector[R]) StartObject

func (r *ReadInspector[R]) StartObject(name string, description string)

func (*ReadInspector[R]) String

func (r *ReadInspector[R]) String(value *string)

func (*ReadInspector[R]) WriteArray

func (r *ReadInspector[R]) WriteArray(name string, elementName string, length int, description string)

func (*ReadInspector[R]) WriteMap

func (r *ReadInspector[R]) WriteMap(name string, elementName string, length int, description string)

func (*ReadInspector[R]) WriteNextKey

func (r *ReadInspector[R]) WriteNextKey(key string)

type Reader

type Reader interface {
	SetReader(io.Reader)
	Int32() (int32, error)
	Int64() (int64, error)
	Float32() (float32, error)
	Float64() (float64, error)
	String() (string, error)
	Bytes() ([]byte, error)
	ByteString() ([]byte, error)
	StartObject() error
	Property(name string) error
	EndObject() error
	// length==-1 => check HaveNext() after every value
	// length==0 => no need to call EndArray
	StartArray() (length int, err error)
	// returns false when array ends or when StartArray returned length!=-1
	HaveNext() (bool, error)
	EndArray() error
	StartMap() (length int, err error)
	NextKey() (string, error)
	EndMap() error
}

type TextReadInspector

type TextReadInspector[R Reader] struct {
	ReadInspector[R]
}

func (*TextReadInspector[R]) PropertyValue

func (r *TextReadInspector[R]) PropertyValue(name string, value RawValue, mandatory bool, description string)

func (*TextReadInspector[R]) Value

func (r *TextReadInspector[R]) Value(value RawValue)

type TextWriteInspector

type TextWriteInspector[W any, PW WriterPtr[W]] struct {
	WriteInspector[W, PW]
}

func (*TextWriteInspector[W, PW]) PropertyValue

func (w *TextWriteInspector[W, PW]) PropertyValue(name string, value RawValue, mandatory bool, description string)

func (*TextWriteInspector[W, PW]) Value

func (w *TextWriteInspector[W, PW]) Value(value RawValue)

type WriteInspector

type WriteInspector[W any, PW WriterPtr[W]] struct {
	// contains filtered or unexported fields
}

func (*WriteInspector[W, PW]) ByteString

func (w *WriteInspector[W, PW]) ByteString(value *[]byte)

func (*WriteInspector[W, PW]) Bytes

func (w *WriteInspector[W, PW]) Bytes(value *[]byte)

func (*WriteInspector[W, PW]) EndArray

func (w *WriteInspector[W, PW]) EndArray()

func (*WriteInspector[W, PW]) EndMap

func (w *WriteInspector[W, PW]) EndMap()

func (*WriteInspector[W, PW]) EndObject

func (w *WriteInspector[W, PW]) EndObject()

func (*WriteInspector[W, PW]) Float32

func (w *WriteInspector[W, PW]) Float32(value *float32, format byte, precision int)

func (*WriteInspector[W, PW]) Float64

func (w *WriteInspector[W, PW]) Float64(value *float64, format byte, precision int)

func (*WriteInspector[W, PW]) Flush

func (w *WriteInspector[W, PW]) Flush()

func (*WriteInspector[W, PW]) HaveNext

func (w *WriteInspector[W, PW]) HaveNext() bool

func (*WriteInspector[W, PW]) Int

func (w *WriteInspector[W, PW]) Int(value *int)

func (*WriteInspector[W, PW]) Int32

func (w *WriteInspector[W, PW]) Int32(value *int32)

func (*WriteInspector[W, PW]) Int64

func (w *WriteInspector[W, PW]) Int64(value *int64)

func (*WriteInspector[W, PW]) IsReading

func (w *WriteInspector[W, PW]) IsReading() bool

func (*WriteInspector[W, PW]) LastError

func (w *WriteInspector[W, PW]) LastError() error

func (*WriteInspector[W, PW]) Property

func (w *WriteInspector[W, PW]) Property(name string, mandatory bool, description string) bool

func (*WriteInspector[W, PW]) PropertyByteString

func (w *WriteInspector[W, PW]) PropertyByteString(name string, value *[]byte, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyBytes

func (w *WriteInspector[W, PW]) PropertyBytes(name string, value *[]byte, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyFloat32

func (w *WriteInspector[W, PW]) PropertyFloat32(name string, value *float32, format byte, precision int, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyFloat64

func (w *WriteInspector[W, PW]) PropertyFloat64(name string, value *float64, format byte, precision int, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyInt

func (w *WriteInspector[W, PW]) PropertyInt(name string, value *int, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyInt32

func (w *WriteInspector[W, PW]) PropertyInt32(name string, value *int32, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyInt64

func (w *WriteInspector[W, PW]) PropertyInt64(name string, value *int64, mandatory bool, description string)

func (*WriteInspector[W, PW]) PropertyString

func (w *WriteInspector[W, PW]) PropertyString(name string, value *string, mandatory bool, description string)

func (*WriteInspector[W, PW]) ReadArray

func (w *WriteInspector[W, PW]) ReadArray() int

func (*WriteInspector[W, PW]) ReadMap

func (w *WriteInspector[W, PW]) ReadMap() int

func (*WriteInspector[W, PW]) ReadNextKey

func (w *WriteInspector[W, PW]) ReadNextKey() string

func (*WriteInspector[W, PW]) SetReader

func (w *WriteInspector[W, PW]) SetReader(io.Reader)

func (*WriteInspector[W, PW]) SetWriter

func (w *WriteInspector[W, PW]) SetWriter(writer io.Writer, bufferSize int)

func (*WriteInspector[W, PW]) StartObject

func (w *WriteInspector[W, PW]) StartObject(name string, description string)

func (*WriteInspector[W, PW]) String

func (w *WriteInspector[W, PW]) String(value *string)

func (*WriteInspector[W, PW]) WriteArray

func (w *WriteInspector[W, PW]) WriteArray(name string, elementName string, length int, description string)

func (*WriteInspector[W, PW]) WriteMap

func (w *WriteInspector[W, PW]) WriteMap(name string, elementName string, length int, description string)

func (*WriteInspector[W, PW]) WriteNextKey

func (w *WriteInspector[W, PW]) WriteNextKey(key string)

type Writer

type Writer interface {
	SetWriter(writer io.Writer, bufferSize int)
	Int32(value int32) error
	Int64(value int64) error
	Float32(value float32, format byte, precision int) error
	Float64(value float64, format byte, precision int) error
	String(value string) error
	Bytes(value []byte) error
	ByteString(value []byte) error
	StartObject() error
	Property(name string) error
	EndObject() error
	StartArray(length int) error
	EndArray() error
	StartMap(length int) error
	NextKey(key string) error
	EndMap() error
	Flush() error
}

type WriterPtr

type WriterPtr[T any] interface {
	*T
	Writer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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