Skip to content

Commit fbcdd6b

Browse files
committed
Rustfmt
1 parent bcb1047 commit fbcdd6b

File tree

12 files changed

+119
-196
lines changed

12 files changed

+119
-196
lines changed

src/error/mod.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,22 @@ impl DbErrorNew for DbError {
139139
impl fmt::Debug for DbError {
140140
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
141141
fmt.debug_struct("DbError")
142-
.field("severity", &self.severity)
143-
.field("code", &self.code)
144-
.field("message", &self.message)
145-
.field("detail", &self.detail)
146-
.field("hint", &self.hint)
147-
.field("position", &self.position)
148-
.field("where_", &self.where_)
149-
.field("schema", &self.schema)
150-
.field("table", &self.table)
151-
.field("column", &self.column)
152-
.field("datatype", &self.datatype)
153-
.field("constraint", &self.constraint)
154-
.field("file", &self.file)
155-
.field("line", &self.line)
156-
.field("routine", &self.routine)
157-
.finish()
142+
.field("severity", &self.severity)
143+
.field("code", &self.code)
144+
.field("message", &self.message)
145+
.field("detail", &self.detail)
146+
.field("hint", &self.hint)
147+
.field("position", &self.position)
148+
.field("where_", &self.where_)
149+
.field("schema", &self.schema)
150+
.field("table", &self.table)
151+
.field("column", &self.column)
152+
.field("datatype", &self.datatype)
153+
.field("constraint", &self.constraint)
154+
.field("file", &self.file)
155+
.field("line", &self.line)
156+
.field("routine", &self.routine)
157+
.finish()
158158
}
159159
}
160160

