Skip to content

Commit 015b29e

Browse files
committed
Change from pin-project-lite to pin-project.
For PinnedDrop support.
1 parent b2c5723 commit 015b29e

File tree

6 files changed

+56
-62
lines changed

6 files changed

+56
-62
lines changed

tokio-postgres/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ futures = "0.3"
4545
log = "0.4"
4646
parking_lot = "0.11"
4747
percent-encoding = "2.0"
48-
pin-project-lite = "0.2"
48+
pin-project = "1.0"
4949
phf = "0.8"
5050
postgres-protocol = { version = "0.5.0", path = "../postgres-protocol" }
5151
postgres-types = { version = "0.1.2", path = "../postgres-types" }

tokio-postgres/src/binary_copy.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{slice_iter, CopyInSink, CopyOutStream, Error};
55
use byteorder::{BigEndian, ByteOrder};
66
use bytes::{Buf, BufMut, Bytes, BytesMut};
77
use futures::{ready, SinkExt, Stream};
8-
use pin_project_lite::pin_project;
8+
use pin_project::pin_project;
99
use postgres_types::BorrowToSql;
1010
use std::convert::TryFrom;
1111
use std::io;
@@ -18,16 +18,15 @@ use std::task::{Context, Poll};
1818
const MAGIC: &[u8] = b"PGCOPY\n\xff\r\n\0";
1919
const HEADER_LEN: usize = MAGIC.len() + 4 + 4;
2020

