-
-
Notifications
You must be signed in to change notification settings - Fork 130
Closed
Description
Hi! I would like to propose to redefine the ManageConnection and CustomizeConnection traits from
#[async_trait]
pub trait ManageConnection: Sized + Send + Sync + 'static {
// other items...
async fn connect(&self) -> Result<Self::Connection, Self::Error>;
async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>;
}
#[async_trait]
pub trait CustomizeConnection<C: Send + 'static, E: 'static>:
fmt::Debug + Send + Sync + 'static
{
async fn on_acquire(&self, _connection: &mut C) -> Result<(), E> {
Ok(())
}
}to
pub trait ManageConnection: Sized + Send + Sync + 'static {
// other items...
fn connect(&self) -> impl Future<Output = Result<Self::Connection, Self::Error>> + Send;
fn is_valid(&self, conn: &mut Self::Connection) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
pub trait CustomizeConnection<C: Send + 'static, E: 'static>:
fmt::Debug + Send + Sync + 'static
{
fn on_acquire(&self, _connection: &mut C) -> impl Future<Output = Result<(), E>> + Send {
async move { Ok(()) }
}
}for bb8 0.9.0.
This will allow bb8 to be used without pulling in any proc-macros AFAICT, people will still be able to write async fn in impls (just without #[async_trait]), and it will improve the rendered documentation (see svix/omniqueue-rs#34 for the diff on another crate).
I can send a PR if you agree that this is a good idea. In that case, do you want to keep main for the 0.8.x release line and create a new branch for 0.9.x, or have the PR against main?
TheButlah and mofterdinger
Metadata
Metadata
Assignees
Labels
No labels