1use crate::runtime::Valence;
4use serde::{Deserialize, Serialize};
5use std::future::Future;
6use std::pin::Pin;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct IterEvaluation {
11 pub should_run: bool,
12 pub reason: String,
13}
14
15impl IterEvaluation {
16 pub fn run(reason: impl Into<String>) -> Self {
17 Self {
18 should_run: true,
19 reason: reason.into(),
20 }
21 }
22
23 pub fn skip(reason: impl Into<String>) -> Self {
24 Self {
25 should_run: false,
26 reason: reason.into(),
27 }
28 }
29}
30
31pub type IterShouldRunFn =
33 fn(
34 Valence,
35 serde_json::Value,
36 ) -> Pin<Box<dyn Future<Output = anyhow::Result<IterEvaluation>> + Send + 'static>>;
37
38pub type IterExecuteFn = fn(
40 Valence,
41 serde_json::Value,
42) -> Pin<Box<dyn Future<Output = anyhow::Result<()>> + Send + 'static>>;
43
44#[derive(Copy, Clone)]
46pub struct IterDescriptor {
47 pub iter_type_name: &'static str,
48 pub table_name: &'static str,
49 pub should_run: IterShouldRunFn,
50 pub execute: IterExecuteFn,
51}
52
53inventory::collect!(IterDescriptor);