diff --git a/Cargo.toml b/Cargo.toml index 7036a8a..65f45dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-postgres" -version = "0.5.1" +version = "0.7.0" authors = ["Hexilee "] edition = "2018" license = "MIT" @@ -21,18 +21,18 @@ codecov = { repository = "Hexilee/async-postgres" } # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +async-std = "1.10" bytes = "0.5" -tokio-postgres = { version = "0.5", default-features = false } -tokio = "0.2" -async-std = "1.6" +tokio = "1" +tokio-postgres = { version = "0.7", default-features = false, features = ["runtime"] } futures = { version = "0.3", default-features = false } [dev-dependencies] -async-std = { version = "1.6", features = ["attributes"] } -tokio = { version = "0.2", features = ["full"] } -tokio-postgres = "0.5" -postgres-native-tls = "0.3" +async-std = { version = "1.10", features = ["attributes"] } +tokio = { version = "1", features = ["full"] } +tokio-postgres = "0.7" +postgres-native-tls = "0.5" native-tls = "0.2" [features] @@ -41,16 +41,20 @@ full = ["all-types"] all-types = [ "with-bit-vec-0_6", "with-chrono-0_4", - "with-eui48-0_4", - "with-geo-types-0_4", + "with-eui48-1", + "with-geo-types-0_7", "with-serde_json-1", "with-uuid-0_8", - "with-time-0_2" + "with-time-0_3" ] + with-bit-vec-0_6 = ["tokio-postgres/with-bit-vec-0_6"] with-chrono-0_4 = ["tokio-postgres/with-chrono-0_4"] with-eui48-0_4 = ["tokio-postgres/with-eui48-0_4"] -with-geo-types-0_4 = ["tokio-postgres/with-geo-types-0_4"] +with-eui48-1 = ["tokio-postgres/with-eui48-1"] +with-geo-types-0_6 = ["tokio-postgres/with-geo-types-0_6"] +with-geo-types-0_7 = ["tokio-postgres/with-geo-types-0_7"] with-serde_json-1 = ["tokio-postgres/with-serde_json-1"] with-uuid-0_8 = ["tokio-postgres/with-uuid-0_8"] with-time-0_2 = ["tokio-postgres/with-time-0_2"] +with-time-0_3 = ["tokio-postgres/with-time-0_3"] \ No newline at end of file diff --git a/src/socket.rs b/src/socket.rs index 87466b8..e485272 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -1,8 +1,8 @@ use async_std::io::{self, Read, Write}; -use std::mem::MaybeUninit; use std::pin::Pin; use std::task::{Context, Poll}; -use tokio::io::{AsyncRead, AsyncWrite}; +use futures::ready; +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; /// A alias for 'static + Unpin + Send + Read + Write pub trait AsyncReadWriter: 'static + Unpin + Send + Read + Write {} @@ -22,18 +22,15 @@ where } impl AsyncRead for Socket { - #[inline] - unsafe fn prepare_uninitialized_buffer(&self, _buf: &mut [MaybeUninit]) -> bool { - false - } - #[inline] fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8], - ) -> Poll> { - Pin::new(&mut self.0).poll_read(cx, buf) + buf: &mut ReadBuf<'_>, + ) -> Poll> { + let read_size = ready!(Pin::new(&mut self.0).poll_read(cx, buf.initialize_unfilled()))?; + buf.advance(read_size); + Poll::Ready(Ok(())) } } diff --git a/tests/benchmark.rs b/tests/benchmark.rs index 1f54ccf..06f1de4 100644 --- a/tests/benchmark.rs +++ b/tests/benchmark.rs @@ -12,7 +12,7 @@ fn benchmark() -> Result<(), Box> { let queries = TASKS * QUERIES; let tcp_url = var("TCP_URL")?; let uds_url = var("UDS_URL")?; - let mut tokio_rr = tokio::runtime::Runtime::new()?; + let tokio_rr = tokio::runtime::Runtime::new()?; println!("Benchmark concurrency({}), queries({}):", TASKS, queries); println!(" - async-postgres on async-std runtime:");