element

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability string

Capability defines what a type can do.

const (
	CapRead     Capability = "read"
	CapWrite    Capability = "write"
	CapIncDec   Capability = "inc_dec"
	CapToggle   Capability = "toggle"
	CapTextEdit Capability = "text_edit"
)

type Property

type Property interface {
	// Descriptor returns metadata about the property.
	Descriptor() PropertyDescriptor

	// LoadValue returns the current value as an interface{}.
	LoadValue() interface{}

	// StoreValue sets the value. It assumes the value is valid.
	StoreValue(val interface{}) error

	// Parse converts a string to the underlying value type.
	Parse(valStr string) (interface{}, error)

	// SetFromString parses and sets the value from a string.
	// This is the primary entry point for TUI edits.
	SetFromString(valStr string) error

	// Validate checks if a value is valid without setting it.
	// Used for pre-flight checks.
	Validate(val interface{}) error
}

Property is the interface that all exposed types must implement. This decouples the Bridge from specific atomic implementations.

type PropertyDescriptor

type PropertyDescriptor struct {
	Name         string       // Variable name (Admin Label)
	Type         string       // Go Type (e.g., "int", "*atomic.Int")
	Capabilities []Capability // List of supported actions
}

PropertyDescriptor holds metadata about an exposed variable.

type ValidatedProperty

type ValidatedProperty struct {
	Property
	// contains filtered or unexported fields
}

ValidatedProperty wraps a Property and enforces constraints.

func NewValidatedProperty

func NewValidatedProperty(p Property, validators ...Validator) *ValidatedProperty

func (*ValidatedProperty) SetFromString

func (vp *ValidatedProperty) SetFromString(valStr string) error

SetFromString validates before storing.

func (*ValidatedProperty) StoreValue

func (vp *ValidatedProperty) StoreValue(val interface{}) error

StoreValue validates before storing.

func (*ValidatedProperty) Validate

func (vp *ValidatedProperty) Validate(val interface{}) error

Validate calls internal property validation AND external validators.

type Validator

type Validator func(val interface{}) error

Validator is a function that checks if a value is safe.

func RangeValidator

func RangeValidator(min, max int) Validator

Basic Range Validator

Jump to

Keyboard shortcuts

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