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.1"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 buildMacros§
- catchers
- Generates a
VecofCatchers from a set of catcher paths. - routes
- Generates a
VecofRoutes from a set of route paths. - uri
- Type-safe, encoding-safe route and non-route URI generation.
Attribute Macros§
- async_
test - Retrofits supports for
async fnin unit tests. - catch
- Attribute to generate a
Catcherand associated metadata. - delete
- Attribute to generate a
Routeand associated metadata. - get
- Attribute to generate a
Routeand associated metadata. - head
- Attribute to generate a
Routeand associated metadata. - launch
- Generates a
mainfunction that launches a returnedRocket<Build>. - main
- Retrofits
async fnsupport inmainfunctions. - options
- Attribute to generate a
Routeand associated metadata. - patch
- Attribute to generate a
Routeand associated metadata. - post
- Attribute to generate a
Routeand associated metadata. - put
- Attribute to generate a
Routeand associated metadata. - route
- Attribute to generate a
Routeand associated metadata.
Derive Macros§
- From
Form - Derive for the
FromFormtrait. - From
Form Field - Derive for the
FromFormFieldtrait. - Responder
- Derive for the
Respondertrait. - UriDisplay
Path - Derive for the
UriDisplay<Path>trait. - UriDisplay
Query - Derive for the
UriDisplay<Query>trait.