mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-02-01 21:48:07 +00:00
remove pin-project workaround
This commit is contained in:
parent
672f83c00e
commit
de14a206ff
21
Cargo.lock
generated
21
Cargo.lock
generated
@ -1097,24 +1097,6 @@ name = "percent-encoding"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.1.4"
|
||||
@ -1510,7 +1492,6 @@ dependencies = [
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-bigint 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2202,8 +2183,6 @@ dependencies = [
|
||||
"checksum paw-raw 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f0b59668fe80c5afe998f0c0bf93322bf2cd66cafeeb80581f291716f3467f2"
|
||||
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
"checksum pin-project 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7804a463a8d9572f13453c516a5faea534a2403d7ced2f0c7e100eeff072772c"
|
||||
"checksum pin-project-internal 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "385322a45f2ecf3410c68d2a549a4a2685e8051d0f278e39743ff4e451cb9b3f"
|
||||
"checksum pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae"
|
||||
"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587"
|
||||
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
||||
|
||||
@ -49,7 +49,6 @@ sha2 = { version = "0.8.1", default-features = false, optional = true }
|
||||
tokio = { version = "0.2.13", default-features = false, features = [ "dns", "fs", "time", "tcp" ], optional = true }
|
||||
url = { version = "2.1.1", default-features = false }
|
||||
uuid = { version = "0.8.1", default-features = false, optional = true, features = [ "std" ] }
|
||||
pin-project = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
matches = "0.1.8"
|
||||
|
||||
@ -5,7 +5,6 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use futures_util::ready;
|
||||
use pin_project::{pin_project, pinned_drop};
|
||||
|
||||
use crate::runtime::{AsyncRead, AsyncReadExt, AsyncWrite};
|
||||
|
||||
@ -26,9 +25,7 @@ pub struct BufStream<S> {
|
||||
rbuf_windex: usize,
|
||||
}
|
||||
|
||||
#[pin_project(PinnedDrop)]
|
||||
pub struct GuardedFlush<'a, S: 'a> {
|
||||
#[pin]
|
||||
stream: &'a mut S,
|
||||
buf: io::Cursor<&'a mut Vec<u8>>,
|
||||
}
|
||||
@ -172,27 +169,29 @@ macro_rules! ret_if_none {
|
||||
impl<'a, S: AsyncWrite + Unpin> Future for GuardedFlush<'a, S> {
|
||||
type Output = io::Result<()>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let mut this = self.project();
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let Self {
|
||||
ref mut stream,
|
||||
ref mut buf,
|
||||
} = *self;
|
||||
|
||||
loop {
|
||||
let buf = this.buf.fill_buf()?;
|
||||
let read = buf.fill_buf()?;
|
||||
|
||||
if !buf.is_empty() {
|
||||
let written = ready!(this.stream.as_mut().poll_write(cx, buf)?);
|
||||
this.buf.consume(written);
|
||||
if !read.is_empty() {
|
||||
let written = ready!(Pin::new(&mut *stream).poll_write(cx, read)?);
|
||||
buf.consume(written);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.stream.poll_flush(cx)
|
||||
Pin::new(stream).poll_flush(cx)
|
||||
}
|
||||
}
|
||||
|
||||
#[pinned_drop]
|
||||
impl<'a, S> PinnedDrop for GuardedFlush<'a, S> {
|
||||
fn drop(mut self: Pin<&mut Self>) {
|
||||
impl<'a, S> Drop for GuardedFlush<'a, S> {
|
||||
fn drop(&mut self) {
|
||||
// clear the buffer regardless of whether the flush succeeded or not
|
||||
self.buf.get_mut().clear();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user