wrapper

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WithJSON

type WithJSON[T any] struct {
	Data T
}

WithJSON adds JSON marshaling capabilities to any struct

func NewWrapper

func NewWrapper[T any](data T) *WithJSON[T]

NewWrapper creates a new instance of withJSON

func (*WithJSON[T]) Clone

func (w *WithJSON[T]) Clone(empty bool) Wrapper[T]

Clone returns a new wrapper with a deep copy of the data

func (*WithJSON[T]) Get

func (w *WithJSON[T]) Get() T

Get returns the underlying data

func (*WithJSON[T]) MarshalJSON

func (w *WithJSON[T]) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*WithJSON[T]) Set

func (w *WithJSON[T]) Set(data T)

Set updates the underlying data

func (*WithJSON[T]) UnmarshalJSON

func (w *WithJSON[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type Wrapper

type Wrapper[T any] interface {
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
	Clone(bool) Wrapper[T]
	Get() T
	Set(data T)
}

Wrapper is an interface that provides JSON marshaling capabilities

Jump to

Keyboard shortcuts

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