pub struct App;
Expand description
The primary entry point for launching a Strut application.
This struct provides a high-level facade for running an application.
Use App::boot
for a quick start with default settings, or
App::launchpad
to customize the startup process.
Implementations§
Source§impl App
impl App
Sourcepub fn boot<Main>(async_main: Main)
pub fn boot<Main>(async_main: Main)
Starts a Strut application with default settings.
This function provides the simplest way to run an application. It creates a
default Launchpad
, runs the startup process, executes the provided
async_main
future, and handles graceful shutdown.
For customization options, see App::launchpad
.
§Example
use strut::App;
fn main() {
App::boot(async_main());
}
async fn async_main() {
println!("Executing the main logic");
}
Sourcepub fn launchpad<Main>(async_main: Main) -> Launchpad<Main>
pub fn launchpad<Main>(async_main: Main) -> Launchpad<Main>
Creates a Launchpad
for custom application startup.
This is the entry point for customizing Strut’s startup behavior. It
returns a Launchpad
instance that you can use to configure aspects like
configuration sources or wiring stages before calling Launchpad::boot
to run the application.
§Example
use strut::{App, AppConfig, PreflightWiring};
use tokio::runtime::Runtime;
fn main() {
App::launchpad(async_main())
.with_preflight_wiring(CustomPreflightWiring)
.boot();
}
async fn async_main() {
println!("Executing the main logic");
}
struct CustomPreflightWiring;
impl PreflightWiring for CustomPreflightWiring {
fn run(&self, _config: &'static AppConfig, _runtime: &Runtime) {
println!("Interjecting the preflight logic");
}
}