heron_rebuild_workflow/
lib.rs

1mod strings;
2pub use strings::WorkflowStrings;
3
4mod value;
5pub use value::{BaseValue, DirectValue, Value};
6
7mod task;
8pub use task::{Task, TaskVars};
9
10mod plan;
11pub use plan::{Plan, Subplan};
12
13mod branch;
14pub use branch::{BaselineBranches, BranchSpec};
15
16mod id;
17pub use id::{
18    AbstractTaskId, AbstractValueId, BranchpointId, IdentId, LiteralId, ModuleId, RealTaskId,
19    RealValueId, RunStrId, NULL_IDENT,
20};
21
22mod error;
23pub use error::{Errors, Recap, Recapper};
24
25mod workflow;
26pub use workflow::{SizeHints, Workflow};
27
28mod string_cache;
29pub use string_cache::{StringCache, StringMaker};
30
31mod real_task;
32pub use real_task::{RealTaskKey, RealTaskStrings};
33
34// used to separate branchpoint from branch value e.g. "Profile.debug"
35pub const BRANCH_KV_DELIM: char = '.';
36// used to separate multiple branchpoint/value pairs e.g. "Profile.debug+Os.windows"
37pub const BRANCH_DELIM: char = '+';
38
39#[derive(thiserror::Error, Debug)]
40pub enum Error {
41    #[error("Unsupported feature: {0}")]
42    Unsupported(String),
43    #[error("Plan not found: {0:?}")]
44    PlanNotFound(IdentId),
45    #[error("Task defines multiple modules with '@'. Only one module is allowed.")]
46    MultipleModulesDefined,
47    #[error("Dot parameters (\".var\") are not yet supported")]
48    DotParamsUnsupported,
49    #[error("Unable to interpolate \"{0}\" into \"{1}\"")]
50    Interp(String, String),
51    #[error("Plan is empty: '{0}'")]
52    EmptyPlan(String),
53    #[error("Module not found: {0:?}")]
54    ModuleNotFound(ModuleId),
55    #[error("Task not found: {0:?}")]
56    TaskNotFound(AbstractTaskId),
57    #[error("Value not found: {0:?}")]
58    ValueNotFound(AbstractValueId),
59}
60
61impl Recap for Error {
62    fn recap(&self, wf: &WorkflowStrings) -> anyhow::Result<Option<String>> {
63        use intern::GetStr;
64        match self {
65            Self::ModuleNotFound(id) => {
66                Ok(Some(format!("Module not found: {}", wf.modules.get(*id)?)))
67            }
68            Self::TaskNotFound(id) => Ok(Some(format!("Task not found: {}", wf.tasks.get(*id)?))),
69            Self::PlanNotFound(id) => Ok(Some(format!(
70                "Plan not found in config file: {}",
71                wf.idents.get(*id)?
72            ))),
73            _ => Ok(None),
74        }
75    }
76}