Documentation
¶
Overview ¶
Package target implements the pipeline v2 target wire type: a variant that is either the boolean true, a node or [Anchor] name, or a rectangle.
Index ¶
- type Target
- func (t Target) AsBool() (bool, error)
- func (t Target) AsRect() (rect.Rect, error)
- func (t Target) AsString() (string, error)
- func (t Target) IsBool() bool
- func (t Target) IsRect() bool
- func (t Target) IsString() bool
- func (t Target) IsZero() bool
- func (t Target) MarshalJSON() ([]byte, error)
- func (t *Target) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target is a type-safe variant that can hold one of three value types: bool, string, or rect.Rect. It provides methods for type checking, safe value retrieval, and JSON serialization/deserialization.
func NewBool ¶
NewBool creates the boolean-true target when b is true; false is not a valid pipeline target and fails to encode.
func NewString ¶
NewString creates a target that refers to a node name or an [Anchor]-prefixed anchor name. The string is passed through as-is; syntax is validated when the pipeline is parsed.
func (Target) AsString ¶
AsString returns the node or anchor name; it fails if the target does not hold a string.
func (Target) IsZero ¶
IsZero reports whether the target is the zero Target, which carries no value: it is omitted by the encoding/json "omitzero" option and fails to encode standalone.
func (Target) MarshalJSON ¶
MarshalJSON encodes the target: the boolean true as JSON true, a string as a JSON string, and a rectangle as a four-element array. A zero target and a wrapped false are not valid pipeline targets and fail to encode.
func (*Target) UnmarshalJSON ¶
UnmarshalJSON decodes the JSON boolean true, a string, or an integer array of two elements (a point, normalized to a 1x1 rectangle) or four elements (a rectangle). null, false, numbers, objects, other lengths, and non-integer or null elements are errors; on error the target is left unchanged.