pub struct WorkflowDef {
pub name: WorkflowName,
pub extends: Option<WorkflowName>,
pub outputs: Vec<OutputName>,
pub demands: Vec<CapName>,
pub prefer: Vec<StageName>,
pub lowering: BTreeMap<BackendName, LoweringSelection>,
pub unsupported: BTreeMap<BackendName, Vec<ElementName>>,
pub render_options: OptionValues,
pub docs: String,
}Expand description
A workflow declaration. A workflow is a named set of demands together with the choices that go with them: which outputs to produce, which other capabilities to demand, and how to make the choices a plan has to make.
A workflow is data held in the registry, so a caller chooses one by name
instead of writing a plan request by hand (the flm program’s option
-p html does so, the profile html running the workflow html). A plan request built from a workflow demands the
capability of each listed output and each extra capability, and carries the
workflow’s stage preferences, lowering selections, elements accepted as
unrenderable and render option values.
A workflow may extend another (extends). The fields are then read along
the chain from the workflow that extends none towards this one, and each
field is taken from the nearest workflow along the chain that declares it
(see replace_declared_fields): a
workflow that lists outputs replaces the inherited list instead of adding to
it, and a workflow that lists none inherits the whole list. A chain may not
lead back to a workflow already in it (BuildError::ExtendsCycle).
Register the declaration with
FeatureBuilder::workflow. A feature can
also change some fields of a workflow that another feature may declare, with
FeatureBuilder::workflow_fields.
FlmRegistry::combined_workflow
returns a workflow with the fields it inherits.
It is written to data with Serialize; see serialized
forms.
§Examples
use flm_core::core::registry::{LoweringSelection, WorkflowDef};
let base = WorkflowDef::new("check").demand("flm.validated");
let text = WorkflowDef::new("text")
.extends("check")
.output("text")
.lowering("text", LoweringSelection::new().prefer("flm.heading.lower.underline"));
assert_eq!(text.extends.as_deref().map(|n| n.as_str()), Some("check"));Fields§
§name: WorkflowNameThe workflow’s name, as a caller writes it.
extends: Option<WorkflowName>The workflow this one extends, if any: the workflow whose fields this one inherits where it does not declare its own.
outputs: Vec<OutputName>The outputs to produce; a plan built from the workflow demands the capability of each.
demands: Vec<CapName>The capabilities demanded besides those of the outputs, typically the checks to run as well. A collection may be listed here.
prefer: Vec<StageName>The stages preferred where several stages could provide the same capability, most preferred first.
lowering: BTreeMap<BackendName, LoweringSelection>The lowering rules preferred on each backend.
unsupported: BTreeMap<BackendName, Vec<ElementName>>For each backend, the elements this workflow accepts as unrenderable:
elements with no lowering into the backend’s native set. The plan is
built anyway, and each occurrence of such an element is lowered to a
flm.pres.unsupported node (see
PlanRequest::unsupported).
render_options: OptionValuesThe option values this workflow sets on the render request. The
registry build refuses a value whose option type no feature declares or
cannot be set on a render request (see
Bind).
docs: StringDocumentation prose.
Implementations§
Source§impl WorkflowDef
impl WorkflowDef
Sourcepub fn new(name: impl Into<WorkflowName>) -> WorkflowDef
pub fn new(name: impl Into<WorkflowName>) -> WorkflowDef
A workflow called name that extends nothing and declares no field.
Sourcepub fn extends(self, workflow: impl Into<WorkflowName>) -> WorkflowDef
pub fn extends(self, workflow: impl Into<WorkflowName>) -> WorkflowDef
Makes this workflow extend workflow, so that it inherits every field
it does not declare. Returns self, for chaining.
Sourcepub fn output(self, output: impl Into<OutputName>) -> WorkflowDef
pub fn output(self, output: impl Into<OutputName>) -> WorkflowDef
Adds an output to produce, after those already listed. Returns self,
for chaining.
Sourcepub fn demand(self, capability: impl Into<CapName>) -> WorkflowDef
pub fn demand(self, capability: impl Into<CapName>) -> WorkflowDef
Adds a capability (or a collection) to demand besides those of the
outputs. Returns self, for chaining.
Sourcepub fn prefer(self, stage: impl Into<StageName>) -> WorkflowDef
pub fn prefer(self, stage: impl Into<StageName>) -> WorkflowDef
Adds a preferred stage, after those already listed, as less preferred
than them. Returns self, for chaining.
Sourcepub fn lowering(
self,
backend: impl Into<BackendName>,
selection: LoweringSelection,
) -> WorkflowDef
pub fn lowering( self, backend: impl Into<BackendName>, selection: LoweringSelection, ) -> WorkflowDef
Sets the lowering selection for the backend backend, replacing any
selection already set for it. Returns self, for chaining.
Sourcepub fn unsupported(
self,
backend: impl Into<BackendName>,
element: impl Into<ElementName>,
) -> WorkflowDef
pub fn unsupported( self, backend: impl Into<BackendName>, element: impl Into<ElementName>, ) -> WorkflowDef
Accepts element as unrenderable on the backend backend: when the
element has no lowering into the backend’s native set, the plan is
built anyway and each occurrence is lowered to a
flm.pres.unsupported node. Returns self, for chaining.
Sourcepub fn render_options(self, options: OptionValues) -> WorkflowDef
pub fn render_options(self, options: OptionValues) -> WorkflowDef
Sets the option values this workflow sets on the render request,
replacing any values already set. Returns self, for chaining.
Sourcepub fn docs(self, docs: impl Into<String>) -> WorkflowDef
pub fn docs(self, docs: impl Into<String>) -> WorkflowDef
Sets the documentation prose. Returns self, for chaining.
Sourcepub fn replace_declared_fields(&mut self, other: WorkflowDef)
pub fn replace_declared_fields(&mut self, other: WorkflowDef)
Replaces each field of this workflow that other declares by other’s
value, and keeps this workflow’s name and every field that other
does not declare.
A field is declared when it is set: extends given, a list or a map
not empty, docs not empty. This is the rule by which a workflow
replaces the fields of the workflow it extends, and by which the fields
registered with
FeatureBuilder::workflow_fields
replace those of a workflow.
Trait Implementations§
Source§impl Clone for WorkflowDef
impl Clone for WorkflowDef
Source§impl Debug for WorkflowDef
impl Debug for WorkflowDef
Source§impl JsonSchema for WorkflowDef
impl JsonSchema for WorkflowDef
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for WorkflowDef
impl !UnwindSafe for WorkflowDef
impl Forget for WorkflowDef
impl Freeze for WorkflowDefwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<OutputName>: Freeze,
PhantomData<CapName>: Freeze,
PhantomData<StageName>: Freeze,
*const LeafNode<BackendName, LoweringSelection> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(BackendName, LoweringSelection)>>: Freeze,
*const LeafNode<BackendName, Vec<ElementName>> is !null: Freeze,
PhantomData<Box<(BackendName, Vec<ElementName>)>>: Freeze,
*const LeafNode<OptionKey, OptionValue> is !null: Freeze,
PhantomData<Box<(OptionKey, OptionValue)>>: Freeze,
PhantomData<u8>: Freeze,
impl Move for WorkflowDef
impl Send for WorkflowDefwhere
Arc<str>: Send,
RawVecInner: Send,
NodeRef<Owned, BackendName, LoweringSelection, LeafOrInternal>: Send,
BoxRaw<(BackendName, LoweringSelection)>: Send,
NodeRef<Owned, BackendName, Vec<ElementName>, LeafOrInternal>: Send,
BoxRaw<(BackendName, Vec<ElementName>)>: Send,
NodeRef<Owned, OptionKey, OptionValue, LeafOrInternal>: Send,
BoxRaw<(OptionKey, OptionValue)>: Send,
impl Sync for WorkflowDefwhere
Arc<str>: Sync,
RawVecInner: Sync,
NodeRef<Owned, BackendName, LoweringSelection, LeafOrInternal>: Sync,
BoxRaw<(BackendName, LoweringSelection)>: Sync,
NodeRef<Owned, BackendName, Vec<ElementName>, LeafOrInternal>: Sync,
BoxRaw<(BackendName, Vec<ElementName>)>: Sync,
NodeRef<Owned, OptionKey, OptionValue, LeafOrInternal>: Sync,
BoxRaw<(OptionKey, OptionValue)>: Sync,
impl Unpin for WorkflowDefwhere
Arc<str>: Unpin,
*const u8 is !null: Unpin,
*const LeafNode<BackendName, LoweringSelection> is !null: Unpin,
Box<(BackendName, LoweringSelection)>: Unpin,
*const LeafNode<BackendName, Vec<ElementName>> is !null: Unpin,
Box<(BackendName, Vec<ElementName>)>: Unpin,
*const LeafNode<OptionKey, OptionValue> is !null: Unpin,
Box<(OptionKey, OptionValue)>: Unpin,
impl UnsafeUnpin for WorkflowDefwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<OutputName>: UnsafeUnpin,
PhantomData<CapName>: UnsafeUnpin,
PhantomData<StageName>: UnsafeUnpin,
*const LeafNode<BackendName, LoweringSelection> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(BackendName, LoweringSelection)>>: UnsafeUnpin,
*const LeafNode<BackendName, Vec<ElementName>> is !null: UnsafeUnpin,
PhantomData<Box<(BackendName, Vec<ElementName>)>>: UnsafeUnpin,
*const LeafNode<OptionKey, OptionValue> is !null: UnsafeUnpin,
PhantomData<Box<(OptionKey, OptionValue)>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more