Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeBool(d *Decoder) (bool, int, error)
- func DecodeByte(d *Decoder) (byte, int, error)
- func DecodeByteArray(d *Decoder, value []byte) (int, error)
- func DecodeByteSlice(d *Decoder) ([]byte, int, error)
- func DecodeByteSliceWithLimit(d *Decoder, limit uint32) ([]byte, int, error)
- func DecodeCompact16(d *Decoder) (uint16, int, error)
- func DecodeCompact16Ptr(d *Decoder) (*uint16, int, error)
- func DecodeCompact32(d *Decoder) (uint32, int, error)
- func DecodeCompact32Ptr(d *Decoder) (*uint32, int, error)
- func DecodeCompact64(d *Decoder) (uint64, int, error)
- func DecodeCompact64Ptr(d *Decoder) (*uint64, int, error)
- func DecodeCompact8(d *Decoder) (uint8, int, error)
- func DecodeCompact8Ptr(d *Decoder) (*uint8, int, error)
- func DecodeLen(d *Decoder, limit uint32) (uint32, int, error)
- func DecodeOption[V any, H DecodablePtr[V]](d *Decoder) (*V, int, error)
- func DecodeSliceOfByteSlice(d *Decoder) ([][]byte, int, error)
- func DecodeSliceOfByteSliceWithLimit(d *Decoder, limit uint32) ([][]byte, int, error)
- func DecodeString(d *Decoder) (string, int, error)
- func DecodeStringSlice(d *Decoder) ([]string, int, error)
- func DecodeStringSliceWithLimit(d *Decoder, limit uint32) ([]string, int, error)
- func DecodeStringWithLimit(d *Decoder, limit uint32) (string, int, error)
- func DecodeStruct[V any, H DecodablePtr[V]](d *Decoder) (V, int, error)
- func DecodeStructArray[V any, H DecodablePtr[V]](d *Decoder, value []V) (int, error)
- func DecodeStructSlice[V any, H DecodablePtr[V]](d *Decoder) ([]V, int, error)
- func DecodeStructSliceWithLimit[V any, H DecodablePtr[V]](d *Decoder, limit uint32) ([]V, int, error)
- func DecodeUint16Slice(d *Decoder) ([]uint16, int, error)
- func DecodeUint16SliceWithLimit(d *Decoder, limit uint32) ([]uint16, int, error)
- func DecodeUint32Slice(d *Decoder) ([]uint32, int, error)
- func DecodeUint32SliceWithLimit(d *Decoder, limit uint32) ([]uint32, int, error)
- func DecodeUint64Slice(d *Decoder) ([]uint64, int, error)
- func DecodeUint64SliceWithLimit(d *Decoder, limit uint32) ([]uint64, int, error)
- func EncodeBool(e *Encoder, value bool) (int, error)
- func EncodeByte(e *Encoder, value byte) (int, error)
- func EncodeByteArray(e *Encoder, value []byte) (int, error)
- func EncodeByteSlice(e *Encoder, value []byte) (int, error)
- func EncodeByteSliceWithLimit(e *Encoder, value []byte, limit uint32) (int, error)
- func EncodeCompact16(e *Encoder, v uint16) (int, error)
- func EncodeCompact16Ptr(e *Encoder, value *uint16) (int, error)
- func EncodeCompact32(e *Encoder, v uint32) (int, error)
- func EncodeCompact32Ptr(e *Encoder, value *uint32) (int, error)
- func EncodeCompact64(e *Encoder, v uint64) (int, error)
- func EncodeCompact64Ptr(e *Encoder, value *uint64) (int, error)
- func EncodeCompact8(e *Encoder, v uint8) (int, error)
- func EncodeCompact8Ptr(e *Encoder, value *uint8) (int, error)
- func EncodeLen(e *Encoder, v, limit uint32) (int, error)
- func EncodeOption[V any, H EncodablePtr[V]](e *Encoder, value *V) (int, error)
- func EncodeString(e *Encoder, value string) (int, error)
- func EncodeStringSlice(e *Encoder, value []string) (int, error)
- func EncodeStringSliceWithLimit(e *Encoder, value []string, limit uint32) (int, error)
- func EncodeStringWithLimit(e *Encoder, value string, limit uint32) (int, error)
- func EncodeStruct[V any, H EncodablePtr[V]](e *Encoder, value V) (int, error)
- func EncodeStructArray[V any, H EncodablePtr[V]](e *Encoder, value []V) (int, error)
- func EncodeStructSlice[V any, H EncodablePtr[V]](e *Encoder, value []V) (int, error)
- func EncodeStructSliceWithLimit[V any, H EncodablePtr[V]](e *Encoder, value []V, limit uint32) (int, error)
- func EncodeUint16(e *Encoder, value uint16) (int, error)
- func EncodeUint16Slice(e *Encoder, value []uint16) (int, error)
- func EncodeUint16SliceWithLimit(e *Encoder, value []uint16, limit uint32) (int, error)
- func EncodeUint32(e *Encoder, value uint32) (int, error)
- func EncodeUint32Slice(e *Encoder, value []uint32) (int, error)
- func EncodeUint32SliceWithLimit(e *Encoder, value []uint32, limit uint32) (int, error)
- func EncodeUint64(e *Encoder, value uint64) (int, error)
- func EncodeUint64Slice(e *Encoder, value []uint64) (int, error)
- func EncodeUint64SliceWithLimit(e *Encoder, value []uint64, limit uint32) (int, error)
- func Generate(pkg, filepath string, objs ...any) error
- func LenSize(v uint32) uint32
- func MaxScaleElements[T any](fieldName string) (uint32, error)
- func MaxScaleElementsForField(v any, fieldName string) (uint32, error)
- func MustGetMaxElements[T any](fieldName string) uint32
- func WithDecodeMaxElements(elements uint32) decoderOpts
- func WithDecodeMaxNested(nested uint) decoderOpts
- func WithEncodeMaxElements(elements uint32) encoderOpts
- func WithEncodeMaxNested(nested uint) encoderOpts
- type Decodable
- type DecodablePtr
- type Decoder
- type Encodable
- type EncodablePtr
- type Encoder
- type Type
- type TypePtr
- type U8
Constants ¶
const ( // MaxElements is the maximum number of elements allowed in a collection if not set explicitly during // encoding/decoding. MaxElements uint32 = 1 << 20 // MaxNested is the maximum nested level allowed if not set explicitly during encoding/decoding. MaxNested uint = 4 )
Variables ¶
var ( // ErrDecodeTooManyElements is returned when scale limit tag is used and collection has too many elements to decode. ErrDecodeTooManyElements = errors.New("too many elements to decode in collection with scale limit set") // ErrDecodeNestedTooDeep is returned when nested level is too deep. ErrDecodeNestedTooDeep = errors.New("nested level is too deep") )
var ( // ErrEncodeTooManyElements is returned when scale limit tag is used and collection has too many elements to encode. ErrEncodeTooManyElements = errors.New("too many elements to encode in collection with scale limit set") // ErrEncodeNestedTooDeep is returned when the depth of nested types exceeds the limit. ErrEncodeNestedTooDeep = errors.New("nested level is too deep") )
Functions ¶
func DecodeOption ¶
func DecodeOption[V any, H DecodablePtr[V]](d *Decoder) (*V, int, error)
func DecodeStringWithLimit ¶
func DecodeStruct ¶
func DecodeStruct[V any, H DecodablePtr[V]](d *Decoder) (V, int, error)
func DecodeStructArray ¶
func DecodeStructArray[V any, H DecodablePtr[V]](d *Decoder, value []V) (int, error)
func DecodeStructSlice ¶
func DecodeStructSlice[V any, H DecodablePtr[V]](d *Decoder) ([]V, int, error)
func DecodeUint16SliceWithLimit ¶ added in v1.2.0
func DecodeUint32SliceWithLimit ¶ added in v1.2.0
func DecodeUint64SliceWithLimit ¶ added in v1.2.0
func EncodeCompact16Ptr ¶ added in v1.2.0
func EncodeCompact32Ptr ¶ added in v1.2.0
func EncodeCompact64Ptr ¶ added in v1.2.0
func EncodeCompact8Ptr ¶ added in v1.2.0
func EncodeOption ¶
func EncodeOption[V any, H EncodablePtr[V]](e *Encoder, value *V) (int, error)
func EncodeStringWithLimit ¶
func EncodeStruct ¶
func EncodeStruct[V any, H EncodablePtr[V]](e *Encoder, value V) (int, error)
func EncodeStructArray ¶
func EncodeStructArray[V any, H EncodablePtr[V]](e *Encoder, value []V) (int, error)
func EncodeStructSlice ¶
func EncodeStructSlice[V any, H EncodablePtr[V]](e *Encoder, value []V) (int, error)
func EncodeUint16Slice ¶ added in v1.2.0
func EncodeUint16SliceWithLimit ¶ added in v1.2.0
func EncodeUint32Slice ¶ added in v1.2.0
func EncodeUint32SliceWithLimit ¶ added in v1.2.0
func EncodeUint64Slice ¶ added in v1.2.0
func EncodeUint64SliceWithLimit ¶ added in v1.2.0
func LenSize ¶ added in v1.1.13
LenSize returns the size in bytes required to encode a length value.
func MaxScaleElements ¶ added in v1.1.14
MaxScaleElements is a generic version of GetMaxElementsFromValue that uses the specified type instead of a struct value.
func MaxScaleElementsForField ¶ added in v1.1.14
MaxScaleElementsForField returns the max number of elements for the specified field in the struct passed as the v argument based on the 'scale' tag. It returns an error if v is not a structure, if max is not specified for the field, the field doesn't exist or there's a problem parsing the tag.
func MustGetMaxElements ¶ added in v1.1.14
MustGetMaxElements is the same as GetMaxElements, but returns just the max tag value and panics in case of an error.
func WithDecodeMaxElements ¶ added in v1.1.10
func WithDecodeMaxElements(elements uint32) decoderOpts
WithDecodeMaxElements sets the maximum number of elements allowed in a collection. The default value is 1 << 20.
func WithDecodeMaxNested ¶ added in v1.1.10
func WithDecodeMaxNested(nested uint) decoderOpts
WithDecodeMaxNested sets the nested level of the decoder. A value of 0 means no nesting is allowed. The default value is 4.
func WithEncodeMaxElements ¶ added in v1.1.10
func WithEncodeMaxElements(elements uint32) encoderOpts
WithEncodeMaxElements sets the maximum number of elements allowed in a collection. The default value is 1 << 20.
func WithEncodeMaxNested ¶ added in v1.1.10
func WithEncodeMaxNested(nested uint) encoderOpts
WithEncodeMaxNested sets the nested level of the encoder. A value of 0 means no nesting is allowed. The default value is 4.
Types ¶
type DecodablePtr ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
type EncodablePtr ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w. If w implements io.StringWriter, the returned encoder will be more efficient in encoding strings.