Implement HandleNotice for FnMut(DbError)

This commit is contained in:
Steven Fackler
2016-03-05 12:04:43 -08:00
parent dc52f84bcf
commit 0624cd6338

View File

@@ -218,11 +218,19 @@ impl IntoConnectParams for Url {
}
/// Trait for types that can handle Postgres notice messages
///
/// It is implemented for all `Send + FnMut(DbError)` closures.
pub trait HandleNotice: Send {
/// Handle a Postgres notice message
fn handle_notice(&mut self, notice: DbError);
}
impl<F: Send + FnMut(DbError)> HandleNotice for F {
fn handle_notice(&mut self, notice: DbError) {
self(notice)
}
}
/// A notice handler which logs at the `info` level.
///
/// This is the default handler used by a `Connection`.