Skip to main content

AuditBackend

Trait AuditBackend 

Source
pub trait AuditBackend: Sync {
    type Analyses: AuditAnalyses + Send;
    type Checkout: BaseCheckout;
    type CacheKey: Sync;
    type Error: Send;

    // Required methods
    fn run_head(
        &self,
        changed_files: &FxHashSet<PathBuf>,
    ) -> Result<Self::Analyses, Self::Error>;
    fn create_base_checkout(
        &self,
        base_ref: &str,
        base_sha: Option<&str>,
    ) -> Result<Self::Checkout, Self::Error>;
    fn run_base(
        &self,
        base_root: &Path,
        focus: Option<&FxHashSet<PathBuf>>,
    ) -> Result<Self::Analyses, Self::Error>;

    // Provided methods
    fn prepare(&self) { ... }
    fn base_cache_key(
        &self,
        _base_ref: &str,
        _focus: &FxHashSet<PathBuf>,
    ) -> Result<Option<Self::CacheKey>, Self::Error> { ... }
    fn cached_base_sha<'k>(&self, _key: &'k Self::CacheKey) -> Option<&'k str> { ... }
    fn load_cached_base(
        &self,
        _key: &Self::CacheKey,
    ) -> Option<AuditKeySnapshot> { ... }
    fn save_cached_base(
        &self,
        _key: &Self::CacheKey,
        _snapshot: &AuditKeySnapshot,
    ) { ... }
    fn shared_diff(&self) -> Option<SharedDiff<'_>> { ... }
}
Expand description

How one surface runs the analyses of an audit.

Required Associated Types§

Source

type Analyses: AuditAnalyses + Send

The analyses of one side.

Source

type Checkout: BaseCheckout

A checkout of the base commit. The base pass keeps it until the base analyses complete.

Source

type CacheKey: Sync

Key of a cached base snapshot.

Source

type Error: Send

The error of the surface.

Required Methods§

Source

fn run_head( &self, changed_files: &FxHashSet<PathBuf>, ) -> Result<Self::Analyses, Self::Error>

Run the head analyses, scoped to changed_files.

§Errors

Returns the surface error when an analysis fails.

Source

fn create_base_checkout( &self, base_ref: &str, base_sha: Option<&str>, ) -> Result<Self::Checkout, Self::Error>

Create a checkout of base_ref. base_sha is the full SHA when a cache key resolved it.

§Errors

Returns the surface error when the checkout cannot be created.

Source

fn run_base( &self, base_root: &Path, focus: Option<&FxHashSet<PathBuf>>, ) -> Result<Self::Analyses, Self::Error>

Run the base analyses in base_root. With focus, scope the findings to those files; without it, leave them unscoped.

§Errors

Returns the surface error when an analysis fails.

Provided Methods§

Source

fn prepare(&self)

Called once when the run has changed files, before any base work.

Source

fn base_cache_key( &self, _base_ref: &str, _focus: &FxHashSet<PathBuf>, ) -> Result<Option<Self::CacheKey>, Self::Error>

The cache key of the base snapshot for base_ref and focus, or None when the surface keeps no cache.

§Errors

Returns the surface error when the key inputs cannot be read.

Source

fn cached_base_sha<'k>(&self, _key: &'k Self::CacheKey) -> Option<&'k str>

The full base SHA that key records.

Source

fn load_cached_base(&self, _key: &Self::CacheKey) -> Option<AuditKeySnapshot>

A cached base snapshot for key.

Source

fn save_cached_base(&self, _key: &Self::CacheKey, _snapshot: &AuditKeySnapshot)

Store a fresh base snapshot under key.

Source

fn shared_diff(&self) -> Option<SharedDiff<'_>>

The opt-in shared diff of the run, when one is active.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§