Skip to content

Commit b295092

Browse files
committed
Update dependencies
1 parent 455c5c9 commit b295092

File tree

10 files changed

+46
-39
lines changed

10 files changed

+46
-39
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@ edition = "2018"
1515
travis-ci = { repository = "blackbeam/rust_mysql_common" }
1616

1717
[dependencies]
18-
base64 = "0.12"
19-
bigdecimal = { version = "0.1", features = ["serde"] }
18+
base64 = "0.13"
19+
bigdecimal = { version = "0.2", features = ["serde"] }
2020
bitflags = "1"
2121
byteorder = "1"
22-
bytes = "0.5.2"
22+
bytes = "0.6.0"
2323
chrono = { version = "0.4", features = ["serde"] }
2424
flate2 = { version = "1.0", default-features = false }
2525
lazy_static = "1"
2626
lexical = "5.2"
27-
num-bigint = { version = "0.2", features = ["i128"] }
27+
num-bigint = { version = "0.3" }
2828
num-traits = { version = "0.2", features = ["i128"] }
2929
rand = "0.7"
3030
regex = "1"
3131
rust_decimal = "1.0"
3232
sha1 = "0.6"
33-
sha2 = "0.8"
33+
sha2 = "0.9"
3434
time = { version = "0.2", default-features = false, features = ["std"] }
3535
twox-hash = "1"
3636
uuid = "0.8"
3737
serde = "1"
3838
serde_json = "1"
3939

4040
[dev-dependencies]
41-
proptest = "0.9.2"
41+
proptest = "0.10.1"
4242

4343
[profile.bench]
4444
debug = true

