lexa_framework/application/
interface.rs1mod cli;
12mod env;
13mod logger;
14mod service;
15
16pub use self::cli::ApplicationCLIInterface;
17pub use self::env::ApplicationEnvInterface;
18pub use self::logger::ApplicationLoggerInterface;
19pub use self::service::Service;
20use super::Error;
21use crate::routing;
22
23pub trait Application {
29 type Router: routing::interface::RouterExt<State = Self::State>;
31
32 type State;
34
35 fn register_extension(
36 _: &crate::state::State<Self::State>,
37 router: routing::AxumRouter<Self::State>,
38 ) -> routing::AxumRouter<Self::State> {
39 router
40 }
41
42 fn register_layer(
43 _: &crate::state::State<Self::State>,
44 router: routing::AxumRouter<Self::State>,
45 ) -> routing::AxumRouter<Self::State> {
46 router
47 }
48
49 fn register_middleware(
50 _: &crate::state::State<Self::State>,
51 router: routing::AxumRouter<Self::State>,
52 ) -> routing::AxumRouter<Self::State> {
53 router
54 }
55
56 fn register_service(
57 server: crate::server::Server<Self::State>,
58 ) -> crate::server::Server<Self::State> {
59 server
60 }
61}
62
63#[async_trait::async_trait]
64pub trait ApplicationCreateExt {
65 type CLI: ApplicationCLIInterface;
66 type ENV: ApplicationEnvInterface;
67
68 fn define_process_mode(self, mode: super::env::EnvProcessMode) -> Self
70 where
71 Self: Sized;
72
73 fn with_cli_args(self) -> Self
76 where
77 Self: Sized;
78
79 fn with_env_vars(self) -> Result<Self, Error>
82 where
83 Self: Sized;
84
85 fn cli_args(&self) -> &Self::CLI;
87
88 fn env_vars(&self) -> &Self::ENV;
90}