Documentation ¶
Index ¶
- Constants
- func From[T any](obj T, ctx IMarshalSchemaContext) calm.ResultT[ITree]
- func FromDefault[T any](obj T) calm.ResultT[ITree]
- func IsArr(tree ITree) bool
- func IsBool(tree ITree) bool
- func IsMap(tree ITree) bool
- func IsNull(tree ITree) bool
- func IsNum(tree ITree) bool
- func IsStr(tree ITree) bool
- func To[T any](tree ITree, ctx IMarshalSchemaContext) calm.ResultT[T]
- func ToAny(v ITree) any
- func ToDefault[T any](tree ITree) calm.ResultT[T]
- func ToUrlValues(v ITree) calm.ResultT[url.Values]
- type IMarshalErr
- type IMarshalSchema
- type IMarshalSchemaContext
- type IMarshalSchemaResolutionContext
- type ITree
Constants ¶
View Source
const ( TypeNull = 0 TypeBool = 1 TypeNum = 2 TypeStr = 3 TypeMap = 4 TypeArr = 5 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IMarshalErr ¶
func NewMarshalErr ¶
func NewMarshalErr(reason string) IMarshalErr
func NewMarshalErrType ¶
func NewMarshalErrType(want, actual int32) IMarshalErr
func WrapMarshalErr ¶
func WrapMarshalErr(err IMarshalErr, path string) IMarshalErr
type IMarshalSchema ¶
type IMarshalSchema interface { Zero(value reflect.Value) Read(value reflect.Value) ITree Write(value reflect.Value, tree ITree) IMarshalErr }
IMarshalSchema The interface for a marshal-able type
Note:
There has always been an interest to speed up encode/decode by skipping reflection. However, this cannot be achieved without exposing golang's internal api. I will stick with reflect.Value for this for the foreseeable future. If anyone is interested in doing so, maybe checkout Masaaki Goshima(https://github.com/goccy)'s work and implement said mechanism on your own fork
type IMarshalSchemaContext ¶
type IMarshalSchemaContext interface { With() IMarshalSchemaResolutionContext Supply(t reflect.Type, schema IMarshalSchema) // contains filtered or unexported methods }
func DefaultSchemaContext ¶
func DefaultSchemaContext() IMarshalSchemaContext
func MakeSchemaContext ¶
func MakeSchemaContext(parent IMarshalSchemaContext) IMarshalSchemaContext
type IMarshalSchemaResolutionContext ¶
type IMarshalSchemaResolutionContext interface {
Resolve(t reflect.Type) IMarshalSchema
}
type ITree ¶
type ITree interface { Type() int32 AsBool() calm.ResultT[bool] AsNum() calm.ResultT[float64] AsStr() calm.ResultT[string] AsMap() calm.ResultT[map[string]ITree] AsArr() calm.ResultT[[]ITree] SetBool(bool) SetNum(float64) SetStr(string) SetMap(map[string]ITree) SetArr([]ITree) }
func FromUrlValues ¶
Click to show internal directories.
Click to hide internal directories.