serializer

package
v0.0.0-...-8032e83 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUnmarshalInputType = fmt.Errorf("unmarshal input have to be non nil pointer:%w", errors.ErrUnsupported)
View Source
var ErrUnMarshalArrayOverflow = errors.New("array overflow")
View Source
var ErrUnMarshalArrayUnderflow = errors.New("array underflow")

Functions

func Marshal

func Marshal(in any, opts ...EncoderOption) (av types.AttributeValue, err error)

func MarshalFuncV1

func MarshalFuncV1[T any](fn func(T) (types.AttributeValue, error)) (res customMarshaler)

func NewUnSupportedTypeError

func NewUnSupportedTypeError(av types.AttributeValue, t reflect.Type) error

func OmitZeroStructFields

func OmitZeroStructFields() encoderOptionAdapter

func UnMarshalFuncV1

func UnMarshalFuncV1[T any](fn func(types.AttributeValue, *T) error) (res customUnMarshaler)

func WithTag

func WithTag(tag string) tagOption

Types

type ArrayUnmarshalOverflowOption

type ArrayUnmarshalOverflowOption uint8
const (
	//fail on attempt to unmarshal into go array if the data length is not exact match to the array length
	CheckOverFlowAndUnderflowArrayOnUnmarshal ArrayUnmarshalOverflowOption = iota //0b0
	//allow unmarshal into go array if the data length is longer then the array length - any data that is beyond the array length will be discarded
	CheckUnderflowArrayOnUnmarshaling ArrayUnmarshalOverflowOption = iota //0b01
	//allow unmarshal into go array if the data length is shorter then the array length - rest of the array will contain the zero value for the un-marshaled type
	CheckOverflowUnmarshalArrayOnUnmarshaling ArrayUnmarshalOverflowOption = iota //0b10
	//will allow to attempt unmarshaling into go array data of any length the behavior will be like other options described
	AllowUnmarshalArrayFromAnyLen ArrayUnmarshalOverflowOption = iota //0b11
)

func (ArrayUnmarshalOverflowOption) IsOverflowAllowed

func (overFlowOption ArrayUnmarshalOverflowOption) IsOverflowAllowed() bool

return true if decoder is allowed to ignore items when unmarshaling array incase array length is smaller then data slice length

func (ArrayUnmarshalOverflowOption) IsUnderflowAllowed

func (overFlowOption ArrayUnmarshalOverflowOption) IsUnderflowAllowed() bool

return true if decoder is allowed to zero items when unmarshaling array incase array length is larger then data slice length

type Decoder

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

func NewDecoder

func NewDecoder(opts ...DecoderOption) *Decoder

func (*Decoder) Unmarshal

func (d *Decoder) Unmarshal(av types.AttributeValue, out any) (err error)

type DecoderConfig

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

func NewDecoderConfig

func NewDecoderConfig(opts ...DecoderOption) DecoderConfig

type DecoderOption

type DecoderOption interface {
	// contains filtered or unexported methods
}

func WithUnmarshalers

func WithUnmarshalers(m customUnMarshaler, more ...customUnMarshaler) DecoderOption

type DynamoKind

type DynamoKind int8
const (
	DynamoKindUnknown   DynamoKind = iota
	DynamoKindNull      DynamoKind = iota
	DynamoKindString    DynamoKind = iota
	DynamoKindNumber    DynamoKind = iota
	DynamoKindBool      DynamoKind = iota
	DynamoKindBinary    DynamoKind = iota
	DynamoKindList      DynamoKind = iota
	DynamoKindMap       DynamoKind = iota
	DynamoKindStringSet DynamoKind = iota
	DynamoKindNumberSet DynamoKind = iota
	DynamoKindBinarySet DynamoKind = iota
)

type Encoder

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

func NewEncoder

func NewEncoder(opts ...EncoderOption) *Encoder

func (*Encoder) Marshal

func (e *Encoder) Marshal(in any) (av types.AttributeValue, err error)

type EncoderConfig

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

func NewEncoderConfig

func NewEncoderConfig(opts ...EncoderOption) EncoderConfig

type EncoderOption

type EncoderOption interface {
	// contains filtered or unexported methods
}

func WithMarshalers

func WithMarshalers(marshaler customMarshaler, more ...customMarshaler) EncoderOption

type IsZeroer

type IsZeroer interface {
	IsZero() bool
}

type SerializerError

type SerializerError struct {
	SerializerErrorData
	// contains filtered or unexported fields
}

func (SerializerError) Error

func (e SerializerError) Error() string

type SerializerErrorData

type SerializerErrorData struct {
	Path   string
	Kind   DynamoKind   //optional
	GoType reflect.Type //may be nill
	Err    error        //may be nill if there is no underlying error
}

func (SerializerErrorData) Unwrap

func (e SerializerErrorData) Unwrap(err error) error

Jump to

Keyboard shortcuts

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