hotshot_testing/predicates/
mod.rs

1// Copyright (c) 2021-2024 Espresso Systems (espressosys.com)
2// This file is part of the HotShot repository.
3
4// You should have received a copy of the MIT License
5// along with the HotShot repository. If not, see <https://mit-license.org/>.
6
7pub mod event;
8pub mod upgrade_with_proposal;
9pub mod upgrade_with_vote;
10
11use async_trait::async_trait;
12
13#[derive(Eq, PartialEq, Copy, Clone, Debug)]
14pub enum PredicateResult {
15    Pass,
16
17    Fail,
18
19    Incomplete,
20}
21
22impl From<bool> for PredicateResult {
23    fn from(boolean: bool) -> Self {
24        match boolean {
25            true => PredicateResult::Pass,
26            false => PredicateResult::Fail,
27        }
28    }
29}
30
31#[async_trait]
32pub trait Predicate<INPUT>: std::fmt::Debug {
33    async fn evaluate(&self, input: &INPUT) -> PredicateResult;
34    async fn info(&self) -> String;
35}