Skip to content

Commit e0d1137

Browse files
committed
Rename raw cancel query
1 parent 940cbb8 commit e0d1137

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

tokio-postgres/src/config.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ use tokio_io::{AsyncRead, AsyncWrite};
1717

1818
#[cfg(feature = "runtime")]
1919
use crate::proto::ConnectFuture;
20-
use crate::proto::HandshakeFuture;
20+
use crate::proto::{CancelQueryRawFuture, HandshakeFuture};
21+
use crate::{CancelData, CancelQueryRaw, Error, Handshake, TlsMode};
2122
#[cfg(feature = "runtime")]
2223
use crate::{Connect, MakeTlsMode, Socket};
23-
use crate::{Error, Handshake, TlsMode};
2424

2525
#[cfg(feature = "runtime")]
2626
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -277,6 +277,19 @@ impl Config {
277277
{
278278
Connect(ConnectFuture::new(make_tls_mode, Ok(self.clone())))
279279
}
280+
281+
pub fn cancel_query_raw<S, T>(
282+
&self,
283+
stream: S,
284+
tls_mode: T,
285+
cancel_data: CancelData,
286+
) -> CancelQueryRaw<S, T>
287+
where
288+
S: AsyncRead + AsyncWrite,
289+
T: TlsMode<S>,
290+
{
291+
CancelQueryRaw(CancelQueryRawFuture::new(stream, tls_mode, cancel_data))
292+
}
280293
}
281294

282295
impl FromStr for Config {

tokio-postgres/src/lib.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ use tokio_io::{AsyncRead, AsyncWrite};
116116

117117
pub use crate::config::*;
118118
pub use crate::error::*;
119-
use crate::proto::CancelFuture;
120119
pub use crate::row::*;
121120
#[cfg(feature = "runtime")]
122121
pub use crate::socket::Socket;
@@ -152,14 +151,6 @@ where
152151
Connect(proto::ConnectFuture::new(tls_mode, config.parse()))
153152
}
154153

155-
pub fn cancel_query<S, T>(stream: S, tls_mode: T, cancel_data: CancelData) -> CancelQuery<S, T>
156-
where
157-
S: AsyncRead + AsyncWrite,
158-
T: TlsMode<S>,
159-
{
160-
CancelQuery(CancelFuture::new(stream, tls_mode, cancel_data))
161-
}
162-
163154
pub struct Client(proto::Client);
164155

165156
impl Client {
@@ -265,12 +256,12 @@ pub enum AsyncMessage {
265256
}
266257

267258
#[must_use = "futures do nothing unless polled"]
268-
pub struct CancelQuery<S, T>(proto::CancelFuture<S, T>)
259+
pub struct CancelQueryRaw<S, T>(proto::CancelQueryRawFuture<S, T>)
269260
where
270261
S: AsyncRead + AsyncWrite,
271262
T: TlsMode<S>;
272263

273-
impl<S, T> Future for CancelQuery<S, T>
264+
impl<S, T> Future for CancelQueryRaw<S, T>
274265
where
275266
S: AsyncRead + AsyncWrite,
276267
T: TlsMode<S>,

tokio-postgres/src/proto/cancel.rs renamed to tokio-postgres/src/proto/cancel_query_raw.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::proto::TlsFuture;
99
use crate::{CancelData, TlsMode};
1010

1111
#[derive(StateMachineFuture)]
12-
pub enum Cancel<S, T>
12+
pub enum CancelQueryRaw<S, T>
1313
where
1414
S: AsyncRead + AsyncWrite,
1515
T: TlsMode<S>,
@@ -31,7 +31,7 @@ where
3131
Failed(Error),
3232
}
3333

34-
impl<S, T> PollCancel<S, T> for Cancel<S, T>
34+
impl<S, T> PollCancelQueryRaw<S, T> for CancelQueryRaw<S, T>
3535
where
3636
S: AsyncRead + AsyncWrite,
3737
T: TlsMode<S>,
@@ -69,12 +69,12 @@ where
6969
}
7070
}
7171

72-
impl<S, T> CancelFuture<S, T>
72+
impl<S, T> CancelQueryRawFuture<S, T>
7373
where
7474
S: AsyncRead + AsyncWrite,
7575
T: TlsMode<S>,
7676
{
77-
pub fn new(stream: S, tls_mode: T, cancel_data: CancelData) -> CancelFuture<S, T> {
78-
Cancel::start(TlsFuture::new(stream, tls_mode), cancel_data)
77+
pub fn new(stream: S, tls_mode: T, cancel_data: CancelData) -> CancelQueryRawFuture<S, T> {
78+
CancelQueryRaw::start(TlsFuture::new(stream, tls_mode), cancel_data)
7979
}
8080
}

tokio-postgres/src/proto/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ macro_rules! try_ready_closed {
1919
}
2020

2121
mod bind;
22-
mod cancel;
22+
mod cancel_query_raw;
2323
mod client;
2424
mod codec;
2525
#[cfg(feature = "runtime")]
@@ -44,7 +44,7 @@ mod typeinfo_composite;
4444
mod typeinfo_enum;
4545

4646
pub use crate::proto::bind::BindFuture;
47-
pub use crate::proto::cancel::CancelFuture;
47+
pub use crate::proto::cancel_query_raw::CancelQueryRawFuture;
4848
pub use crate::proto::client::Client;
4949
pub use crate::proto::codec::PostgresCodec;
5050
#[cfg(feature = "runtime")]

tokio-postgres/tests/test/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn cancel_query() {
245245
})
246246
.then(|r| {
247247
let s = r.unwrap();
248-
tokio_postgres::cancel_query(s, NoTls, cancel_data)
248+
tokio_postgres::Config::new().cancel_query_raw(s, NoTls, cancel_data)
249249
})
250250
.then(|r| {
251251
r.unwrap();

0 commit comments

Comments
 (0)