Skip to main content

ic_bn_lib_common/traits/
utils.rs

1use std::fmt::{Debug, Display};
2
3use async_trait::async_trait;
4
5use crate::types::utils::TargetState;
6
7/// Trait that executes the requests.
8/// Akin to Tower's Service, but generic over backend.
9#[async_trait]
10pub trait ExecutesRequest<T>: Send + Sync + Debug {
11    type Request;
12    type Response;
13    type Error;
14
15    async fn execute(&self, backend: &T, req: Self::Request)
16    -> Result<Self::Response, Self::Error>;
17}
18
19/// Checks if given target is healthy
20#[async_trait]
21pub trait ChecksTarget<T: Clone + Display + Debug>: Send + Sync + 'static {
22    async fn check(&self, target: &T) -> TargetState;
23}