task

package
v0.0.0-...-cbd24a7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc func(int, Task) bool

type List

type List []Task

func (List) Filter

func (ls List) Filter(f FilterFunc) List

Filter returns a list with all tasks from ls that passed the predicate f.

func (List) Map

func (ls List) Map(f MapFunc) List

Map returns a list where all nodes from ls are applied by f.

type MapFunc

type MapFunc func(int, Task) Task

type Prop

type Prop interface {
	fmt.Stringer
	json.Marshaler
	json.Unmarshaler

	// Store sets the property value from the given string.
	Store(string) error
	// Match returns whether the property matches the given expression.
	Match(string) bool
	// Kind returns the property kind.
	Kind() PropKind
}

Prop is a general interface for the different kinds of properties.

func NewProp

func NewProp(kind PropKind) (Prop, error)

NewProp returns a new property of the specified kind.

type PropError

type PropError struct {
	Name string
	Err  error
}

func (*PropError) Error

func (e *PropError) Error() string

type PropKind

type PropKind = string
const (
	PKindString  PropKind = "string"
	PKindStrings PropKind = "strings"
	PKindNumber  PropKind = "number"
	PKindTime    PropKind = "time"
)

type PropKindInvalidError

type PropKindInvalidError struct {
	Kind PropKind
}

func (*PropKindInvalidError) Error

func (e *PropKindInvalidError) Error() string

type PropNoExistError

type PropNoExistError struct {
	Name string
}

func (*PropNoExistError) Error

func (e *PropNoExistError) Error() string

type PropNumber

type PropNumber struct {
	Value float64
}

PropNumber is a property with the float64 type.

func (*PropNumber) Kind

func (p *PropNumber) Kind() PropKind

func (*PropNumber) MarshalJSON

func (p *PropNumber) MarshalJSON() ([]byte, error)

func (*PropNumber) Match

func (p *PropNumber) Match(s string) bool

func (*PropNumber) Store

func (p *PropNumber) Store(s string) error

func (*PropNumber) String

func (p *PropNumber) String() string

func (*PropNumber) UnmarshalJSON

func (p *PropNumber) UnmarshalJSON(data []byte) error

type PropString

type PropString struct {
	Value string
}

PropString is a property with the string type.

func (*PropString) Kind

func (p *PropString) Kind() PropKind

func (*PropString) MarshalJSON

func (p *PropString) MarshalJSON() ([]byte, error)

func (*PropString) Match

func (p *PropString) Match(s string) bool

func (*PropString) Store

func (p *PropString) Store(s string) error

func (*PropString) String

func (p *PropString) String() string

func (*PropString) UnmarshalJSON

func (p *PropString) UnmarshalJSON(data []byte) error

type PropStrings

type PropStrings struct {
	Value []string
}

PropStrings is a property with the string slice type.

func (*PropStrings) Kind

func (p *PropStrings) Kind() PropKind

func (*PropStrings) MarshalJSON

func (p *PropStrings) MarshalJSON() ([]byte, error)

func (*PropStrings) Match

func (p *PropStrings) Match(s string) bool

func (*PropStrings) Store

func (p *PropStrings) Store(s string) error

func (*PropStrings) String

func (p *PropStrings) String() string

func (*PropStrings) UnmarshalJSON

func (p *PropStrings) UnmarshalJSON(data []byte) error

type PropTime

type PropTime struct {
	Value time.Time
}

PropTime is a property with the time.Time type.

func (*PropTime) Kind

func (p *PropTime) Kind() PropKind

func (*PropTime) MarshalJSON

func (p *PropTime) MarshalJSON() ([]byte, error)

func (*PropTime) Match

func (p *PropTime) Match(s string) bool

func (*PropTime) Store

func (p *PropTime) Store(s string) error

func (*PropTime) String

func (p *PropTime) String() string

func (*PropTime) UnmarshalJSON

func (p *PropTime) UnmarshalJSON(data []byte) error

type Rule

type Rule struct {
	Kind PropKind `json:"kind"`
}

A Rule defines the requirements of a property.

type RuleNoExistError

type RuleNoExistError struct {
	Name string
}

func (*RuleNoExistError) Error

func (e *RuleNoExistError) Error() string

type Schema

type Schema map[string]Rule

A Schema is a map of property names and their rules.

func (*Schema) Check

func (s *Schema) Check(name, value string) error

Check verifies the given property name and value with the corresponding rule.

type Task

type Task map[string]Prop

A Task contains a map of its properties.

func (*Task) Delete

func (t *Task) Delete(names ...string)

Delete removes the specified property names from t.

func (*Task) MarshalJSON

func (t *Task) MarshalJSON() ([]byte, error)

func (*Task) Number

func (t *Task) Number(name string) (float64, error)

Number returns the float64 value of the property name.

func (*Task) Store

func (t *Task) Store(name, value string, kind PropKind) (err error)

Store sets the value of the given property name based on its kind.

func (*Task) String

func (t *Task) String(name string) (string, error)

String returns the string value of the property name.

func (*Task) Strings

func (t *Task) Strings(name string) ([]string, error)

Strings returns the []string value of the property name.

func (*Task) UnmarshalJSON

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

type TimeFunc

type TimeFunc func() time.Time

type TimeLayoutError

type TimeLayoutError struct {
	Value string
}

func (*TimeLayoutError) Error

func (e *TimeLayoutError) Error() string

Jump to

Keyboard shortcuts

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