2021-06-03 12:49:01 +03:00
|
|
|
package decoder
|
|
|
|
|
|
|
|
import (
|
2021-06-12 11:06:26 +03:00
|
|
|
"context"
|
2021-06-03 12:49:01 +03:00
|
|
|
"encoding"
|
|
|
|
"encoding/json"
|
|
|
|
"reflect"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2021-06-03 13:10:17 +03:00
|
|
|
type Decoder interface {
|
2021-06-04 19:08:27 +03:00
|
|
|
Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error)
|
2021-06-03 12:49:01 +03:00
|
|
|
DecodeStream(*Stream, int64, unsafe.Pointer) error
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
nul = '\000'
|
|
|
|
maxDecodeNestingDepth = 10000
|
|
|
|
)
|
|
|
|
|
2021-06-12 11:06:26 +03:00
|
|
|
type unmarshalerContext interface {
|
|
|
|
UnmarshalJSON(context.Context, []byte) error
|
|
|
|
}
|
|
|
|
|
2021-06-03 12:49:01 +03:00
|
|
|
var (
|
2021-06-12 11:06:26 +03:00
|
|
|
unmarshalJSONType = reflect.TypeOf((*json.Unmarshaler)(nil)).Elem()
|
|
|
|
unmarshalJSONContextType = reflect.TypeOf((*unmarshalerContext)(nil)).Elem()
|
|
|
|
unmarshalTextType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
|
2021-06-03 12:49:01 +03:00
|
|
|
)
|