rocket_extra_codegen

Crates.iorocket_extra_codegen
lib.rsrocket_extra_codegen
version0.1.0
sourcesrc
created_at2019-02-04 20:18:53.92168
updated_at2019-02-07 16:23:28.271989
descriptionAdditional macros for rocket.rs
homepage
repositoryhttps://github.com/Woyten/rocket_extra_codegen
max_upload_size
id112749
size7,260
(Woyten)

documentation

README

Additional macros for rocket.rs

Derive FromRequest

use rocket_extra_codegen::FromRequest;

#[derive(FromRequest)]
struct BookingService {
    db_conn: DbConnection,
    queue_conn: QueueConnection,
    user: AuthUser,
}

The errors of the individual fields will be converted via the From trait to a common target error type. The target error type defaults to () but can be overridden manually:

use rocket_extra_codegen::FromRequest;

#[derive(FromRequest)]
#[error_type = "MyError"]
struct BookingService {
    db_conn: DbConnection,
    queue_conn: QueueConnection,
    user: AuthUser,
}
Commit count: 9

cargo fmt