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/// | `ShuttleThruster` | [shuttle-thruster](https://crates.io/crates/shuttle-thruster)  | [thruster](https://docs.rs/thruster)                                    | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/thruster/hello-world) |
32/// | `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)    |
33/// | `ShuttleTide`     | [shuttle-tide](https://crates.io/crates/shuttle-tide)          | [tide](https://docs.rs/tide)                                            | [GitHub](https://github.com/shuttle-hq/shuttle-examples/tree/main/tide/hello-world)     |
34///
35/// ## Getting shuttle managed resources
36/// 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:
37/// ```rust,no_run
38/// use sqlx::PgPool;
39/// use shuttle_rocket::ShuttleRocket;
40///
41/// struct MyState(PgPool);
42///
43/// #[shuttle_runtime::main]
44/// async fn rocket(#[shuttle_shared_db::Postgres] pool: PgPool) -> ShuttleRocket {
45///     let state = MyState(pool);
46///     let rocket = rocket::build().manage(state);
47///
48///     Ok(rocket.into())
49/// }
50/// ```
51///
52/// More [shuttle managed resources can be found here](https://github.com/shuttle-hq/shuttle/tree/main/resources)
53#[proc_macro_error2::proc_macro_error]
54#[proc_macro_attribute]
55pub fn main(
56    attr: proc_macro::TokenStream,
57    item: proc_macro::TokenStream,
58) -> proc_macro::TokenStream {
59    shuttle_main::tokens(attr, item)
60}