Skip to main content

PlanRequest

Struct PlanRequest 

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

The 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

Source

pub fn new() -> PlanRequest

Creates a plan request that demands nothing and decides nothing.

Source

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.

Source

pub fn prefer(self, stage: impl Into<StageName>) -> PlanRequest

Adds stage to the preferred stages, after the ones already there, and returns the request.

Source

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.

Source

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.

Source

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

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 PlanRequest

Source§

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

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

impl Default for PlanRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for PlanRequest

§

impl !UnwindSafe for PlanRequest

§

impl Forget for PlanRequest

§

impl Freeze for PlanRequest
where *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 PlanRequest
where 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 PlanRequest
where 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 PlanRequest
where *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 PlanRequest

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.