marshal

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonMarshaler

type JsonMarshaler[T any] struct {
}

JsonMarshaler is an implementation of Marshaler that uses JSON.

func (*JsonMarshaler[T]) Marshal

func (jm *JsonMarshaler[T]) Marshal(ctx context.Context, value T) (string, error)

Marshal marshals a go struct into a JSON string.

func (*JsonMarshaler[T]) Unmarshal

func (jm *JsonMarshaler[T]) Unmarshal(ctx context.Context, valueString string, value *T) error

Unmarshal unmarshals a go struct from a JSON string into a go struct.

type Marshaler

type Marshaler[T any] interface {
	// Marshal marshals a go struct into a string.
	Marshal(ctx context.Context, value T) (string, error)
	// Unmarshal unmarshals a string into a go struct.
	Unmarshal(ctx context.Context, valueString string, value *T) error
}

Marshaler is an interface contract for marshalling values from Go structs into strings that can be stored in Redis.

Jump to

Keyboard shortcuts

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