rocket_extra_codegen 0.1.0

Additional macros for rocket.rs
Documentation

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,
}