target

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: LGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func NewBool(b bool) Target

NewBool creates the boolean-true target when b is true; false is not a valid pipeline target and fails to encode.

func NewRect

func NewRect(r rect.Rect) Target

NewRect creates a target for an explicit rectangle.

func NewString

func NewString(s string) Target

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) AsBool

func (t Target) AsBool() (bool, error)

AsBool returns the boolean value; it fails if the target does not hold one.

func (Target) AsRect

func (t Target) AsRect() (rect.Rect, error)

AsRect returns the rectangle; it fails if the target does not hold one.

func (Target) AsString

func (t Target) AsString() (string, error)

AsString returns the node or anchor name; it fails if the target does not hold a string.

func (Target) IsBool

func (t Target) IsBool() bool

IsBool reports whether the target holds the boolean true.

func (Target) IsRect

func (t Target) IsRect() bool

IsRect reports whether the target holds a rectangle.

func (Target) IsString

func (t Target) IsString() bool

IsString reports whether the target holds a node or anchor name.

func (Target) IsZero

func (t Target) IsZero() bool

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

func (t Target) MarshalJSON() ([]byte, error)

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

func (t *Target) UnmarshalJSON(data []byte) error

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.

Jump to

Keyboard shortcuts

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