Trait edm_core::application::Application
source · pub trait Application {
type Routes;
Show 24 methods
// Required methods
fn register(self, routes: Self::Routes) -> Self;
fn run_with<T: AsyncScheduler + Send + 'static>(self, scheduler: T);
// Provided methods
fn boot() -> Self
where Self: Default { ... }
fn boot_with<F>(init: F) -> Self
where Self: Default,
F: FnOnce(&'static State<Map>) { ... }
fn register_with(self, server_tag: ServerTag, routes: Self::Routes) -> Self
where Self: Sized { ... }
fn register_debug(self, routes: Self::Routes) -> Self
where Self: Sized { ... }
fn sysinfo() -> Map { ... }
fn openapi() -> OpenApi { ... }
fn shared_state() -> &'static State<Map> { ... }
fn env() -> &'static Env { ... }
fn config() -> &'static Table { ... }
fn state_data() -> &'static Map { ... }
fn name() -> &'static str { ... }
fn version() -> &'static str { ... }
fn domain() -> &'static str { ... }
fn project_dir() -> &'static PathBuf { ... }
fn secret_key() -> &'static [u8] ⓘ { ... }
fn shared_dir(name: &str) -> PathBuf { ... }
fn spawn<T>(self, scheduler: T) -> Self
where Self: Sized,
T: Scheduler + Send + 'static { ... }
fn run(self)
where Self: Sized { ... }
async fn load() { ... }
async fn shutdown() { ... }
async fn fetch(
resource: &str,
options: Option<&Map>
) -> Result<Response, Error> { ... }
async fn fetch_json<T: DeserializeOwned>(
resource: &str,
options: Option<&Map>
) -> Result<T, Error> { ... }
}Expand description
Application interfaces.
Required Associated Types§
Required Methods§
sourcefn run_with<T: AsyncScheduler + Send + 'static>(self, scheduler: T)
fn run_with<T: AsyncScheduler + Send + 'static>(self, scheduler: T)
Runs the application with an optional scheduler for async jobs.
Provided Methods§
sourcefn boot() -> Selfwhere
Self: Default,
fn boot() -> Selfwhere
Self: Default,
Boots the application. It also initializes the required directories and setups the default secret key, the tracing subscriber, the metrics exporter and a global HTTP client.
sourcefn register_with(self, server_tag: ServerTag, routes: Self::Routes) -> Selfwhere
Self: Sized,
fn register_with(self, server_tag: ServerTag, routes: Self::Routes) -> Selfwhere
Self: Sized,
Registers routes with a server tag.
sourcefn register_debug(self, routes: Self::Routes) -> Selfwhere
Self: Sized,
fn register_debug(self, routes: Self::Routes) -> Selfwhere
Self: Sized,
Registers routes for debugger.
Returns a reference to the shared application state.
sourcefn state_data() -> &'static Map
fn state_data() -> &'static Map
Returns a reference to the shared application state data.
sourcefn project_dir() -> &'static PathBuf
fn project_dir() -> &'static PathBuf
Returns the project directory for the application.
sourcefn secret_key() -> &'static [u8] ⓘ
fn secret_key() -> &'static [u8] ⓘ
Returns the secret key for the application. It should have at least 64 bytes.
Note
This should only be used for internal services. Do not expose it to external users.
Returns the shared directory with the specific name,
which is defined in the dirs table.
sourceasync fn fetch(resource: &str, options: Option<&Map>) -> Result<Response, Error>
async fn fetch(resource: &str, options: Option<&Map>) -> Result<Response, Error>
Makes an HTTP request to the provided resource
using reqwest.
sourceasync fn fetch_json<T: DeserializeOwned>(
resource: &str,
options: Option<&Map>
) -> Result<T, Error>
async fn fetch_json<T: DeserializeOwned>( resource: &str, options: Option<&Map> ) -> Result<T, Error>
Makes an HTTP request to the provided resource and deserializes the response body via JSON.