21-
pin_project! {
22-
/// A type which serializes rows into the PostgreSQL binary copy format.
23-
///
24-
/// The copy *must* be explicitly completed via the `finish` method. If it is not, the copy will be aborted.
25-
pub struct BinaryCopyInWriter {
26-
#[pin]
27-
sink: CopyInSink<Bytes>,
28-
types: Vec<Type>,
29-
buf: BytesMut,
30-
}
21+
/// A type which serializes rows into the PostgreSQL binary copy format.
22+
///
23+
/// The copy *must* be explicitly completed via the `finish` method. If it is not, the copy will be aborted.
24+
#[pin_project]
25+
pub struct BinaryCopyInWriter {
26+
#[pin]
27+
sink: CopyInSink<Bytes>,
28+
types: Vec<Type>,
29+
buf: BytesMut,
3130
}
3231

3332
impl BinaryCopyInWriter {
@@ -115,14 +114,13 @@ struct Header {
115114
has_oids: bool,
116115
}
117116

118-
pin_project! {
119-
/// A stream of rows deserialized from the PostgreSQL binary copy format.
120-
pub struct BinaryCopyOutStream {
121-
#[pin]
122-
stream: CopyOutStream,
123-
types: Arc<Vec<Type>>,
124-
header: Option<Header>,
125-
}
117+
/// A stream of rows deserialized from the PostgreSQL binary copy format.
118+
#[pin_project]
119+
pub struct BinaryCopyOutStream {
120+
#[pin]
121+
stream: CopyOutStream,
122+
types: Arc<Vec<Type>>,
123+
header: Option<Header>,
126124
}
127125

128126
impl BinaryCopyOutStream {

tokio-postgres/src/copy_in.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use futures::channel::mpsc;
88
use futures::future;
99
use futures::{ready, Sink, SinkExt, Stream, StreamExt};
1010
use log::debug;
11-
use pin_project_lite::pin_project;
11+
use pin_project::pin_project;
1212
use postgres_protocol::message::backend::Message;
1313
use postgres_protocol::message::frontend;
1414
use postgres_protocol::message::frontend::CopyData;
@@ -69,21 +69,20 @@ enum SinkState {
6969
Reading,
7070
}
7171

72-
pin_project! {
73-
/// A sink for `COPY ... FROM STDIN` query data.
74-
///
75-
/// The copy *must* be explicitly completed via the `Sink::close` or `finish` methods. If it is
76-
/// not, the copy will be aborted.
77-
pub struct CopyInSink<T> {
78-
#[pin]
79-
sender: mpsc::Sender<CopyInMessage>,
80-
responses: Responses,
81-
buf: BytesMut,
82-
state: SinkState,
83-
#[pin]
84-
_p: PhantomPinned,
85-
_p2: PhantomData<T>,
86-
}
72+
/// A sink for `COPY ... FROM STDIN` query data.
73+
///
74+
/// The copy *must* be explicitly completed via the `Sink::close` or `finish` methods. If it is
75+
/// not, the copy will be aborted.
76+
#[pin_project]
77+
pub struct CopyInSink<T> {
78+
#[pin]
79+
sender: mpsc::Sender<CopyInMessage>,
80+
responses: Responses,
81+
buf: BytesMut,
82+
state: SinkState,
83+
#[pin]
84+
_p: PhantomPinned,
85+
_p2: PhantomData<T>,
8786
}
8887

8988
impl<T> CopyInSink<T>

tokio-postgres/src/copy_out.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{query, slice_iter, Error, Statement};
55
use bytes::Bytes;
66
use futures::{ready, Stream};
77
use log::debug;
8-
use pin_project_lite::pin_project;
8+
use pin_project::pin_project;
99
use postgres_protocol::message::backend::Message;
1010
use std::marker::PhantomPinned;
1111
use std::pin::Pin;
@@ -38,13 +38,12 @@ async fn start(client: &InnerClient, buf: Bytes) -> Result<Responses, Error> {
3838
Ok(responses)
3939
}
4040

41-
pin_project! {
42-
/// A stream of `COPY ... TO STDOUT` query data.
43-
pub struct CopyOutStream {
44-
responses: Responses,
45-
#[pin]
46-
_p: PhantomPinned,
47-
}
41+
/// A stream of `COPY ... TO STDOUT` query data.
42+
#[pin_project]
43+
pub struct CopyOutStream {
44+
responses: Responses,
45+
#[pin]
46+
_p: PhantomPinned,
4847
}
4948

5049
impl Stream for CopyOutStream {

tokio-postgres/src/query.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{Error, Portal, Row, Statement};
66
use bytes::{Bytes, BytesMut};
77
use futures::{ready, Stream};
88
use log::{debug, log_enabled, Level};
9-
use pin_project_lite::pin_project;
9+
use pin_project::pin_project;
1010
use postgres_protocol::message::backend::Message;
1111
use postgres_protocol::message::frontend;
1212
use std::fmt;
@@ -188,14 +188,13 @@ where
188188
}
189189
}
190190

191-
pin_project! {
192-
/// A stream of table rows.
193-
pub struct RowStream {
194-
statement: Statement,
195-
responses: Responses,
196-
#[pin]
197-
_p: PhantomPinned,
198-
}
191+
/// A stream of table rows.
192+
#[pin_project]
193+
pub struct RowStream {
194+
statement: Statement,
195+
responses: Responses,
196+
#[pin]
197+
_p: PhantomPinned,
199198
}
200199

201200
impl Stream for RowStream {

tokio-postgres/src/simple_query.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bytes::Bytes;
66
use fallible_iterator::FallibleIterator;
77
use futures::{ready, Stream};
88
use log::debug;
9-
use pin_project_lite::pin_project;
9+
use pin_project::pin_project;
1010
use postgres_protocol::message::backend::Message;
1111
use postgres_protocol::message::frontend;
1212
use std::marker::PhantomPinned;
@@ -52,14 +52,13 @@ fn encode(client: &InnerClient, query: &str) -> Result<Bytes, Error> {
5252
})
5353
}
5454

55-
pin_project! {
56-
/// A stream of simple query results.
57-
pub struct SimpleQueryStream {
58-
responses: Responses,
59-
columns: Option<Arc<[String]>>,
60-
#[pin]
61-
_p: PhantomPinned,
62-
}
55+
/// A stream of simple query results.
56+
#[pin_project]
57+
pub struct SimpleQueryStream {
58+
responses: Responses,
59+
columns: Option<Arc<[String]>>,
60+
#[pin]
61+
_p: PhantomPinned,
6362
}
6463

6564
impl Stream for SimpleQueryStream {

0 commit comments

Comments
 (0)