shuttle_runtime

Attribute Macro main

Source
#[main]
Expand description

Helper macro that generates the entrypoint required by any service - likely the only macro you need in this crate.

§Without shuttle managed resources

The simplest usage is when your service does not require any shuttle managed resources, so you only need to return a shuttle supported service:

use shuttle_rocket::ShuttleRocket;

#[shuttle_rocket::main]
async fn rocket() -> ShuttleRocket {
    let rocket = rocket::build();

    Ok(rocket.into())
}

§Shuttle supported services

The following types can be returned from a #[shuttle_service::main] function and enjoy first class service support in shuttle.

Return typeCrateServiceVersionExample
ShuttleActixWebshuttle-actix-webactix-web4.3GitHub
ShuttleAxumshuttle-axumaxum0.7GitHub
ShuttlePoemshuttle-poempoem2.0GitHub
ShuttleRocketshuttle-rocketrocket0.5GitHub
ShuttleSalvoshuttle-salvosalvo0.63GitHub
ShuttleSerenityshuttle-serenityserenity and poise0.12GitHub
ShuttleThrustershuttle-thrusterthruster1.3GitHub
ShuttleTowershuttle-towertower0.4GitHub
ShuttleTideshuttle-tidetide0.16GitHub

§Getting shuttle managed resources

Shuttle is able to manage resource dependencies for you. These resources are passed in as inputs to your #[shuttle_runtime::main] function and are configured using attributes:

use sqlx::PgPool;
use shuttle_rocket::ShuttleRocket;

struct MyState(PgPool);

#[shuttle_runtime::main]
async fn rocket(#[shuttle_shared_db::Postgres] pool: PgPool) -> ShuttleRocket {
    let state = MyState(pool);
    let rocket = rocket::build().manage(state);

    Ok(rocket.into())
}

More shuttle managed resources can be found here