pub enum TaskRef {
SameProject(TaskName),
Project(ProjectName, TaskName),
FanOut(TaskName),
SiblingFanOut(TaskName),
Tag(TagName, TaskName),
SiblingTag(TagName, TaskName),
}Expand description
A validated task reference.
Construction is via TaskRef::parse. The fmt::Display
implementation produces a string that round-trips through
TaskRef::parse.
§Examples
use haz_domain::task_ref::TaskRef;
let r = TaskRef::parse("~:compile").unwrap();
assert_eq!(r.to_string(), "~:compile");
let r = TaskRef::parse("[typescript]:compile").unwrap();
assert_eq!(r.to_string(), "[typescript]:compile");Variants§
SameProject(TaskName)
~:<task>. Resolves within the bearing project (REF-002).
Project(ProjectName, TaskName)
<project>:<task>. Resolves to a task in the named project
(REF-003).
FanOut(TaskName)
^:<task>. Resolves to every task with this name across the
workspace, including the bearing project (REF-004).
SiblingFanOut(TaskName)
^~:<task>. Resolves to every task with this name across the
workspace except the bearing project (REF-008).
Tag(TagName, TaskName)
[<tag>]:<task>. Resolves to every task with this name
whose project carries the named tag, including the bearing
project (REF-005).
SiblingTag(TagName, TaskName)
[<tag>]~:<task>. Resolves to every task with this name
whose project carries the named tag, excluding the bearing
project even if it carries the named tag (REF-008).
Implementations§
Source§impl TaskRef
impl TaskRef
Sourcepub fn parse(s: &str) -> Result<Self, TaskRefError>
pub fn parse(s: &str) -> Result<Self, TaskRefError>
Parse s as a TaskRef.
Dispatch follows REF-006: at most three characters of
lookahead for ^-prefixed forms, plus scanning past the
closing ] for tag forms.
§Errors
Returns a TaskRefError when s violates the grammar
(REF-002..REF-006, REF-008) or when any name component
violates the identifier rules (REF-001, delegating to
ID-001..ID-003):
TaskRefError::EmptyInputifsis the empty string.TaskRefError::MissingColonifsis a project reference with no:separator.TaskRefError::MalformedTagBracketsifsbegins with[but is not a well-formed[<tag>]:<task>or[<tag>]~:<task>.TaskRefError::InvalidNameif any name component is not a valid identifier.
§Examples
use haz_domain::task_ref::TaskRef;
assert!(TaskRef::parse("~:compile").is_ok());
assert!(TaskRef::parse("lib_core:compile").is_ok());
assert!(TaskRef::parse("^:compile").is_ok());
assert!(TaskRef::parse("^~:compile").is_ok());
assert!(TaskRef::parse("[typescript]:compile").is_ok());
assert!(TaskRef::parse("[typescript]~:compile").is_ok());
assert!(TaskRef::parse("").is_err());
assert!(TaskRef::parse("compile").is_err());
assert!(TaskRef::parse("[tag]compile").is_err());
assert!(TaskRef::parse("[tag]~compile").is_err());Sourcepub fn is_same_project(&self) -> bool
pub fn is_same_project(&self) -> bool
true if this is a same-project reference (~:<task>).
Sourcepub fn is_project(&self) -> bool
pub fn is_project(&self) -> bool
true if this is a project reference (<project>:<task>).
Sourcepub fn is_fan_out(&self) -> bool
pub fn is_fan_out(&self) -> bool
true if this is a fan-out reference (^:<task>).
Sourcepub fn is_sibling_fan_out(&self) -> bool
pub fn is_sibling_fan_out(&self) -> bool
true if this is a sibling-fan-out reference (^~:<task>).
Sourcepub fn is_sibling_tag(&self) -> bool
pub fn is_sibling_tag(&self) -> bool
true if this is a sibling-tag reference ([<tag>]~:<task>).