Skip to content

Update to rust master #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl IntoConnectParams for Url {

let database = if !path.is_empty() {
// path contains the leading /
let (_, path) = path[].slice_shift_char();
let (_, path) = path[].slice_shift_char().unwrap();
Some(path.into_string())
} else {
Option::None
Expand Down Expand Up @@ -351,7 +351,7 @@ impl InnerConnection {
Option::None => {}
}

try!(conn.write_messages([StartupMessage {
try!(conn.write_messages(&[StartupMessage {
version: message::PROTOCOL_VERSION,
parameters: options[]
}]));
Expand Down Expand Up @@ -410,7 +410,7 @@ impl InnerConnection {
AuthenticationOk => return Ok(()),
AuthenticationCleartextPassword => {
let pass = try!(user.password.ok_or(ConnectError::MissingPassword));
try!(self.write_messages([PasswordMessage {
try!(self.write_messages(&[PasswordMessage {
password: pass[],
}]));
}
Expand All @@ -422,9 +422,9 @@ impl InnerConnection {
let output = hasher.finalize()[].to_hex();
let hasher = Hasher::new(MD5);
hasher.update(output.as_bytes());
hasher.update(salt);
hasher.update(&salt);
let output = format!("md5{}", hasher.finalize()[].to_hex());
try!(self.write_messages([PasswordMessage {
try!(self.write_messages(&[PasswordMessage {
password: output[]
}]));
}
Expand Down Expand Up @@ -458,11 +458,11 @@ impl InnerConnection {
let stmt_name = format!("s{}", self.next_stmt_id);
self.next_stmt_id += 1;

try!(self.write_messages([
try!(self.write_messages(&[
Parse {
name: stmt_name[],
query: query,
param_types: []
param_types: &[]
},
Describe {
variant: b'S',
Expand Down Expand Up @@ -548,7 +548,7 @@ impl InnerConnection {
}

fn close_statement(&mut self, stmt_name: &str) -> Result<()> {
try!(self.write_messages([
try!(self.write_messages(&[
Close {
variant: b'S',
name: stmt_name,
Expand Down Expand Up @@ -605,7 +605,7 @@ impl InnerConnection {

fn quick_query(&mut self, query: &str) -> Result<Vec<Vec<Option<String>>>> {
check_desync!(self);
try!(self.write_messages([Query { query: query }]));
try!(self.write_messages(&[Query { query: query }]));

let mut result = vec![];
loop {
Expand All @@ -617,7 +617,7 @@ impl InnerConnection {
}).collect());
}
CopyInResponse { .. } => {
try!(self.write_messages([
try!(self.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand All @@ -636,7 +636,7 @@ impl InnerConnection {
fn finish_inner(&mut self) -> Result<()> {
check_desync!(self);
self.canary = 0;
try!(self.write_messages([Terminate]));
try!(self.write_messages(&[Terminate]));
Ok(())
}
}
Expand Down Expand Up @@ -1095,13 +1095,13 @@ impl<'conn> Statement<'conn> {
values.push(try!(param.to_sql(ty)));
};

try!(conn.write_messages([
try!(conn.write_messages(&[
Bind {
portal: portal_name,
statement: self.name[],
formats: [1],
formats: &[1],
values: values[],
result_formats: [1]
result_formats: &[1]
},
Execute {
portal: portal_name,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ impl<'conn> Statement<'conn> {
break;
}
CopyInResponse { .. } => {
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand Down Expand Up @@ -1273,7 +1273,7 @@ impl<'stmt> Rows<'stmt> {
fn finish_inner(&mut self) -> Result<()> {
let mut conn = self.stmt.conn.conn.borrow_mut();
check_desync!(conn);
try!(conn.write_messages([
try!(conn.write_messages(&[
Close {
variant: b'P',
name: self.name[]
Expand Down Expand Up @@ -1312,7 +1312,7 @@ impl<'stmt> Rows<'stmt> {
return DbError::new(fields);
}
CopyInResponse { .. } => {
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyFail {
message: "COPY queries cannot be directly executed",
},
Expand All @@ -1328,7 +1328,7 @@ impl<'stmt> Rows<'stmt> {
}

fn execute(&mut self) -> Result<()> {
try!(self.stmt.conn.write_messages([
try!(self.stmt.conn.write_messages(&[
Execute {
portal: self.name[],
max_rows: self.row_limit
Expand Down Expand Up @@ -1417,7 +1417,7 @@ impl<'stmt> Row<'stmt> {
/// # use postgres::{Connection, SslMode};
/// # let conn = Connection::connect("", &SslMode::None).unwrap();
/// # let stmt = conn.prepare("").unwrap();
/// # let mut result = stmt.query([]).unwrap();
/// # let mut result = stmt.query(&[]).unwrap();
/// # let row = result.next().unwrap();
/// let foo: i32 = row.get(0u);
/// let bar: String = row.get("bar");
Expand Down Expand Up @@ -1520,13 +1520,13 @@ impl<'a> CopyInStatement<'a> {
where I: Iterator<J>, J: Iterator<&'b ToSql + 'b> {
let mut conn = self.conn.conn.borrow_mut();

try!(conn.write_messages([
try!(conn.write_messages(&[
Bind {
portal: "",
statement: self.name[],
formats: [],
values: [],
result_formats: []
formats: &[],
values: &[],
result_formats: &[]
},
Execute {
portal: "",
Expand Down Expand Up @@ -1605,7 +1605,7 @@ impl<'a> CopyInStatement<'a> {
}

let _ = buf.write_be_i16(-1);
try!(conn.write_messages([
try!(conn.write_messages(&[
CopyData {
data: buf.unwrap()[],
},
Expand Down
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ fn read_auth_message(buf: &mut MemReader) -> IoResult<BackendMessage> {
3 => AuthenticationCleartextPassword,
5 => {
let mut salt = [0, ..4];
try!(buf.read_at_least(salt.len(), salt));
try!(buf.read_at_least(salt.len(), &mut salt));
AuthenticationMD5Password { salt: salt }
},
6 => AuthenticationSCMCredential,
Expand Down
6 changes: 3 additions & 3 deletions src/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn decode_inner<T: BytesContainer>(c: T, full_url: bool) -> DecodeResult<String>
};

// Only decode some characters if full_url:
match num::from_str_radix::<uint>(str::from_utf8(bytes).unwrap(), 16u).unwrap() as u8 as char {
match num::from_str_radix::<uint>(str::from_utf8(&bytes).unwrap(), 16u).unwrap() as u8 as char {
// gen-delims:
':' | '/' | '?' | '#' | '[' | ']' | '@' |

Expand Down Expand Up @@ -463,8 +463,8 @@ fn get_query_fragment(rawurl: &str) -> DecodeResult<(Query, Option<String>)> {
};

match before_fragment.slice_shift_char() {
(Some('?'), rest) => Ok((try!(query_from_str(rest)), fragment)),
(None, "") => Ok((vec!(), fragment)),
Some(('?', rest)) => Ok((try!(query_from_str(rest)), fragment)),
None => Ok((vec!(), fragment)),
_ => Err(format!("Query didn't start with '?': '{}..'", before_fragment)),
}
}
Expand Down