Crate rocket_codegen
source ·Expand description
Rocket - Code Generation
This crate implements the code generation portions of Rocket. This includes custom derives, custom attributes, and procedural macros. The documentation here is purely technical. The code generation facilities are documented thoroughly in the Rocket programming guide.
Usage
You should not directly depend on this library. To use the macros,
attributes, and derives in this crate, it suffices to depend on rocket
in
Cargo.toml
:
[dependencies]
rocket = "=0.5.0-rc.3"
And to import all macros, attributes, and derives via #[macro_use]
in the
crate root:
#[macro_use] extern crate rocket;
Or, alternatively, selectively import from the top-level scope:
use rocket::{get, routes};
Debugging Codegen
When the ROCKET_CODEGEN_DEBUG
environment variable is set, this crate
logs, at compile-time and to the console, the items it generates. For
example, you might run the following to build a Rocket application with
codegen debug logging enabled:
ROCKET_CODEGEN_DEBUG=1 cargo build
Macros
- Generates a
Vec
ofCatcher
s from a set of catcher paths. - Generates a
Vec
ofRoute
s from a set of route paths. - Type-safe, encoding-safe route and non-route URI generation.
Attribute Macros
- Retrofits supports for
async fn
in unit tests. - Attribute to generate a
Catcher
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Generates a
main
function that launches a returnedRocket<Build>
. - Retrofits
async fn
support inmain
functions. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata. - Attribute to generate a
Route
and associated metadata.
Derive Macros
- Derive for the
FromForm
trait. - Derive for the
FromFormField
trait. - Derive for the
Responder
trait. - Derive for the
UriDisplay<Path>
trait. - Derive for the
UriDisplay<Query>
trait.