Skip to content

Commit 6a5f22c

Browse files
committed
Migrate postgres-protocol to 2018 edition
1 parent 14571ab commit 6a5f22c

7 files changed

Lines changed: 59 additions & 69 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ version: 2
2222
jobs:
2323
build:
2424
docker:
25-
- image: rust:1.30.1
25+
- image: rust:1.31.0
2626
environment:
2727
RUSTFLAGS: -D warnings
2828
- image: sfackler/rust-postgres-test:5

postgres-protocol/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "postgres-protocol"
33
version = "0.3.2"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
5+
edition = "2018"
56
description = "Low level Postgres protocol APIs"
67
license = "MIT/Apache-2.0"
78
repository = "https://github.com/sfackler/rust-postgres-protocol"

postgres-protocol/src/authentication/sasl.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! SASL-based authentication support.
22
3-
use base64;
43
use generic_array::typenum::U32;
54
use generic_array::GenericArray;
65
use hmac::{Hmac, Mac};
@@ -11,7 +10,6 @@ use std::io;
1110
use std::iter;
1211
use std::mem;
1312
use std::str;
14-
use stringprep;
1513

1614
const NONCE_LENGTH: usize = 24;
1715

@@ -143,7 +141,8 @@ impl ScramSha256 {
143141
v = 0x7e
144142
}
145143
v as char
146-
}).collect::<String>();
144+
})
145+
.collect::<String>();
147146

148147
ScramSha256::new_inner(password, channel_binding, nonce)
149148
}
@@ -333,7 +332,7 @@ impl<'a> Parser<'a> {
333332

334333
fn printable(&mut self) -> io::Result<&'a str> {
335334
self.take_while(|c| match c {
336-
'\x21'...'\x2b' | '\x2d'...'\x7e' => true,
335+
'\x21'..='\x2b' | '\x2d'..='\x7e' => true,
337336
_ => false,
338337
})
339338
}
@@ -346,7 +345,7 @@ impl<'a> Parser<'a> {
346345

347346
fn base64(&mut self) -> io::Result<&'a str> {
348347
self.take_while(|c| match c {
349-
'a'...'z' | 'A'...'Z' | '0'...'9' | '/' | '+' | '=' => true,
348+
'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '+' | '=' => true,
350349
_ => false,
351350
})
352351
}
@@ -359,7 +358,7 @@ impl<'a> Parser<'a> {
359358

360359
fn posit_number(&mut self) -> io::Result<u32> {
361360
let n = self.take_while(|c| match c {
362-
'0'...'9' => true,
361+
'0'..='9' => true,
363362
_ => false,
364363
})?;
365364
n.parse()

postgres-protocol/src/lib.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,7 @@
1010
//! This library assumes that the `client_encoding` backend parameter has been
1111
//! set to `UTF8`. It will most likely not behave properly if that is not the case.
1212
#![doc(html_root_url = "https://docs.rs/postgres-protocol/0.3")]
13-
#![warn(missing_docs)]
14-
extern crate base64;
15-
extern crate byteorder;
16-
extern crate bytes;
17-
extern crate fallible_iterator;
18-
extern crate generic_array;
19-
extern crate hmac;
20-
extern crate md5;
21-
extern crate memchr;
22-
extern crate rand;
23-
extern crate sha2;
24-
extern crate stringprep;
13+
#![warn(missing_docs, rust_2018_idioms)]
2514

2615
use byteorder::{BigEndian, ByteOrder};
2716
use std::io;

postgres-protocol/src/message/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::io::{self, Read};
99
use std::ops::Range;
1010
use std::str;
1111

12-
use Oid;
12+
use crate::Oid;
1313

1414
/// An enum representing Postgres backend messages.
1515
pub enum Message {

postgres-protocol/src/message/frontend.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::error::Error;
66
use std::io;
77
use std::marker;
88

9-
use {write_nullable, FromUsize, IsNull, Oid};
9+
use crate::{write_nullable, FromUsize, IsNull, Oid};
1010

1111
pub enum Message<'a> {
1212
Bind {
@@ -148,13 +148,13 @@ where
148148
}
149149

150150
pub enum BindError {
151-
Conversion(Box<Error + marker::Sync + Send>),
151+
Conversion(Box<dyn Error + marker::Sync + Send>),
152152
Serialization(io::Error),
153153
}
154154

155-
impl From<Box<Error + marker::Sync + Send>> for BindError {
155+
impl From<Box<dyn Error + marker::Sync + Send>> for BindError {
156156
#[inline]
157-
fn from(e: Box<Error + marker::Sync + Send>) -> BindError {
157+
fn from(e: Box<dyn Error + marker::Sync + Send>) -> BindError {
158158
BindError::Conversion(e)
159159
}
160160
}
@@ -179,7 +179,7 @@ pub fn bind<I, J, F, T, K>(
179179
where
180180
I: IntoIterator<Item = i16>,
181181
J: IntoIterator<Item = T>,
182-
F: FnMut(T, &mut Vec<u8>) -> Result<IsNull, Box<Error + marker::Sync + Send>>,
182+
F: FnMut(T, &mut Vec<u8>) -> Result<IsNull, Box<dyn Error + marker::Sync + Send>>,
183183
K: IntoIterator<Item = i16>,
184184
{
185185
buf.push(b'B');
@@ -225,7 +225,8 @@ pub fn cancel_request(process_id: i32, secret_key: i32, buf: &mut Vec<u8>) {
225225
buf.write_i32::<BigEndian>(80877102).unwrap();
226226
buf.write_i32::<BigEndian>(process_id).unwrap();
227227
buf.write_i32::<BigEndian>(secret_key)
228-
}).unwrap();
228+
})
229+
.unwrap();
229230
}
230231

231232
#[inline]

0 commit comments

Comments
 (0)