ayun_core/traits/
application.rsuse crate::{traits::ServiceTrait, Container, Result};
pub trait ApplicationTrait: Default {
#[cfg(feature = "migration")]
type Migrator: sea_orm_migration::MigratorTrait;
#[cfg(any(feature = "http1", feature = "http2"))]
fn with_routing() -> impl ServiceTrait;
#[cfg(feature = "schedule")]
fn with_schedule() -> impl ServiceTrait;
#[cfg(feature = "console")]
fn with_console() -> impl ServiceTrait;
fn register(container: Container) -> Result<Container> {
Ok(container)
}
fn boot() {
#[cfg(not(feature = "logger"))]
{
use tracing_subscriber::layer::SubscriberExt;
let subscriber = tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_target(false));
let _ = tracing::subscriber::set_global_default(subscriber);
}
#[cfg(feature = "color-eyre")]
color_eyre::install().expect("Failed to install color eyre");
}
fn new() -> Self {
Self::default()
}
fn run<S: ServiceTrait>(self) -> Result<()>
where
Self: Sized,
{
S::init::<Self>().run()
}
}