encoder

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package encoder will replace encoder package with new design :(

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(b []byte, enc Encoder, target interface{}) error

func DecodeWithHint

func DecodeWithHint(b []byte, enc Encoder, ht hint.Hint, target interface{}) error

func Ptr

func Ptr(i interface{}) (reflect.Value, reflect.Value)

Types

type AsyncWriter

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

func NewAsyncWriter

func NewAsyncWriter(enc Encoder, w io.Writer) *AsyncWriter

type Encoder

type Encoder interface {
	hint.Hinter
	Add(hint.Hinter) error
	Marshal(interface{}) ([]byte, error)
	Unmarshal([]byte, interface{}) error
	Decode([]byte) (hint.Hinter, error)                    // NOTE decode hinted instance
	DecodeWithHint([]byte, hint.Hint) (hint.Hinter, error) // NOTE decode with hint
	DecodeSlice([]byte) ([]hint.Hinter, error)             // NOTE decode slice of hinted instance
	DecodeMap([]byte) (map[string]hint.Hinter, error)      // NOTE decode string key map of hinted instance
}

type Encoders

type Encoders struct {
	*hint.GlobalHintset
	// contains filtered or unexported fields
}

func NewEncoders

func NewEncoders() *Encoders

func (*Encoders) AddEncoder

func (es *Encoders) AddEncoder(ec Encoder) error

func (*Encoders) AddHinter

func (es *Encoders) AddHinter(ht hint.Hinter) error

func (*Encoders) AddType

func (es *Encoders) AddType(ty hint.Type) error

func (*Encoders) Compatible

func (es *Encoders) Compatible(ht hint.Hint) (hint.Hinter, error)

func (*Encoders) Encoder

func (es *Encoders) Encoder(ty hint.Type, version string) (Encoder, error)

func (*Encoders) Initialize

func (es *Encoders) Initialize() error

type UnpackFunc

type UnpackFunc func([]byte, hint.Hint) (interface{}, error)

type Unpacker

type Unpacker struct {
	Elem interface{}
	N    string
	F    UnpackFunc
}

func AnalyzeSetHinter

func AnalyzeSetHinter(up Unpacker) Unpacker

Directories

Path Synopsis
Package bsonenc support encoding and decoding instance by bson.
Package bsonenc support encoding and decoding instance by bson.
Package jsonenc support encoding and decoding instance by json.
Package jsonenc support encoding and decoding instance by json.

Jump to

Keyboard shortcuts

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