diff --git a/contrib/sync_db_pools/codegen/src/lib.rs b/contrib/sync_db_pools/codegen/src/lib.rs index 44bf2da8..05f8288e 100644 --- a/contrib/sync_db_pools/codegen/src/lib.rs +++ b/contrib/sync_db_pools/codegen/src/lib.rs @@ -30,7 +30,7 @@ use proc_macro::TokenStream; /// retrieves a connection from the database pool or fails with a /// `Status::ServiceUnavailable` if connecting to the database times out. /// -/// The macro also generates two inherent methods on the decorated type: +/// The macro also generates three inherent methods on the decorated type: /// /// * `fn fairing() -> impl Fairing` /// @@ -42,6 +42,12 @@ use proc_macro::TokenStream; /// Retrieves a connection wrapper from the configured pool. Returns `Some` /// as long as `Self::fairing()` has been attached. /// +/// * `async fn run(&self, impl FnOnce(&mut Db) -> R + Send + 'static) -> R` +/// +/// Runs the specified function or closure, providing it access to the +/// underlying database connection (`&mut Db`). Returns the value returned +/// by the function or closure. +/// /// [`FromRequest`]: rocket::request::FromRequest #[proc_macro_attribute] pub fn database(attr: TokenStream, input: TokenStream) -> TokenStream { diff --git a/contrib/sync_db_pools/lib/src/lib.rs b/contrib/sync_db_pools/lib/src/lib.rs index 3764197d..b8d0165e 100644 --- a/contrib/sync_db_pools/lib/src/lib.rs +++ b/contrib/sync_db_pools/lib/src/lib.rs @@ -187,7 +187,7 @@ //! retrieves a connection from the database pool or fails with a //! `Status::ServiceUnavailable` if connecting to the database times out. //! -//! The macro also generates two inherent methods on the decorated type: +//! The macro also generates three inherent methods on the decorated type: //! //! * `fn fairing() -> impl Fairing` //! @@ -199,6 +199,12 @@ //! Retrieves a connection wrapper from the configured pool. Returns `Some` //! as long as `Self::fairing()` has been attached. //! +//! * `async fn run(&self, impl FnOnce(&mut Db) -> R + Send + 'static) -> R` +//! +//! Runs the specified function or closure, providing it access to the +//! underlying database connection (`&mut Db`). Returns the value returned +//! by the function or closure. +//! //! The attribute can only be applied to unit-like structs with one type. The //! internal type of the structure must implement [`Poolable`]. //!