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 DecodeCtx

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

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

	// ExtendedErrorContext can be used to include more of the JSON snippet in error messages (default is 16 chars, ExtendedErrorContext 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.
	ExtendedErrorContext

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

type EncodeCtx

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

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

An InvalidUnmarshalError describes an invalid argument passed to Deserialize. (The argument to Deserialize must be a non-nil pointer.)

func (InvalidUnmarshalError) Error
func (e InvalidUnmarshalError) Error() string

type MarshalerError

type MarshalerError struct {
	Type reflect.Type
	Err  error
	// contains filtered or unexported fields
}

A MarshalerError represents an error from calling a MarshalAstra method.

func (MarshalerError) Error
func (e MarshalerError) Error() string
func (MarshalerError) Unwrap
func (e MarshalerError) 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 SyntaxError

type SyntaxError struct {
	Snippet string // snippet of JSON near the error
	Err     error  // underlying error
	// contains filtered or unexported fields
}

A SyntaxError is a description of a JSON/BSON syntax error.

func (SyntaxError) Error
func (e SyntaxError) Error() string
func (SyntaxError) GetSnippet
func (e SyntaxError) GetSnippet() string
func (SyntaxError) Unwrap
func (e SyntaxError) Unwrap() error

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
}

type UnmarshalTypeError

type UnmarshalTypeError struct {
	Value   string       // description of JSON/BSON value - "bool", "array", "number -5"
	Type    reflect.Type // type of Go value it could not be assigned to
	Snippet string       // snippet of JSON near the error
	Err     error        // underlying error
	// contains filtered or unexported fields
}

An UnmarshalTypeError describes a JSON/BSON value that was not appropriate for a value of a specific Go type.

func (UnmarshalTypeError) Error
func (e UnmarshalTypeError) Error() string
func (UnmarshalTypeError) GetSnippet
func (e UnmarshalTypeError) GetSnippet() string
func (UnmarshalTypeError) Unwrap
func (e UnmarshalTypeError) Unwrap() error

type UnmarshalerError

type UnmarshalerError struct {
	Type    reflect.Type
	Snippet string
	Err     error
	// contains filtered or unexported fields
}

An UnmarshalerError represents an error from calling an UnmarshalAstra method.

func (UnmarshalerError) Error
func (e UnmarshalerError) Error() string
func (UnmarshalerError) GetSnippet
func (e UnmarshalerError) GetSnippet() string
func (UnmarshalerError) Unwrap
func (e UnmarshalerError) Unwrap() error

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type reflect.Type
	// contains filtered or unexported fields
}

An UnsupportedTypeError is returned when attempting to marshal an unsupported type.

func (UnsupportedTypeError) Error
func (e UnsupportedTypeError) Error() string

type UnsupportedValueError

type UnsupportedValueError struct {
	Value any
	Msg   string
	// contains filtered or unexported fields
}

An UnsupportedValueError is returned when a value is not supported by Astra, such as a cycle, a missing tag, or a target mismatch.

func (UnsupportedValueError) Error
func (e UnsupportedValueError) Error() string