Skip to main content

WorkflowDef

Struct WorkflowDef 

Source
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: WorkflowName

The 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: OptionValues

The 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: String

Documentation prose.

Implementations§

Source§

impl WorkflowDef

Source

pub fn new(name: impl Into<WorkflowName>) -> WorkflowDef

A workflow called name that extends nothing and declares no field.

Source

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.

Source

pub fn output(self, output: impl Into<OutputName>) -> WorkflowDef

Adds an output to produce, after those already listed. Returns self, for chaining.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn docs(self, docs: impl Into<String>) -> WorkflowDef

Sets the documentation prose. Returns self, for chaining.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkflowDef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl JsonSchema for WorkflowDef

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for WorkflowDef

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for WorkflowDef

§

impl !UnwindSafe for WorkflowDef

§

impl Forget for WorkflowDef

§

impl Freeze for WorkflowDef

§

impl Move for WorkflowDef

§

impl Send for WorkflowDef
where 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 WorkflowDef
where 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 WorkflowDef
where 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 WorkflowDef

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.