@@ -207,7 +207,8 @@ impl error::Error for ConnectError {
207207

208208
fn cause(&self) -> Option<&error::Error> {
209209
match *self {
210-
ConnectError::ConnectParams(ref err) | ConnectError::Ssl(ref err) => Some(&**err),
210+
ConnectError::ConnectParams(ref err) |
211+
ConnectError::Ssl(ref err) => Some(&**err),
211212
ConnectError::Db(ref err) => Some(&**err),
212213
ConnectError::Io(ref err) => Some(err),
213214
}

src/lib.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ impl InnerConnection {
245245
let user = match user {
246246
Some(user) => user,
247247
None => {
248-
return Err(ConnectError::ConnectParams("User missing from connection parameters".into()));
248+
return Err(ConnectError::ConnectParams("User missing from connection parameters"
249+
.into()));
249250
}
250251
};
251252

@@ -337,8 +338,7 @@ impl InnerConnection {
337338
}
338339
}
339340

340-
fn read_message_with_notification_nonblocking(&mut self)
341-
-> std::io::Result<Option<Backend>> {
341+
fn read_message_with_notification_nonblocking(&mut self) -> std::io::Result<Option<Backend>> {
342342
debug_assert!(!self.desynchronized);
343343
loop {
344344
match try_desync!(self, self.stream.read_message_nonblocking()) {
@@ -471,7 +471,8 @@ impl InnerConnection {
471471
let more_rows;
472472
loop {
473473
match try!(self.read_message()) {
474-
Backend::EmptyQueryResponse | Backend::CommandComplete { .. } => {
474+
Backend::EmptyQueryResponse |
475+
Backend::CommandComplete { .. } => {
475476
more_rows = false;
476477
break;
477478
}
@@ -813,10 +814,8 @@ impl InnerConnection {
813814
Backend::ReadyForQuery { .. } => break,
814815
Backend::DataRow { row } => {
815816
result.push(row.into_iter()
816-
.map(|opt| {
817-
opt.map(|b| String::from_utf8_lossy(&b).into_owned())
818-
})
819-
.collect());
817+
.map(|opt| opt.map(|b| String::from_utf8_lossy(&b).into_owned()))
818+
.collect());
820819
}
821820
Backend::CopyInResponse { .. } => {
822821
try!(self.stream.write_message(&frontend::CopyFail {
@@ -857,13 +856,13 @@ impl fmt::Debug for Connection {
857856
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
858857
let conn = self.conn.borrow();
859858
fmt.debug_struct("Connection")
860-
.field("stream", &conn.stream.get_ref())
861-
.field("cancel_data", &conn.cancel_data)
862-
.field("notifications", &conn.notifications.len())
863-
.field("transaction_depth", &conn.trans_depth)
864-
.field("desynchronized", &conn.desynchronized)
865-
.field("cached_statements", &conn.cached_statements.len())
866-
.finish()
859+
.field("stream", &conn.stream.get_ref())
860+
.field("cancel_data", &conn.cancel_data)
861+
.field("notifications", &conn.notifications.len())
862+
.field("transaction_depth", &conn.trans_depth)
863+
.field("desynchronized", &conn.desynchronized)
864+
.field("cached_statements", &conn.cached_statements.len())
865+
.finish()
867866
}
868867
}
869868

src/md5.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ macro_rules! impl_fixed_buffer( ($name:ident, $size:expr) => (
166166
fn input<F: FnMut(&[u8])>(&mut self, input: &[u8], mut func: F) {
167167
let mut i = 0;
168168

169-
// FIXME: #6304 - This local variable shouldn't be necessary.
169+
// FIXME: #6304 - This local variable shouldn't be necessary.
170170
let size = $size;
171171

172-
// If there is already data in the buffer, copy as much as we can into it and process
173-
// the data if the buffer becomes full.
172+
// If there is already data in the buffer, copy as much as we can into it and process
173+
// the data if the buffer becomes full.
174174
if self.buffer_idx != 0 {
175175
let buffer_remaining = size - self.buffer_idx;
176176
if input.len() >= buffer_remaining {
@@ -189,16 +189,16 @@ macro_rules! impl_fixed_buffer( ($name:ident, $size:expr) => (
189189
}
190190
}
191191

192-
// While we have at least a full buffer size chunks's worth of data, process that data
193-
// without copying it into the buffer
192+
// While we have at least a full buffer size chunks's worth of data, process that data
193+
// without copying it into the buffer
194194
while input.len() - i >= size {
195195
func(&input[i..i + size]);
196196
i += size;
197197
}
198198

199-
// Copy any input data into the buffer. At this point in the method, the ammount of
200-
// data left in the input vector will be less than the buffer size and the buffer will
201-
// be empty.
199+
// Copy any input data into the buffer. At this point in the method, the ammount of
200+
// data left in the input vector will be less than the buffer size and the buffer will
201+
// be empty.
202202
let input_remaining = input.len() - i;
203203
copy_memory(
204204
&input[i..],

src/message.rs

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,15 @@ pub enum Backend {
88
AuthenticationCleartextPassword,
99
AuthenticationGSS,
1010
AuthenticationKerberosV5,
11-
AuthenticationMD5Password {
12-
salt: [u8; 4],
13-
},
11+
AuthenticationMD5Password { salt: [u8; 4] },
1412
AuthenticationOk,
1513
AuthenticationSCMCredential,
1614
AuthenticationSSPI,
17-
BackendKeyData {
18-
process_id: i32,
19-
secret_key: i32,
20-
},
15+
BackendKeyData { process_id: i32, secret_key: i32 },
2116
BindComplete,
2217
CloseComplete,
23-
CommandComplete {
24-
tag: String,
25-
},
26-
CopyData {
27-
data: Vec<u8>,
28-
},
18+
CommandComplete { tag: String },
19+
CopyData { data: Vec<u8> },
2920
CopyDone,
3021
CopyInResponse {
3122
format: u8,
@@ -35,37 +26,22 @@ pub enum Backend {
3526
format: u8,
3627
column_formats: Vec<u16>,
3728
},
38-
DataRow {
39-
row: Vec<Option<Vec<u8>>>,
40-
},
29+
DataRow { row: Vec<Option<Vec<u8>>> },
4130
EmptyQueryResponse,
42-
ErrorResponse {
43-
fields: Vec<(u8, String)>,
44-
},
31+
ErrorResponse { fields: Vec<(u8, String)> },
4532
NoData,
46-
NoticeResponse {
47-
fields: Vec<(u8, String)>,
48-
},
33+
NoticeResponse { fields: Vec<(u8, String)> },
4934
NotificationResponse {
5035
process_id: i32,
5136
channel: String,
5237
payload: String,
5338
},
54-
ParameterDescription {
55-
types: Vec<Oid>,
56-
},
57-
ParameterStatus {
58-
parameter: String,
59-
value: String,
60-
},
39+
ParameterDescription { types: Vec<Oid> },
40+
ParameterStatus { parameter: String, value: String },
6141
ParseComplete,
6242
PortalSuspended,
63-
ReadyForQuery {
64-
_state: u8,
65-
},
66-
RowDescription {
67-
descriptions: Vec<RowDescriptionEntry>,
68-
},
43+
ReadyForQuery { _state: u8 },
44+
RowDescription { descriptions: Vec<RowDescriptionEntry>, },
6945
}
7046

7147
impl Backend {
@@ -89,9 +65,7 @@ impl Backend {
8965
Message::BindComplete => Backend::BindComplete,
9066
Message::CloseComplete => Backend::CloseComplete,
9167
Message::CommandComplete(body) => {
92-
Backend::CommandComplete {
93-
tag: body.tag().to_owned()
94-
}
68+
Backend::CommandComplete { tag: body.tag().to_owned() }
9569
}
9670
Message::CopyData(body) => Backend::CopyData { data: body.data().to_owned() },
9771
Message::CopyDone => Backend::CopyDone,
@@ -115,13 +89,17 @@ impl Backend {
11589
Message::EmptyQueryResponse => Backend::EmptyQueryResponse,
11690
Message::ErrorResponse(body) => {
11791
Backend::ErrorResponse {
118-
fields: try!(body.fields().map(|f| (f.type_(), f.value().to_owned())).collect()),
92+
fields: try!(body.fields()
93+
.map(|f| (f.type_(), f.value().to_owned()))
94+
.collect()),
11995
}
12096
}
12197
Message::NoData => Backend::NoData,
12298
Message::NoticeResponse(body) => {
12399
Backend::NoticeResponse {
124-
fields: try!(body.fields().map(|f| (f.type_(), f.value().to_owned())).collect()),
100+
fields: try!(body.fields()
101+
.map(|f| (f.type_(), f.value().to_owned()))
102+
.collect()),
125103
}
126104
}
127105
Message::NotificationResponse(body) => {
@@ -132,9 +110,7 @@ impl Backend {
132110
}
133111
}
134112
Message::ParameterDescription(body) => {
135-
Backend::ParameterDescription {
136-
types: try!(body.parameters().collect()),
137-
}
113+
Backend::ParameterDescription { types: try!(body.parameters().collect()) }
138114
}
139115
Message::ParameterStatus(body) => {
140116
Backend::ParameterStatus {
@@ -158,9 +134,7 @@ impl Backend {
158134
format: f.format(),
159135
}
160136
});
161-
Backend::RowDescription {
162-
descriptions: try!(fields.collect()),
163-
}
137+
Backend::RowDescription { descriptions: try!(fields.collect()) }
164138
}
165139
_ => return Err(io::Error::new(io::ErrorKind::InvalidInput, "unknown message type")),
166140
};

src/notification.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub struct Notifications<'conn> {
2727
impl<'a> fmt::Debug for Notifications<'a> {
2828
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
2929
fmt.debug_struct("Notifications")
30-
.field("pending", &self.len())
31-
.finish()
30+
.field("pending", &self.len())
31+
.finish()
3232
}
3333
}
3434

src/priv_io.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ impl MessageStream {
8585

8686
match b {
8787
Ok(b) => self.inner_read_message(b).map(Some),
88-
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock || e.kind() == io::ErrorKind::TimedOut => {
89-
Ok(None)
90-
}
88+
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock ||
89+
e.kind() == io::ErrorKind::TimedOut => Ok(None),
9190
Err(e) => Err(e),
9291
}
9392
}

src/rows.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,7 @@ impl<'trans, 'stmt> FallibleIterator for LazyRows<'trans, 'stmt> {
397397

398398
fn size_hint(&self) -> (usize, Option<usize>) {
399399
let lower = self.data.len();
400-
let upper = if self.more_rows {
401-
None
402-
} else {
403-
Some(lower)
404-
};
400+
let upper = if self.more_rows { None } else { Some(lower) };
405401
(lower, upper)
406402
}
407403
}

src/stmt.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use types::{SessionInfo, Type, ToSql};
1212
use message::Backend;
1313
use rows::{Rows, LazyRows};
1414
use transaction::Transaction;
15-
use {bad_response, Connection, StatementInternals, Result, RowsNew, InnerConnection, SessionInfoNew,
16-
LazyRowsNew, DbErrorNew, ColumnNew, StatementInfo, TransactionInternals};
15+
use {bad_response, Connection, StatementInternals, Result, RowsNew, InnerConnection,
16+
SessionInfoNew, LazyRowsNew, DbErrorNew, ColumnNew, StatementInfo, TransactionInternals};
1717

1818
/// A prepared statement.
1919
pub struct Statement<'conn> {
@@ -26,10 +26,10 @@ pub struct Statement<'conn> {
2626
impl<'a> fmt::Debug for Statement<'a> {
2727
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
2828
fmt.debug_struct("Statement")
29-
.field("name", &self.info.name)
30-
.field("parameter_types", &self.info.param_types)
31-
.field("columns", &self.info.columns)
32-
.finish()
29+
.field("name", &self.info.name)
30+
.field("parameter_types", &self.info.param_types)
31+
.field("columns", &self.info.columns)
32+
.finish()
3333
}
3434
}
3535

@@ -417,7 +417,8 @@ impl<'conn> Statement<'conn> {
417417
Ok(n) => data = &data[n..],
418418
Err(e) => {
419419
loop {
420-
if let Backend::ReadyForQuery { .. } = try!(info.conn.read_message()) {
420+
if let Backend::ReadyForQuery { .. } =
421+
try!(info.conn.read_message()) {
421422
return Err(Error::Io(e));
422423
}
423424
}

src/transaction.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use std::cell::Cell;
44
use std::fmt;
55
use std::ascii::AsciiExt;
66

7-
use {bad_response, Result, Connection, TransactionInternals, ConfigInternals,
8-
IsolationLevelNew};
7+
use {bad_response, Result, Connection, TransactionInternals, ConfigInternals, IsolationLevelNew};
98
use error::Error;
109
use rows::Rows;
1110
use stmt::Statement;
@@ -159,9 +158,9 @@ pub struct Transaction<'conn> {
159158
impl<'a> fmt::Debug for Transaction<'a> {
160159
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
161160
fmt.debug_struct("Transaction")
162-
.field("commit", &self.commit.get())
163-
.field("depth", &self.depth)
164-
.finish()
161+
.field("commit", &self.commit.get())
162+
.field("depth", &self.depth)
163+
.finish()
165164
}
166165
}
167166

@@ -199,15 +198,13 @@ impl<'conn> Transaction<'conn> {
199198
debug_assert!(self.depth == conn.trans_depth);
200199
conn.trans_depth -= 1;
201200
match (self.commit.get(), &self.savepoint_name) {
202-
(false, &Some(ref savepoint_name)) => {
203-
conn.quick_query(&format!("ROLLBACK TO {}", savepoint_name))
204-
}
205-
(false, &None) => conn.quick_query("ROLLBACK"),
206-
(true, &Some(ref savepoint_name)) => {
207-
conn.quick_query(&format!("RELEASE {}", savepoint_name))
208-
}
209-
(true, &None) => conn.quick_query("COMMIT"),
210-
}.map(|_| ())
201+
(false, &Some(ref sp)) => try!(conn.quick_query(&format!("ROLLBACK TO {}", sp))),
202+
(false, &None) => try!(conn.quick_query("ROLLBACK")),
203+
(true, &Some(ref sp)) => try!(conn.quick_query(&format!("RELEASE {}", sp))),
204+
(true, &None) => try!(conn.quick_query("COMMIT")),
205+
};
206+
207+
Ok(())
211208
}
212209

213210
/// Like `Connection::prepare`.

0 commit comments

Comments
 (0)