Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    type Config: for<'a> Facet<'a> + Sync;
    type Error: StdError + Send + Sync + 'static;
    type Live: Send;
    type Operation: Display + Send + Sync;

    // Required methods
    fn apply(
        &self,
        repository: &RepoRef,
        operation: &Self::Operation,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn plan(
        config: &Self::Config,
        live: &Self::Live,
    ) -> Planned<Self::Operation>;
    fn read(
        &self,
        repository: &RepoRef,
        config: &Self::Config,
    ) -> impl Future<Output = Result<Self::Live, Self::Error>> + Send;
    fn validate(config: &Self::Config) -> Result<(), Self::Error>;
}
Expand description

An adapter that reads one forge and applies planned writes to it.

The adapter owns the shape of the desired state, the live state and the writes. The shared code only orders and reports them.

Required Associated Types§

Source

type Config: for<'a> Facet<'a> + Sync

The desired repository state, decoded from the state document.

Source

type Error: StdError + Send + Sync + 'static

The adapter’s transport or API error.

Source

type Live: Send

The state read from the forge.

Source

type Operation: Display + Send + Sync

One labelled write. The label names the resource the write changes.

Required Methods§

Source

fn apply( &self, repository: &RepoRef, operation: &Self::Operation, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Perform one planned operation.

Source

fn plan(config: &Self::Config, live: &Self::Live) -> Planned<Self::Operation>

Compare the desired and the live state without any I/O.

Source

fn read( &self, repository: &RepoRef, config: &Self::Config, ) -> impl Future<Output = Result<Self::Live, Self::Error>> + Send

Read the state that planning compares with config.

Source

fn validate(config: &Self::Config) -> Result<(), Self::Error>

Check a configuration before any network access.

§Errors

Returns an error when the forge cannot represent the configuration.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§