Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn head(&self, name: &str) -> Result<Option<Head>>;
    fn swap_head(
        &self,
        name: &str,
        expected: Option<&Head>,
        new: &Head,
    ) -> Result<()>;
    fn put_version(&self, name: &str, version: &Version) -> Result<()>;
    fn version(&self, name: &str, digest: &str) -> Result<Option<Version>>;
    fn names(&self) -> Result<Vec<String>>;
    fn start_run(&self, name: &str, run: &Run) -> Result<u64>;
    fn finish_run(&self, name: &str, run: &Run) -> Result<()>;
    fn run(&self, name: &str, id: u64) -> Result<Option<Run>>;
    fn last_run(&self, name: &str) -> Result<Option<Run>>;
}
Expand description

Where a host keeps its scripts. Every method is called from inside an endpoint, so an implementation must not block for long; both built-ins are synchronous and local.

Required Methods§

Source

fn head(&self, name: &str) -> Result<Option<Head>>

The head of name, or None when no such script exists.

Source

fn swap_head( &self, name: &str, expected: Option<&Head>, new: &Head, ) -> Result<()>

Replace the head of name with new, if it is still expected (None: if no head exists yet). Otherwise a typed Conflict: someone got there first.

Source

fn put_version(&self, name: &str, version: &Version) -> Result<()>

Store a version under name. Idempotent: a version is its content.

Source

fn version(&self, name: &str, digest: &str) -> Result<Option<Version>>

The version digest of name, or None. An implementation verifies the content against the digest and refuses a mismatch.

Source

fn names(&self) -> Result<Vec<String>>

Every script name that has a head, sorted.

Source

fn start_run(&self, name: &str, run: &Run) -> Result<u64>

Record a run that is starting, under a fresh id (the id field is ignored), and return the id.

Source

fn finish_run(&self, name: &str, run: &Run) -> Result<()>

Replace the record of a run already started.

Source

fn run(&self, name: &str, id: u64) -> Result<Option<Run>>

Run id of name, or None.

Source

fn last_run(&self, name: &str) -> Result<Option<Run>>

The run of name with the highest id, or None.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§