Skip to content

Commit 2380165

Browse files
committed
Rename NoticeHandler
1 parent 63cd220 commit 2380165

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,19 @@ impl IntoConnectParams for Url {
193193
}
194194

195195
/// Trait for types that can handle Postgres notice messages
196-
pub trait NoticeHandler: Send {
196+
pub trait HandleNotice: Send {
197197
/// Handle a Postgres notice message
198-
fn handle(&mut self, notice: DbError);
198+
fn handle_notice(&mut self, notice: DbError);
199199
}
200200

201201
/// A notice handler which logs at the `info` level.
202202
///
203203
/// This is the default handler used by a `Connection`.
204204
#[derive(Copy, Debug)]
205-
pub struct DefaultNoticeHandler;
205+
pub struct LoggingNoticeHandler;
206206

207-
impl NoticeHandler for DefaultNoticeHandler {
208-
fn handle(&mut self, notice: DbError) {
207+
impl HandleNotice for LoggingNoticeHandler {
208+
fn handle_notice(&mut self, notice: DbError) {
209209
info!("{}: {}", notice.severity(), notice.message());
210210
}
211211
}
@@ -384,7 +384,7 @@ struct CachedStatement {
384384

385385
struct InnerConnection {
386386
stream: BufferedStream<MaybeSslStream<InternalStream>>,
387-
notice_handler: Box<NoticeHandler>,
387+
notice_handler: Box<HandleNotice>,
388388
notifications: VecDeque<Notification>,
389389
cancel_data: CancelData,
390390
unknown_types: HashMap<Oid, Type>,
@@ -417,7 +417,7 @@ impl InnerConnection {
417417
let mut conn = InnerConnection {
418418
stream: BufferedStream::new(stream),
419419
next_stmt_id: 0,
420-
notice_handler: Box::new(DefaultNoticeHandler),
420+
notice_handler: Box::new(LoggingNoticeHandler),
421421
notifications: VecDeque::new(),
422422
cancel_data: CancelData { process_id: 0, secret_key: 0 },
423423
unknown_types: HashMap::new(),
@@ -500,7 +500,7 @@ impl InnerConnection {
500500
match try_desync!(self, self.stream.read_message()) {
501501
NoticeResponse { fields } => {
502502
if let Ok(err) = ugh_privacy::dberror_new_raw(fields) {
503-
self.notice_handler.handle(err);
503+
self.notice_handler.handle_notice(err);
504504
}
505505
Ok(None)
506506
}
@@ -572,7 +572,7 @@ impl InnerConnection {
572572
}
573573
}
574574

575-
fn set_notice_handler(&mut self, handler: Box<NoticeHandler>) -> Box<NoticeHandler> {
575+
fn set_notice_handler(&mut self, handler: Box<HandleNotice>) -> Box<HandleNotice> {
576576
mem::replace(&mut self.notice_handler, handler)
577577
}
578578

@@ -919,7 +919,7 @@ impl Connection {
919919
}
920920

921921
/// Sets the notice handler for the connection, returning the old handler.
922-
pub fn set_notice_handler(&self, handler: Box<NoticeHandler>) -> Box<NoticeHandler> {
922+
pub fn set_notice_handler(&self, handler: Box<HandleNotice>) -> Box<HandleNotice> {
923923
self.conn.borrow_mut().set_notice_handler(handler)
924924
}
925925

tests/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::old_io::timer;
1111
use std::time::Duration;
1212
use std::thread;
1313

14-
use postgres::{NoticeHandler,
14+
use postgres::{HandleNotice,
1515
Notification,
1616
Connection,
1717
GenericConnection,
@@ -529,8 +529,8 @@ fn test_custom_notice_handler() {
529529
static mut count: usize = 0;
530530
struct Handler;
531531

532-
impl NoticeHandler for Handler {
533-
fn handle(&mut self, notice: DbError) {
532+
impl HandleNotice for Handler {
533+
fn handle_notice(&mut self, notice: DbError) {
534534
assert_eq!("note", notice.message());
535535
unsafe { count += 1; }
536536
}

0 commit comments

Comments
 (0)