Documentation
¶
Index ¶
- Constants
- Variables
- func Decode(ctx *ReadContext) (any, error)
- func DecodeArray[T any](ctx *ReadContext, init ...func(arr []T)) (arr []T, err error)
- func DecodeBytecodeFrom(ctx *ReadContext) (*gad.Bytecode, error)
- func DecodeDict(ctx *ReadContext) (d gad.Dict, err error)
- func DecodeFields(ctx *ReadContext, cb func(field uint8) error) (err error)
- func DecodeItems[V any](ctx *ReadContext, init func(l int), cb func(i int, v V) error) (err error)
- func DecodeIterator(ctx *ReadContext, init func(l int), cb func(i int) error) (err error)
- func DecodeT[T any](ctx *ReadContext) (o T, err error)
- func Encode(ctx *WriteContext, typeID byte, version byte, o any) (err error)
- func EncodeArray[T any](ctx *WriteContext, arr []T) (err error)
- func EncodeDict(ctx *WriteContext, d gad.Dict) (err error)
- func EncodeObject(ctx *WriteContext, o any) (err error)
- func Register[T any](typeID byte, version byte, encDec *EncDec)
- func WriteArray[T any](w Writer, arr []T, do func(w Writer, v T) error) (err error)
- type Context
- type DecodeFunc
- type EmbeddedWriter
- type EncDec
- type EncodeFunc
- type GoModules
- type ModulesSpec
- type ReadContext
- type ReadContextOption
- type Reader
- type TypeEncoder
- type WriteContext
- type WriteContextOption
- type Writer
Constants ¶
View Source
const ( BytecodeSignature uint32 = 0x75474F BytecodeVersion uint16 = 1 )
BytecodeV1 signature and version are written to the header of encoded BytecodeV1. BytecodeV1 is encoded with current BytecodeVersion and its format.
View Source
const FieldEOF byte = 255
Variables ¶
View Source
var Encoders = encDecRegistrator{ // contains filtered or unexported fields }
Functions ¶
func Decode ¶ added in v0.0.2
func Decode(ctx *ReadContext) (any, error)
func DecodeArray ¶ added in v0.0.2
func DecodeArray[T any](ctx *ReadContext, init ...func(arr []T)) (arr []T, err error)
func DecodeBytecodeFrom ¶
func DecodeBytecodeFrom(ctx *ReadContext) (*gad.Bytecode, error)
DecodeBytecodeFrom decodes *gad.Bytecode from given r io.Reader.
func DecodeDict ¶ added in v0.0.2
func DecodeDict(ctx *ReadContext) (d gad.Dict, err error)
func DecodeFields ¶ added in v0.0.2
func DecodeFields(ctx *ReadContext, cb func(field uint8) error) (err error)
func DecodeItems ¶ added in v0.0.2
func DecodeIterator ¶ added in v0.0.2
func DecodeIterator(ctx *ReadContext, init func(l int), cb func(i int) error) (err error)
func DecodeT ¶ added in v0.0.2
func DecodeT[T any](ctx *ReadContext) (o T, err error)
func Encode ¶ added in v0.0.2
func Encode(ctx *WriteContext, typeID byte, version byte, o any) (err error)
func EncodeArray ¶ added in v0.0.2
func EncodeArray[T any](ctx *WriteContext, arr []T) (err error)
func EncodeDict ¶ added in v0.0.2
func EncodeDict(ctx *WriteContext, d gad.Dict) (err error)
func EncodeObject ¶ added in v0.0.2
func EncodeObject(ctx *WriteContext, o any) (err error)
Types ¶
type Context ¶ added in v0.0.2
type Context struct {
context.Context
Modules []*gad.ModuleSpec
GoModules GoModules
}
type DecodeFunc ¶ added in v0.0.2
type DecodeFunc func(ctx *ReadContext) (any, error)
type EmbeddedWriter ¶ added in v0.0.2
type EncDec ¶ added in v0.0.2
type EncDec struct {
Encode EncodeFunc
Decode DecodeFunc
}
var ( CompiledFunctionV1, NilV1, StrV1, RawStrV1, BytesV1, ArrayV1, DictV1, SyncDictV1, IntV1, UintV1, CharV1, FloatV1, DecimalV1, BoolV1, FlagV1, BytecodeV1, SourceFileSetV1, SourceFileV1, SymbolInfoV1, ModuleSpecV1, ErrorV1, EmbeddedV1, RegexpV1, TimeV1, DurationV1, CalendarDateV1, CalendarTimeV1, EnumV1, TypedIdentV1, FuncHeaderObjectV1, MethodInterfaceV1, InterfaceV1, InterfaceFieldV1, InterfacePropV1, InterfaceMethodV1 EncDec )
type EncodeFunc ¶ added in v0.0.2
type EncodeFunc func(ctx *WriteContext, o any) error
type GoModules ¶ added in v0.0.2
type GoModules map[string]gad.ModuleInitFunc
func GoModulesFromModulesMap ¶ added in v0.0.2
type ModulesSpec ¶ added in v0.0.2
type ModulesSpec []*gad.ModuleSpec
func EncodeBytecodeTo ¶
func EncodeBytecodeTo(ctx *WriteContext, bc *gad.Bytecode) (ModulesSpec, error)
EncodeBytecodeTo encodes given bc to w io.Writer.
type ReadContext ¶ added in v0.0.2
type ReadContext struct {
Reader
Context context.Context
Modules []*gad.ModuleSpec
GoModules GoModules
EmbeddedReader io.ReaderAt
}
func NewReadContext ¶ added in v0.0.2
func NewReadContext(r Reader, opt ...ReadContextOption) *ReadContext
type ReadContextOption ¶ added in v0.0.2
type ReadContextOption func(ctx *ReadContext)
func ReadContextWithEmbeddedReader ¶ added in v0.0.2
func ReadContextWithEmbeddedReader(r io.ReaderAt) ReadContextOption
func ReadContextWithGoModules ¶ added in v0.0.2
func ReadContextWithGoModules(modules GoModules) ReadContextOption
func ReadContextWithModuleMap ¶ added in v0.0.2
func ReadContextWithModuleMap(mm *gad.ModuleMap) ReadContextOption
func ReadContextWithModules ¶ added in v0.0.2
func ReadContextWithModules(modules ModulesSpec) ReadContextOption
type Reader ¶ added in v0.0.2
type Reader interface {
io.ReadSeeker
io.ByteReader
io.ReaderAt
}
func NewReader ¶ added in v0.0.2
func NewReader(r io.ReadSeeker) Reader
type TypeEncoder ¶ added in v0.0.2
type WriteContext ¶ added in v0.0.2
type WriteContext struct {
Context context.Context
EmbeddedWriter EmbeddedWriter
Writer
}
func NewWriteContext ¶ added in v0.0.2
func NewWriteContext(ctx context.Context, writer Writer, opt ...WriteContextOption) *WriteContext
func (*WriteContext) Value ¶ added in v0.0.2
func (ctx *WriteContext) Value(key string) any
func (*WriteContext) WithValue ¶ added in v0.0.2
func (ctx *WriteContext) WithValue(key string, value any) *WriteContext
type WriteContextOption ¶ added in v0.0.2
type WriteContextOption func(ctx *WriteContext)
func WriteContextWithEmbededWriter ¶ added in v0.0.2
func WriteContextWithEmbededWriter(w EmbeddedWriter) WriteContextOption
Click to show internal directories.
Click to hide internal directories.