use alloc::{vec, vec::IntoIter};
use codec::FullCodec;
use core::{fmt::Debug, iter::Iterator};
use scale_info::TypeInfo;
use subsoil::runtime::DispatchError;
use subsoil::weights::Weight;
#[doc(hidden)]
pub mod __private {
pub use alloc::{vec, vec::IntoIter};
pub use codec::FullCodec;
pub use core::{fmt::Debug, iter::Iterator};
pub use scale_info::TypeInfo;
pub use subsoil::runtime::DispatchError;
pub use subsoil::weights::Weight;
}
pub trait Task: Sized + FullCodec + TypeInfo + Clone + Debug + PartialEq + Eq {
type Enumeration: Iterator;
fn iter() -> Self::Enumeration;
fn is_valid(&self) -> bool;
fn run(&self) -> Result<(), DispatchError>;
fn weight(&self) -> Weight;
fn task_index(&self) -> u32;
}
impl Task for () {
type Enumeration = IntoIter<Self>;
fn iter() -> Self::Enumeration {
vec![].into_iter()
}
fn is_valid(&self) -> bool {
true
}
fn run(&self) -> Result<(), DispatchError> {
Ok(())
}
fn weight(&self) -> Weight {
Weight::default()
}
fn task_index(&self) -> u32 {
0
}
}