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§
Sourcefn head(&self, name: &str) -> Result<Option<Head>>
fn head(&self, name: &str) -> Result<Option<Head>>
The head of name, or None when no such script exists.
Sourcefn swap_head(
&self,
name: &str,
expected: Option<&Head>,
new: &Head,
) -> Result<()>
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.
Sourcefn put_version(&self, name: &str, version: &Version) -> Result<()>
fn put_version(&self, name: &str, version: &Version) -> Result<()>
Store a version under name. Idempotent: a version is its content.
Sourcefn version(&self, name: &str, digest: &str) -> Result<Option<Version>>
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.
Sourcefn start_run(&self, name: &str, run: &Run) -> Result<u64>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".