Skip to content

Commit 96943d7

Browse files
committed
Switch over to protocol backend parser
We still have to keep our owned Backend enum around since SEME doesn't work :'(
1 parent 457d700 commit 96943d7

File tree

6 files changed

+146
-283
lines changed

6 files changed

+146
-283
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ with-uuid = ["uuid"]
3434
[dependencies]
3535
bufstream = "0.1"
3636
byteorder = "0.5"
37+
fallible-iterator = "0.1"
3738
hex = "0.2"
3839
log = "0.3"
3940
phf = "=0.7.15"

src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
extern crate bufstream;
4646
extern crate byteorder;
47+
extern crate fallible_iterator;
4748
extern crate hex;
4849
#[macro_use]
4950
extern crate log;
@@ -64,7 +65,7 @@ use postgres_protocol::message::frontend;
6465

6566
use error::{Error, ConnectError, SqlState, DbError};
6667
use io::TlsHandshake;
67-
use message::{Backend, RowDescriptionEntry, ReadMessage};
68+
use message::{Backend, RowDescriptionEntry};
6869
use notification::{Notifications, Notification};
6970
use params::{ConnectParams, IntoConnectParams, UserInfo};
7071
use priv_io::MessageStream;
@@ -288,8 +289,8 @@ impl InnerConnection {
288289
loop {
289290
match try!(conn.read_message()) {
290291
Backend::BackendKeyData { process_id, secret_key } => {
291-
conn.cancel_data.process_id = process_id as i32;
292-
conn.cancel_data.secret_key = secret_key as i32;
292+
conn.cancel_data.process_id = process_id;
293+
conn.cancel_data.secret_key = secret_key;
293294
}
294295
Backend::ReadyForQuery { .. } => break,
295296
Backend::ErrorResponse { fields } => return DbError::new_connect(fields),
@@ -303,7 +304,7 @@ impl InnerConnection {
303304
fn read_message_with_notification(&mut self) -> std_io::Result<Backend> {
304305
debug_assert!(!self.desynchronized);
305306
loop {
306-
match try_desync!(self, ReadMessage::read_message(&mut self.stream)) {
307+
match try_desync!(self, self.stream.read_message()) {
307308
Backend::NoticeResponse { fields } => {
308309
if let Ok(err) = DbError::new_raw(fields) {
309310
self.notice_handler.handle_notice(err);
@@ -357,9 +358,9 @@ impl InnerConnection {
357358
fn read_message(&mut self) -> std_io::Result<Backend> {
358359
loop {
359360
match try!(self.read_message_with_notification()) {
360-
Backend::NotificationResponse { pid, channel, payload } => {
361+
Backend::NotificationResponse { process_id, channel, payload } => {
361362
self.notifications.push_back(Notification {
362-
pid: pid,
363+
process_id: process_id,
363364
channel: channel,
364365
payload: payload,
365366
})

0 commit comments

Comments
 (0)