pub struct PassManager {
pub registry: PassRegistry,
/* private fields */
}Expand description
Runs the pipelines a program states and verifies the world between steps.
Fields§
§registry: PassRegistryImplementations§
Source§impl PassManager
impl PassManager
pub fn new(registry: PassRegistry) -> Self
Sourcepub fn with_settings(self, settings: Settings) -> Self
pub fn with_settings(self, settings: Settings) -> Self
State the program’s run settings: before every pipeline it runs, plain or a conversion’s part, the manager
states them in the world, and a pass that declares a setting (Pass::settings) reads it there. A manager that
states none runs only passes that read none (another is refused, Error::Missing); a world that already
states a setting otherwise is refused (Error::SettingDisagrees).
Sourcepub fn with_pass_checks(self, on: bool) -> Self
pub fn with_pass_checks(self, on: bool) -> Self
The pass checks, after every pass: its effects entity by entity against its declarations (what it adds to or
takes from an entity, what it despawns, the resources it writes: Pass::provides, Pass::removes,
Pass::modifies), then the verifier (Component::verify, crate::Resource::verify, the validators) on
what it leaves. On in debug builds (the test suites); off by default in release builds, for speed, so a pass
that leaves an invalid component is not named there unless the program opts in with true. Measured on a
level of 16,000 placements (12 passes, release): the verifier 0.26 s and the declaration diff another
0.46 s, against 1.6 s of passes. What a pass’s names do across the whole world is checked either way, and a
conversion (PassManager::convert) verifies the reader’s output and the world before its writer either way.
The in-place edits of values on entities that keep the name are not in the declaration diff in any build
(Pass::modifies); only the verifier sees their result, and only after the pass when the checks are on.
pub fn pass_checks(&self) -> bool
Sourcepub fn with_missing_inputs(self, policy: MissingInputs) -> Self
pub fn with_missing_inputs(self, policy: MissingInputs) -> Self
State how to handle unfed preparation steps. Skipping never supplies default data or
calls an unfed pass: its StepReport::skipped lists the absent names, and later steps
inspect the world actually left by earlier steps. The default remains strict refusal.
Sourcepub fn with_conservation(self, c: Conservation) -> Self
pub fn with_conservation(self, c: Conservation) -> Self
Run the conservation diagnostics around every pass (crate::ledger): off by default.
pub fn conservation(&self) -> Conservation
pub fn add_validator(&mut self, v: Box<dyn Validator>)
Sourcepub fn verify(&self, w: &World, after: &str) -> Result<()>
pub fn verify(&self, w: &World, after: &str) -> Result<()>
Every component’s own checks and every world validator. after names the step for the error.
Sourcepub fn run(
&self,
w: &mut World,
pipeline: &Pipeline,
report: &mut RunReport,
) -> Result<()>
pub fn run( &self, w: &mut World, pipeline: &Pipeline, report: &mut RunReport, ) -> Result<()>
Run a pipeline as written, verifying after every pass and checking each pass’s declarations.
Sourcepub fn run_instrumented(
&self,
w: &mut World,
pipeline: &Pipeline,
report: &mut RunReport,
instrument: &mut dyn Instrument,
) -> Result<()>
pub fn run_instrumented( &self, w: &mut World, pipeline: &Pipeline, report: &mut RunReport, instrument: &mut dyn Instrument, ) -> Result<()>
PassManager::run, calling instrument around every pass.
Sourcepub fn run_part(
&self,
w: &mut World,
pipeline: &Pipeline,
report: &mut RunReport,
) -> Result<()>
pub fn run_part( &self, w: &mut World, pipeline: &Pipeline, report: &mut RunReport, ) -> Result<()>
PassManager::run on one part of a conversion (crate::convert), with the same rule as any run: a pass that
opts in (Pass::may_lack_inputs), requires names and finds none of them has nothing to do there and is
skipped, recorded (its step’s StepReport::skipped, a SKIPPED count in its log). Any other pass whose
required names are absent fails, as does an opted-in pass that finds some of them but not all; a pass that
requires nothing always runs. An explicit MissingInputs::Skip policy also skips
other unfed steps, retaining their missing names in the report.
Sourcepub fn convert(
&self,
w: &mut World,
pipeline: &Pipeline,
target: &Target,
mode: Mode,
) -> Result<RunReport>
pub fn convert( &self, w: &mut World, pipeline: &Pipeline, target: &Target, mode: Mode, ) -> Result<RunReport>
Run the stated pipeline and check the world it leaves against target: verify the reader’s world, run the
pipeline as written (verifying after every pass with the pass checks), then check that the target accepts every
component and resource in mode, and verify once more before the writer. A name the target still refuses is
Error::Illegal, naming the passes of the pipeline that remove or rewrite it, or none: the manager never adds a
pass to lower it.
Sourcepub fn convert_instrumented(
&self,
w: &mut World,
pipeline: &Pipeline,
target: &Target,
mode: Mode,
instrument: &mut dyn Instrument,
) -> Result<RunReport>
pub fn convert_instrumented( &self, w: &mut World, pipeline: &Pipeline, target: &Target, mode: Mode, instrument: &mut dyn Instrument, ) -> Result<RunReport>
PassManager::convert, calling instrument around every pass of the pipeline.