package serdes

import "github.com/datastax/astra-db-go/v2/astra/serdes"

Copyright IBM Corp.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Code generated by gen-options; DO NOT EDIT.

Index

Functions

func Deserialize

func Deserialize(data []byte, res any, targetDecodeCtx TargetDecodeCtx, target Target, flags ...DesFlags) error

func Serialize

func Serialize(data any, target Target, flags ...SerFlags) ([]byte, error)

func SerializeInto

func SerializeInto(data any, target Target, dst []byte, flags ...SerFlags) ([]byte, error)

Types

type AstraMarshaler

type AstraMarshaler interface {
	MarshalAstra(ctx EncodeCtx) (any, error)
}

type AstraRawMarshaler

type AstraRawMarshaler interface {
	MarshalAstraRaw(ctx EncodeCtx, dst []byte) ([]byte, error)
}

type AstraRawUnmarshaler

type AstraRawUnmarshaler interface {
	UnmarshalAstraRaw(ctx DecodeCtx, value []byte) error
}

type AstraUnmarshaler

type AstraUnmarshaler interface {
	UnmarshalAstra(ctx DecodeCtx, value any) error
}

type DecodeAction

type DecodeAction int
const (
	DecodeActionSyntax DecodeAction = iota
	DecodeActionTypeMismatch
	DecodeActionCustomUnmarshaler
	DecodeActionUnsupported
	DecodeActionInvalid
)

type DecodeCtx

type DecodeCtx struct {
	Target    Target
	TargetCtx TargetDecodeCtx
	Flags     DesFlags
	// contains filtered or unexported fields
}

type DecodeError

type DecodeError struct {
	Action  DecodeAction
	Msg     string
	Value   string
	Type    reflect.Type
	Snippet string
	Offset  int64
	Err     error
	// contains filtered or unexported fields
}
func (*DecodeError) Error
func (e *DecodeError) Error() string
func (*DecodeError) Unwrap
func (e *DecodeError) Unwrap() error

type DesFlags

type DesFlags int
const (
	// SparseRows can be used to disable populating missing columns in untyped rows.
	SparseRows DesFlags = 1 << iota

	// UseNumber can be used for untyped documents/rows in case they're expecting large numbers often.
	UseNumber

	// DesNoCache can be used to disable the serdes cache for deserialization.
	DesNoCache

	// ExtendedErrorSnippet can be used to include more of the JSON snippet in error messages (default is 16 chars, ExtendedErrorSnippet allows up to 64 chars).
	//
	// Note that extending the error context has a higher chance of leaking sensitive data in error messages; be mindful of its usage.
	ExtendedErrorSnippet

	// UseJSONUnmarshal can be used to recognize the standard library's json.Unmarshaler interface.
	// Custom Astra unmarshalers still take precedence.
	UseJSONUnmarshal

	// CaseInsensitiveFieldMatching can be used to fallback to case-insensitive
	// struct field lookups if an exact match isn't found.
	CaseInsensitiveFieldMatching
)

type EncodeAction

type EncodeAction int
const (
	EncodeActionCustomMarshaler EncodeAction = iota
	EncodeActionUnsupportedValue
	EncodeActionUnsupportedType
)

type EncodeCtx

type EncodeCtx struct {
	Target Target
	Flags  SerFlags
	// contains filtered or unexported fields
}

type EncodeError

type EncodeError struct {
	Action EncodeAction
	Msg    string
	Type   reflect.Type
	Err    error
	// contains filtered or unexported fields
}
func (*EncodeError) Error
func (e *EncodeError) Error() string
func (*EncodeError) Unwrap
func (e *EncodeError) Unwrap() error

type SerFlags

type SerFlags int
const (
	// TrustRawMessage can be used as a slight optimization for when internal code has something it knows for sure is trusted.
	TrustRawMessage SerFlags = 1 << iota

	// SortMapKeys can be used to force the keys of a map to be sorted using datatypes.ComparatorFor when serializing
	SortMapKeys

	// SerNoCache can be used to disable the serdes cache for serialization.
	SerNoCache

	// UseJSONMarshal can be used to recognize the standard library's json.Marshaler interface.
	// Custom Astra marshalers still take precedence.
	UseJSONMarshal
)

type Target

type Target int
const (
	TargetNone Target = iota
	TargetCollection
	TargetTable
)
func (Target) String
func (t Target) String() string

type TargetDecodeCtx

type TargetDecodeCtx interface {
	UntypedTargetInterface() reflect.Type
	NewUntypedTarget(ctx DecodeCtx, p unsafe.Pointer) AstraRawUnmarshaler
}