marshaller

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MarshalError

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

MarshalError represents an error when marshalling fails.

func (MarshalError) Error

func (e MarshalError) Error() string

Error returns a string representation of the marshalling error.

func (MarshalError) Unwrap

func (e MarshalError) Unwrap() error

Unwrap returns the underlying error that caused the marshalling failure.

type Marshallable

type Marshallable interface {
	Marshal() ([]byte, error)
	Unmarshal(data []byte) error
}

Marshallable - custom object serialization, implements for each object. Required for `integrity.Storage` type to set marshalling format to specific object and as recommendation for developers of `Storage` wrappers.

type Marshaller

type Marshaller interface {
	Marshal(data any) ([]byte, error)
	Unmarshal(data []byte, out any) error
}

Marshaller - serialization by default (JSON/Protobuf/etc), implements one time for all objects. Required for `integrity.Storage` to set marshalling format for any type object and as recommendation for developers of `Storage` wrappers.

type TypedBytesMarshaller added in v1.3.0

type TypedBytesMarshaller struct{}

TypedBytesMarshaller is a passthrough marshaller for raw []byte payloads. It implements TypedMarshaller[[]byte] without performing any encoding, useful when values are already serialized or stored as opaque blobs.

func NewTypedBytesMarshaller added in v1.3.0

func NewTypedBytesMarshaller() TypedBytesMarshaller

NewTypedBytesMarshaller creates a new TypedBytesMarshaller.

func (TypedBytesMarshaller) Marshal added in v1.3.0

func (m TypedBytesMarshaller) Marshal(data []byte) ([]byte, error)

Marshal returns the input bytes unchanged.

func (TypedBytesMarshaller) Unmarshal added in v1.3.0

func (m TypedBytesMarshaller) Unmarshal(data []byte) ([]byte, error)

Unmarshal returns the input bytes unchanged.

type TypedJSONMarshaller added in v1.3.0

type TypedJSONMarshaller[T any] struct{}

TypedJSONMarshaller is a generic JSON marshaller for typed objects.

func NewTypedJSONMarshaller added in v1.3.0

func NewTypedJSONMarshaller[T any]() TypedJSONMarshaller[T]

NewTypedJSONMarshaller creates a new TypedJSONMarshaller for the specified type.

func (TypedJSONMarshaller[T]) Marshal added in v1.3.0

func (m TypedJSONMarshaller[T]) Marshal(data T) ([]byte, error)

Marshal serializes the typed data to JSON format.

func (TypedJSONMarshaller[T]) Unmarshal added in v1.3.0

func (m TypedJSONMarshaller[T]) Unmarshal(data []byte) (T, error)

Unmarshal deserializes JSON data into a typed object.

type TypedMarshaller

type TypedMarshaller[T any] interface {
	Marshal(data T) ([]byte, error)
	Unmarshal(data []byte) (T, error)
}

TypedMarshaller is a generic interface for typed marshalling operations.

type TypedYamlMarshaller

type TypedYamlMarshaller[T any] struct{}

TypedYamlMarshaller is a generic YAML marshaller for typed objects.

func NewTypedYamlMarshaller

func NewTypedYamlMarshaller[T any]() TypedYamlMarshaller[T]

NewTypedYamlMarshaller creates a new TypedYamlMarshaller for the specified type.

func (TypedYamlMarshaller[T]) Marshal

func (m TypedYamlMarshaller[T]) Marshal(data T) ([]byte, error)

Marshal serializes the typed data to YAML format.

func (TypedYamlMarshaller[T]) Unmarshal

func (m TypedYamlMarshaller[T]) Unmarshal(data []byte) (T, error)

Unmarshal deserializes YAML data into a typed object.

type UnmarshalError

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

UnmarshalError represents an error when unmarshalling fails.

func (UnmarshalError) Error

func (e UnmarshalError) Error() string

Error returns a string representation of the unmarshalling error.

func (UnmarshalError) Unwrap

func (e UnmarshalError) Unwrap() error

Unwrap returns the underlying error that caused the unmarshalling failure.

Jump to

Keyboard shortcuts

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