patch

package module
v0.0.0-...-dedce4b Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 2 Imported by: 0

README

smartpatch

Golang library for making consistent patching of structured data easier

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OptionalPatcher

type OptionalPatcher[T comparable] struct {
	// contains filtered or unexported fields
}

func NewOptionalPatcher

func NewOptionalPatcher[T comparable](target optional.Optional[T], patch Patch[T]) *OptionalPatcher[T]

func (*OptionalPatcher[T]) Apply

func (p *OptionalPatcher[T]) Apply() error

func (OptionalPatcher[T]) IsNoop

func (p OptionalPatcher[T]) IsNoop() bool

type Patch

type Patch[T comparable] interface {
	IsNoop(T) bool
	IsNoopOption(optional.Option[T]) bool
	Apply(*T) error
	ApplyOption(optional.Option[T]) error
}

type PatchAction

type PatchAction int
const (
	Noop PatchAction = iota
	Remove
	Replace
)

type PatchField

type PatchField[T comparable] struct {
	// contains filtered or unexported fields
}

func GetFieldPatch

func GetFieldPatch[T comparable](old, updated T) PatchField[T]

func GetOptionFieldPatch

func GetOptionFieldPatch[T comparable](old, updated optional.Optional[T]) PatchField[T]

func NewNoop

func NewNoop[T comparable]() PatchField[T]

func NewRemoval

func NewRemoval[T comparable]() PatchField[T]

func NewReplace

func NewReplace[T comparable](updated T) PatchField[T]

func (PatchField[T]) Action

func (p PatchField[T]) Action() PatchAction

func (PatchField[T]) Apply

func (p PatchField[T]) Apply(operand *T) error

func (PatchField[T]) ApplyOption

func (p PatchField[T]) ApplyOption(current optional.Optional[T]) error

func (PatchField[T]) IsNoop

func (p PatchField[T]) IsNoop(current T) bool

func (PatchField[T]) IsNoopOption

func (p PatchField[T]) IsNoopOption(current optional.Optional[T]) bool

func (PatchField[T]) Peek

func (p PatchField[T]) Peek() optional.Optional[T]

type PatchFunc

type PatchFunc[T comparable] func(left, right T) error

type PatchMap

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

func NewPatchMap

func NewPatchMap() *PatchMap

func (*PatchMap) Append

func (m *PatchMap) Append(label string, patch Patcher) error

func (*PatchMap) Apply

func (m *PatchMap) Apply(label any) error

func (*PatchMap) ApplyAll

func (m *PatchMap) ApplyAll() error

func (*PatchMap) IsAllNoop

func (m *PatchMap) IsAllNoop() bool

func (*PatchMap) IsNoop

func (m *PatchMap) IsNoop(label any) (bool, error)

type PatchSet

type PatchSet interface {
	IsNoop(any) (bool, error)
	Apply(any) error
	IsAllNoop() bool
	ApplyAll() error
}

type Patchable

type Patchable[Self comparable, P Patch[Self]] interface {
	WithPatch(P) (Self, error)
	Patch(P) error
}

type Patcher

type Patcher interface {
	IsNoop() bool
	Apply() error
}

type PrimativePatch

type PrimativePatch[T comparable] interface {
	Patch[T]
	Action() PatchAction
	Peek() optional.Option[T]
}

type ValuePatcher

type ValuePatcher[T comparable] struct {
	// contains filtered or unexported fields
}

func NewValuePatcher

func NewValuePatcher[T comparable](target *T, patch Patch[T]) *ValuePatcher[T]

func (*ValuePatcher[T]) Apply

func (p *ValuePatcher[T]) Apply() error

func (ValuePatcher[T]) IsNoop

func (p ValuePatcher[T]) IsNoop() bool

Jump to

Keyboard shortcuts

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