mod controller;
mod plan;
mod types;
pub use controller::Controller;
pub use plan::{Plan, PlanError, Rule};
pub use types::{ExecutionError, Limit, Limits, Report, Work, WorkExceeded};
use std::{error::Error, future::Future};
pub trait RuleBackend: Send {
type Rule: Eq + Send + Sync;
type Snapshot: Send + Sync;
type Error: Error + Send + Sync + 'static;
fn snapshot(&mut self) -> impl Future<Output = Result<Self::Snapshot, Self::Error>> + Send;
fn begin_layer(
&mut self,
rules: &[Rule<Self::Rule>],
work: &mut Work,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn execute(
&mut self,
rule: &Self::Rule,
snapshot: &Self::Snapshot,
phase: u64,
work: &mut Work,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn merge_phase(
&mut self,
work: &mut Work,
) -> impl Future<Output = Result<u64, Self::Error>> + Send;
fn finish_layer(
&mut self,
rules: &[Rule<Self::Rule>],
work: &mut Work,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn finish(&mut self, work: &mut Work) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn is_cancelled(&self) -> bool;
}