Skip to content

Commit 0c56a5e

Browse files
committed
Flatten out InnerConnection
1 parent dc08fc6 commit 0c56a5e

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

postgres-tokio/src/lib.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ pub struct CancelData {
3535
pub secret_key: i32,
3636
}
3737

38-
struct InnerConnectionState {
39-
parameters: HashMap<String, String>,
40-
cancel_data: CancelData,
41-
}
42-
4338
struct InnerConnection {
4439
stream: PostgresStream,
45-
state: InnerConnectionState,
40+
parameters: HashMap<String, String>,
41+
cancel_data: CancelData,
4642
}
4743

4844
impl InnerConnection {
@@ -64,7 +60,7 @@ impl InnerConnection {
6460
Ok(value) => value.to_owned(),
6561
Err(e) => return Either::A(Err((e, s)).into_future()),
6662
};
67-
s.state.parameters.insert(name, value);
63+
s.parameters.insert(name, value);
6864
Either::B(s.read())
6965
}
7066
Some(backend::Message::NoticeResponse(_)) => {
@@ -117,12 +113,10 @@ impl Connection {
117113
.map(|s| {
118114
Connection(InnerConnection {
119115
stream: s,
120-
state: InnerConnectionState {
121-
parameters: HashMap::new(),
122-
cancel_data: CancelData {
123-
process_id: 0,
124-
secret_key: 0,
125-
}
116+
parameters: HashMap::new(),
117+
cancel_data: CancelData {
118+
process_id: 0,
119+
secret_key: 0,
126120
}
127121
})
128122
})
@@ -230,8 +224,8 @@ impl Connection {
230224
.and_then(|(m, mut s)| {
231225
match m {
232226
backend::Message::BackendKeyData(body) => {
233-
s.state.cancel_data.process_id = body.process_id();
234-
s.state.cancel_data.secret_key = body.secret_key();
227+
s.cancel_data.process_id = body.process_id();
228+
s.cancel_data.secret_key = body.secret_key();
235229
Either::A(Connection(s).finish_startup())
236230
}
237231
backend::Message::ReadyForQuery(_) => Either::B(Ok(Connection(s)).into_future()),
@@ -245,7 +239,7 @@ impl Connection {
245239
}
246240

247241
pub fn cancel_data(&self) -> CancelData {
248-
self.0.state.cancel_data
242+
self.0.cancel_data
249243
}
250244
}
251245

0 commit comments

Comments
 (0)