pub struct PlanRequest {
pub demands: Vec<CapName>,
pub prefer: Vec<StageName>,
pub lowering: BTreeMap<BackendName, LoweringSelection>,
pub unsupported: BTreeMap<BackendName, Vec<ElementName>>,
pub render_options: OptionValues,
pub workflow: Option<WorkflowName>,
}Expand description
A plan request: everything a caller says about what it wants from a plan.
To demand a capability is to ask the plan for a stage that provides it; the
demands of a plan request are the capabilities it asks for, and a workflow is a
named set of demands together with the choices that go with them
(WorkflowDef). A capability is a
registered dotted name for a state of processing that a stage brings about
(CapabilityDef).
The request has five parts. The demands say what is wanted; the other four
fields decide how: which stage provides a capability several stages
provide, which lowering rule lowers an element several rules lower, which
elements a backend need not render, and which option values the render
request sets. These five fields, together with the registry,
decide the whole plan. The same fields are therefore what a stage can consult
while it states its needs (PlanCx), and what the
PlanKey is computed over.
The request also records the workflow it was made from, if any
(workflow). Plan building does not
consult that name; the errors and warnings of the plan name it, so that a
person reading them knows which workflow’s request they are about.
Create a request with PlanRequest::new and add to it with the methods that
take and return it, or set the public fields directly. Build the plan with
Plan::build, which checks that every name
in the request is registered. To start from a registered workflow instead, use
workflow_request or
Plan::for_workflow.
§Examples
use flm_core::core::plan::PlanRequest;
let request = PlanRequest::new()
.demand("flm.validated")
.prefer("flm.blocks.structure");
assert_eq!(request.demands.len(), 1);Fields§
§demands: Vec<CapName>The demanded capabilities. A name here may also be a collection, a name
for a set of capabilities
(CollectionDef): building the
plan replaces it with its members.
prefer: Vec<StageName>The stages to schedule where several stages could provide one
capability, most preferred first. A preference for a stage that provides
nothing the plan needs schedules nothing. A preference for a stage that the
plan had to rule out becomes a
PlanWarning::IgnoredPreference.
See selection for how a provider is
chosen.
lowering: BTreeMap<BackendName, LoweringSelection>The lowering rules to use where several rules could lower one element,
per backend, each list most preferred first. See
SelectedRules for how a rule is
chosen.
unsupported: BTreeMap<BackendName, Vec<ElementName>>The accepted unrenderable elements, per backend.
An accepted unrenderable element is an element the plan request lists, per
backend, as one the backend need not render: the plan builds anyway, and
each occurrence lowers to a childless flm.pres.unsupported node with one
Error diagnostic. Without this list, a backend that cannot render an element
a document may contain makes the plan build fail
(PlanError::Incomplete).
render_options: OptionValuesThe option values set on the render request. An option type is a plain
Rust struct a feature declares once, with a binding that says where its
values may be set (crate::model::options). A value here for an option
type whose binding does not admit the render request makes the plan build
fail (PlanError::RenderOption).
workflow: Option<WorkflowName>The workflow the request was made from, or None for a request a
program builds by hand. workflow_request
sets it. Plan building does not consult it: the errors and warnings of
the plan name the workflow in their messages, and the PlanKey leaves
it out, so that two workflows that produce the same request share a plan.
Implementations§
Source§impl PlanRequest
impl PlanRequest
Sourcepub fn new() -> PlanRequest
pub fn new() -> PlanRequest
Creates a plan request that demands nothing and decides nothing.
Sourcepub fn demand(self, capability: impl Into<CapName>) -> PlanRequest
pub fn demand(self, capability: impl Into<CapName>) -> PlanRequest
Adds capability to the demands, after the ones already there, and returns
the request. capability may also be the name of a collection, which
demands each of its members.
Sourcepub fn prefer(self, stage: impl Into<StageName>) -> PlanRequest
pub fn prefer(self, stage: impl Into<StageName>) -> PlanRequest
Adds stage to the preferred stages, after the ones already there, and
returns the request.
Sourcepub fn lowering(
self,
backend: impl Into<BackendName>,
selection: LoweringSelection,
) -> PlanRequest
pub fn lowering( self, backend: impl Into<BackendName>, selection: LoweringSelection, ) -> PlanRequest
Sets the lowering rules preferred on backend, replacing any selection
already set for that backend, and returns the request.
Sourcepub fn unsupported(
self,
backend: impl Into<BackendName>,
element: impl Into<ElementName>,
) -> PlanRequest
pub fn unsupported( self, backend: impl Into<BackendName>, element: impl Into<ElementName>, ) -> PlanRequest
Adds element to the accepted unrenderable elements of backend and
returns the request: the plan builds even though backend cannot render
element. See the unsupported
field.
Sourcepub fn render_options(self, options: OptionValues) -> PlanRequest
pub fn render_options(self, options: OptionValues) -> PlanRequest
Sets the option values of the render request, replacing any already set, and returns the request.
Trait Implementations§
Source§impl Clone for PlanRequest
impl Clone for PlanRequest
Source§impl Debug for PlanRequest
impl Debug for PlanRequest
Auto Trait Implementations§
impl !RefUnwindSafe for PlanRequest
impl !UnwindSafe for PlanRequest
impl Forget for PlanRequest
impl Freeze for PlanRequestwhere
*const u8 is !null: 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,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
impl Move for PlanRequest
impl Send for PlanRequestwhere
RawVecInner: Send,
Arc<str>: 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 PlanRequestwhere
RawVecInner: Sync,
Arc<str>: 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 PlanRequestwhere
*const u8 is !null: Unpin,
Arc<str>: 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 PlanRequestwhere
*const u8 is !null: 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,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: 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