Skip to main content

FixPasses

Trait FixPasses 

Source
pub trait FixPasses {
    // Required methods
    fn run_pass(&mut self, candidate_version: usize) -> PassResult;
    fn apply(&mut self, snapshot: usize) -> bool;
    fn snapshots_equal(&mut self, left: usize, right: usize) -> bool;
}
Expand description

What: The work the loop drives. A trait is a named set of methods a type promises to provide, like a TS interface; &mut self lends the implementer for writing. Why: Exact candidate states can be large, so the implementer stores them (the incumbent used private files) and answers equality by snapshot number; the loop never holds content. Gotcha: Snapshot 0 is the state before the first pass and must exist before the loop starts.

In TS you’d write (pseudocode):

interface FixPasses { runPass(version: number): PassResult; apply(snapshot: number): boolean; snapshotsEqual(a: number, b: number): boolean }

Required Methods§

Source

fn run_pass(&mut self, candidate_version: usize) -> PassResult

Run every policy against the current state; candidate_version counts earlier changes.

Source

fn apply(&mut self, snapshot: usize) -> bool

Apply the last pass’s corrections and store the new exact state under snapshot. Returns false when the corrections could not be applied.

Source

fn snapshots_equal(&mut self, left: usize, right: usize) -> bool

Whether two stored states are equal byte for byte.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F: RepositoryFacts> FixPasses for DirectFixPasses<'_, F>

What: impl FixPasses for DirectFixPasses<'_, F> gives the loop its three operations. Why: The loop is tested without Git; these are the real passes.

In TS you’d write (pseudocode):

class DirectFixPasses implements FixPasses {}