kaspa_core/task/
service.rs1use futures_util::future::BoxFuture;
2use intertrait::CastFromSync;
3use std::sync::Arc;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum AsyncServiceError {
8 #[error("{0}")]
9 Service(String),
10}
11
12pub type AsyncServiceResult<T> = std::result::Result<T, AsyncServiceError>;
13
14pub type AsyncServiceFuture = BoxFuture<'static, AsyncServiceResult<()>>;
15
16pub trait AsyncService: CastFromSync {
17 fn ident(self: Arc<Self>) -> &'static str;
18 fn start(self: Arc<Self>) -> AsyncServiceFuture;
19 fn signal_exit(self: Arc<Self>);
20 fn stop(self: Arc<Self>) -> AsyncServiceFuture;
21}