Trait TasksFacade

Source
pub trait TasksFacade<'a, T: Task<'a>>: Serialize + Deserialize<'a> {
    // Required methods
    fn new(name: String, desired_retention: f64) -> Self;
    fn get_name(&self) -> &str;
    fn get_desired_retention(&self) -> f64;
    fn set_desired_retention(&mut self, desired_retention: f64);
    fn tasks_total(&self) -> usize;
    fn tasks_to_complete(&self) -> usize;
    fn complete_task(
        &mut self,
        interaction: &mut impl FnMut(TaskId, Blocks) -> Result<Response>,
    ) -> Result<(), Error>;
    fn insert(&mut self, task: T);
    fn create_task(&mut self, input: BlocksWithAnswer);
    fn iter<'t>(&'t self) -> impl Iterator<Item = (&'t T, TaskId)>
       where T: 't;
    fn remove(&mut self, id: TaskId) -> bool;
    fn optimize(&mut self) -> Result<(), Box<dyn Error>>
       where T::SharedState: SharedStateExt<'a, T>;
}

Required Methods§

Source

fn new(name: String, desired_retention: f64) -> Self

Source

fn get_name(&self) -> &str

Source

fn get_desired_retention(&self) -> f64

Source

fn set_desired_retention(&mut self, desired_retention: f64)

Source

fn tasks_total(&self) -> usize

Source

fn tasks_to_complete(&self) -> usize

Source

fn complete_task( &mut self, interaction: &mut impl FnMut(TaskId, Blocks) -> Result<Response>, ) -> Result<(), Error>

If an error occurs, the tasks facade will remain unmodified.

§Errors

If interaction return error.

Source

fn insert(&mut self, task: T)

Source

fn create_task(&mut self, input: BlocksWithAnswer)

Source

fn iter<'t>(&'t self) -> impl Iterator<Item = (&'t T, TaskId)>
where T: 't,

Return itrator of (&task, id)

Source

fn remove(&mut self, id: TaskId) -> bool

Remove task. Returns whether such an element was present.

Source

fn optimize(&mut self) -> Result<(), Box<dyn Error>>
where T::SharedState: SharedStateExt<'a, T>,

§Errors

If error occurs when optimizing. Guarantee to not modify anything.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§