src/crypto/rsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl PublicKey {
162162

163163
/// Returns number of octets in the modulus.
164164
pub fn num_octets(&self) -> usize {
165-
(self.modulus.bits() + 6) >> 3
165+
(self.modulus.bits() as usize + 6) >> 3
166166
}
167167

168168
/// Returns modulus of the public key.

src/named_params.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ use self::ParserState::*;
2727
/// * names of named parameters (if any) in order of appearance in `query`. Same name may
2828
/// appear multiple times if named parameter used more than once.
2929
/// * query string to pass to MySql (named parameters replaced with `?`).
30-
pub fn parse_named_params<'a>(
31-
query: &'a str,
32-
) -> Result<(Option<Vec<String>>, Cow<'a, str>), MixedParamsError> {
30+
pub fn parse_named_params(
31+
query: &str,
32+
) -> Result<(Option<Vec<String>>, Cow<'_, str>), MixedParamsError> {
3333
let mut state = TopLevel;
3434
let mut have_positional = false;
3535
let mut cur_param = 0;

src/packets.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,7 @@ impl<'a> ErrPacket<'a> {
569569

570570
/// Returns false if this error packet contains progress report.
571571
pub fn is_error(&self) -> bool {
572-
match *self {
573-
ErrPacket::Error(..) => true,
574-
_ => false,
575-
}
572+
matches!(self, ErrPacket::Error(..))
576573
}
577574

578575
/// Returns true if this error packet contains progress report.

src/proto/codec/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
// option. All files in the project carrying such notice may not be copied,
77
// modified, or distributed except according to those terms.
88

9-
use std::fmt;
10-
use std::io;
9+
use std::{fmt, io};
1110

1211
#[derive(Debug)]
1312
pub enum PacketCodecError {

src/proto/codec/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ use std::{
1919
io::Read,
2020
mem,
2121
num::NonZeroUsize,
22+
ptr::slice_from_raw_parts_mut,
2223
};
2324

2425
use self::error::PacketCodecError;
2526
use crate::constants::{DEFAULT_MAX_ALLOWED_PACKET, MAX_PAYLOAD_LEN, MIN_COMPRESS_LENGTH};
2627

2728
pub mod error;
2829

29-
/// Helper that transmutes `&mut [MaybeUninit<u8>]` to `&mut [u8]`.
30-
pub(crate) unsafe fn transmute_buf(buf: &mut [mem::MaybeUninit<u8>]) -> &mut [u8] {
31-
&mut *(buf as *mut [mem::MaybeUninit<u8>] as *mut [u8])
32-
}
33-
3430
/// Will split given `packet` to MySql packet chunks and write into `dst`.
3531
///
3632
/// Chunk ids will start with given `seq_id`.
@@ -80,7 +76,10 @@ pub fn compress(
8076
loop {
8177
dst.reserve(max(chunk.len().saturating_sub(read), 1));
8278
let dst_buf = &mut dst.bytes_mut()[7 + read..];
83-
match encoder.read(transmute_buf(dst_buf))? {
79+
match encoder.read(&mut *slice_from_raw_parts_mut(
80+
dst_buf.as_mut_ptr(),
81+
dst_buf.len(),
82+
))? {
8483
0 => break,
8584
count => read += count,
8685
}
@@ -316,8 +315,10 @@ impl CompDecoder {
316315
dst.reserve(plain_len.get());
317316
unsafe {
318317
let mut decoder = ZlibDecoder::new(&src[..needed.get()]);
319-
decoder.read_exact(transmute_buf(
320-
&mut dst.bytes_mut()[..plain_len.get()],
318+
let dst_buf = &mut dst.bytes_mut()[..plain_len.get()];
319+
decoder.read_exact(&mut *slice_from_raw_parts_mut(
320+
dst_buf.as_mut_ptr(),
321+
dst_buf.len(),
321322
))?;
322323
dst.advance_mut(plain_len.get());
323324
}

src/proto/sync_framed.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ use crate::{
1313
proto::codec::{error::PacketCodecError, PacketCodec},
1414
};
1515

16-
use std::io::{
17-
Error,
18-
ErrorKind::{Interrupted, Other},
19-
Read, Write,
16+
use std::{
17+
io::{
18+
Error,
19+
ErrorKind::{Interrupted, Other},
20+
Read, Write,
21+
},
22+
ptr::slice_from_raw_parts_mut,
2023
};
2124

2225
// stolen from futures-rs
@@ -148,10 +151,10 @@ where
148151
Some(item) => return Some(item),
149152
None => unsafe {
150153
self.in_buf.reserve(1);
151-
match with_interrupt!(self
152-
.stream
153-
.read(super::codec::transmute_buf(self.in_buf.bytes_mut())))
154-
{
154+
match with_interrupt!(self.stream.read(&mut *slice_from_raw_parts_mut(
155+
self.in_buf.bytes_mut().as_mut_ptr(),
156+
self.in_buf.bytes_mut().len()
157+
))) {
155158
Ok(0) => self.eof = true,
156159
Ok(x) => {
157160
self.in_buf.advance_mut(x);

src/row/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ impl Row {
6060
self.values.len()
6161
}
6262

63+
/// Returns true if the row has a length of 0.
64+
pub fn is_empty(&self) -> bool {
65+
self.values.is_empty()
66+
}
67+
6368
/// Returns columns of this row.
6469
pub fn columns_ref(&self) -> &[Column] {
6570
&*self.columns

src/scramble.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ pub fn scramble_native(nonce: &[u8], password: &[u8]) -> Option<[u8; 20]> {
6161
pub fn scramble_sha256(nonce: &[u8], password: &[u8]) -> Option<[u8; 32]> {
6262
fn sha256_1(bytes: impl AsRef<[u8]>) -> [u8; 32] {
6363
let mut hasher = Sha256::default();
64-
hasher.input(bytes.as_ref());
65-
to_u8_32(hasher.result())
64+
hasher.update(bytes.as_ref());
65+
to_u8_32(hasher.finalize())
6666
}
6767

6868
fn sha256_2(bytes1: impl AsRef<[u8]>, bytes2: impl AsRef<[u8]>) -> [u8; 32] {
6969
let mut hasher = Sha256::default();
70-
hasher.input(bytes1.as_ref());
71-
hasher.input(bytes2.as_ref());
72-
to_u8_32(hasher.result())
70+
hasher.update(bytes1.as_ref());
71+
hasher.update(bytes2.as_ref());
72+
to_u8_32(hasher.finalize())
7373
}
7474

7575
if password.is_empty() {

src/value/convert/bigdecimal.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
//! This module implements conversion from/to `Value` for `BigDecimal` type.
1010
11+
use std::convert::TryInto;
12+
1113
use bigdecimal::BigDecimal;
1214

1315
use super::{ConvIr, FromValue, FromValueError, ParseIr, Value};
@@ -25,11 +27,11 @@ impl ConvIr<BigDecimal> for ParseIr<BigDecimal> {
2527
}),
2628
Value::Float(x) => Ok(ParseIr {
2729
value: Value::Float(x),
28-
output: x.into(),
30+
output: x.try_into().map_err(|_| FromValueError(Value::Float(x)))?,
2931
}),
3032
Value::Double(x) => Ok(ParseIr {
3133
value: Value::Double(x),
32-
output: x.into(),
34+
output: x.try_into().map_err(|_| FromValueError(Value::Double(x)))?,
3335
}),
3436
Value::Bytes(bytes) => match BigDecimal::parse_bytes(&*bytes, 10) {
3537
Some(x) => Ok(ParseIr {

0 commit comments

Comments
 (0)