1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//! The input of plan building: the plan request, the changes a caller makes to a
//! workflow's request, and the number that identifies a plan.
//!
//! - [`PlanRequest`] is everything a caller says about what it wants from a plan;
//! [`Plan::build`](crate::core::plan::Plan::build) builds the plan that satisfies
//! it.
//! - [`Overrides`] are the changes a caller makes to the request of a registered
//! workflow. Most callers never write a plan request: they choose a workflow by
//! name and let [`Plan::for_workflow`](crate::core::plan::Plan::for_workflow)
//! build its request, with these changes applied.
//! - [`PlanKey`] identifies a plan by everything it was built from, so that a
//! built plan can be cached and reused.
//!
//! A plan request holds nothing about any document. One plan therefore serves
//! every document rendered the same way. See [`crate::core::plan`] for the whole
//! process.
use BTreeMap;
use fmt;
use crate;
use crateOptionValues;
use crateLoweringSelection;
/// 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`](crate::core::registry::WorkflowDef)). A capability is a
/// registered dotted name for a state of processing that a stage brings about
/// ([`CapabilityDef`](crate::core::registry::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`](crate::core::plan::PlanCx)), and what the
/// [`PlanKey`] is computed over.
///
/// The request also records the workflow it was made from, if any
/// ([`workflow`](PlanRequest#structfield.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`](crate::core::plan::Plan::build), which checks that every name
/// in the request is registered. To start from a registered workflow instead, use
/// [`workflow_request`](crate::core::plan::workflow_request) or
/// [`Plan::for_workflow`](crate::core::plan::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);
/// ```
/// The changes a caller makes to the plan request of a registered workflow.
///
/// A workflow ([`WorkflowDef`](crate::core::registry::WorkflowDef)) is a named
/// set of demands together with the choices that go with them, held in the
/// registry as a complete plan request.
/// [`workflow_request`](crate::core::plan::workflow_request) turns it into a
/// [`PlanRequest`] and then applies these changes, and
/// [`Plan::for_workflow`](crate::core::plan::Plan::for_workflow) builds the result.
/// Each field combines with the workflow's own value as its documentation below
/// says, so that a caller adds to a workflow without restating it.
///
/// [`Overrides::none`] changes nothing.
/// The number that identifies a plan, computed over everything the plan was built
/// from.
///
/// The key is a digest of the registry's own digest, the demands (with
/// collections replaced by their members), the preferred stages, the lowering
/// selections, the accepted unrenderable elements and the option values of the
/// render request: everything that plan building consults, and nothing else. The
/// name of the workflow the request was made from is left out, since plan
/// building does not consult it: two workflows that produce the same request
/// share a plan. Two
/// plan requests with the same key against the same registry therefore build the
/// same plan, and a caller can cache a built plan under its key. Read a plan's key
/// with [`Plan::key`](crate::core::plan::Plan::key).
///
/// The key is displayed as sixteen hexadecimal digits.
;