marshaller

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 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 BytesMarshaller

type BytesMarshaller struct{}

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

func NewBytesMarshaller

func NewBytesMarshaller() BytesMarshaller

NewBytesMarshaller creates a new BytesMarshaller.

func (BytesMarshaller) Marshal

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

Marshal returns the input bytes unchanged.

func (BytesMarshaller) Unmarshal

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

Unmarshal returns the input bytes unchanged.

type JSONMarshaller

type JSONMarshaller[T any] struct{}

JSONMarshaller is a generic JSON marshaller for typed objects.

func NewJSONMarshaller

func NewJSONMarshaller[T any]() JSONMarshaller[T]

NewJSONMarshaller creates a new JSONMarshaller for the specified type.

func (JSONMarshaller[T]) Marshal

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

Marshal serializes the typed data to JSON format.

func (JSONMarshaller[T]) Unmarshal

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

Unmarshal deserializes JSON data into a typed object.

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 Marshaller

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

Marshaller is a generic interface for typed marshalling operations.

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.

type YamlMarshaller

type YamlMarshaller[T any] struct{}

YamlMarshaller is a generic YAML marshaller for typed objects.

func NewYamlMarshaller

func NewYamlMarshaller[T any]() YamlMarshaller[T]

NewYamlMarshaller creates a new YamlMarshaller for the specified type.

func (YamlMarshaller[T]) Marshal

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

Marshal serializes the typed data to YAML format.

func (YamlMarshaller[T]) Unmarshal

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

Unmarshal deserializes YAML data into a typed object.

Jump to

Keyboard shortcuts

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