1pub use crate::setup::{ApplicationConfiguration, SetupConfiguration};
17
18use std::future::Future;
22
23use serde::de::DeserializeOwned;
25
26use crate::setup::Setup;
28
29pub trait Context: Clone + Send + Sync + 'static {
42 #[doc(hidden)]
43 type Configuration: SetupConfiguration;
44}
45
46pub trait Lifecycle: Sized + Send + 'static {
47 type Config: DeserializeOwned + Default + Send + 'static;
48 type Error: std::error::Error + Send + Sync + 'static;
49 type Context: Context;
50
51 fn prepare(config: Self::Config, setup: &mut Setup<Self>) -> impl Future<Output = Result<Self, Self::Error>> + Send;
52 fn initialize(&mut self, context: &Self::Context) -> impl Future<Output = Result<(), Self::Error>> + Send;
53 fn stop(&mut self, context: &Self::Context) -> impl Future<Output = Result<(), Self::Error>> + Send;
54 fn cleanup(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send;
55}
56
57