shuttle_codegen/
lib.rs

1mod shuttle_main;
2
3/// Helper macro that generates the entrypoint required by any service - likely the only macro you need in this crate.
4///
5/// ## Without shuttle managed resources
6/// The simplest usage is when your service does not require any shuttle managed resources, so you only need to return a shuttle supported service:
7///
8/// ```rust,no_run
9/// use shuttle_rocket::ShuttleRocket;
10///
11/// #[shuttle_runtime::main]
12/// async fn rocket() -> ShuttleRocket {
13///     let rocket = rocket::build();
14///
15///     Ok(rocket.into())
16/// }
17/// ```
18///
19/// ## Shuttle supported services
20/// The following types can be returned from a `#[shuttle_runtime::main]` function and enjoy first class service support in shuttle.
21///
22/// | Return type       | Crate                                                          | Service                                                                 | Example                                                                                 |
23/// | ----------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
24/// | `ShuttleActixWeb` | [shuttle-actix-web](https://crates.io/crates/shuttle-actix-web)| [actix-web](https://docs.rs/actix-web)                                  | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/actix-web/hello-world)|
25/// | `ShuttleAxum`     | [shuttle-axum](https://crates.io/crates/shuttle-axum)          | [axum](https://docs.rs/axum)                                            | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/axum/hello-world)     |
26/// | `ShuttlePoem`     | [shuttle-poem](https://crates.io/crates/shuttle-poem)          | [poem](https://docs.rs/poem)                                            | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/poem/hello-world)     |
27/// | `ShuttleRama`     | [shuttle-rama](https://crates.io/crates/shuttle-rama)          | [rama](https://docs.rs/rama)                                            | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/rama/hello-world)     |
28/// | `ShuttleRocket`   | [shuttle-rocket](https://crates.io/crates/shuttle-rocket)      | [rocket](https://docs.rs/rocket)                                        | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/rocket/hello-world)   |
29/// | `ShuttleSalvo`    | [shuttle-salvo](https://crates.io/crates/shuttle-salvo)        | [salvo](https://docs.rs/salvo)                                          | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/salvo/hello-world)    |
30/// | `ShuttleSerenity` | [shuttle-serenity](https://crates.io/crates/shuttle-serenity)  | [serenity](https://docs.rs/serenity) and [poise](https://docs.rs/poise) | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/serenity/hello-world) |
31/// | `ShuttleTower`    | [shuttle-tower](https://crates.io/crates/shuttle-tower)        | [tower](https://docs.rs/tower)                                          | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/tower/hello-world)    |
32/// | `ShuttleWarp`     | [shuttle-warp](https://crates.io/crates/shuttle-warp)          | [warp](https://docs.rs/warp)                                            | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/warp/hello-world)     |
33///
34/// ## Getting shuttle managed resources
35/// 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:
36/// ```rust,no_run
37/// use sqlx::PgPool;
38/// use shuttle_rocket::ShuttleRocket;
39///
40/// struct MyState(PgPool);
41///
42/// #[shuttle_runtime::main]
43/// async fn rocket(#[shuttle_shared_db::Postgres] pool: PgPool) -> ShuttleRocket {
44///     let state = MyState(pool);
45///     let rocket = rocket::build().manage(state);
46///
47///     Ok(rocket.into())
48/// }
49/// ```
50///
51/// More [shuttle managed resources can be found here](https://github.com/shuttle-hq/shuttle/tree/main/resources)
52#[proc_macro_error2::proc_macro_error]
53#[proc_macro_attribute]
54pub fn main(
55    attr: proc_macro::TokenStream,
56    item: proc_macro::TokenStream,
57) -> proc_macro::TokenStream {
58    shuttle_main::tokens(attr, item)
59}