Skip to content

Commit 0624cd6

Browse files
committed
Implement HandleNotice for FnMut(DbError)
1 parent dc52f84 commit 0624cd6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,19 @@ impl IntoConnectParams for Url {
218218
}
219219

220220
/// Trait for types that can handle Postgres notice messages
221+
///
222+
/// It is implemented for all `Send + FnMut(DbError)` closures.
221223
pub trait HandleNotice: Send {
222224
/// Handle a Postgres notice message
223225
fn handle_notice(&mut self, notice: DbError);
224226
}
225227

228+
impl<F: Send + FnMut(DbError)> HandleNotice for F {
229+
fn handle_notice(&mut self, notice: DbError) {
230+
self(notice)
231+
}
232+
}
233+
226234
/// A notice handler which logs at the `info` level.
227235
///
228236
/// This is the default handler used by a `Connection`.

0 commit comments

Comments
 (0)