Skip to content

Commit 73eb495

Browse files
godofdreamjbg
authored andcommitted
update to new tokio
1 parent 6a7a5d6 commit 73eb495

File tree

3 files changed

+15
-42
lines changed

3 files changed

+15
-42
lines changed

Cargo.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
[package]
22
name = "tokio-postgres-rustls"
33
description = "Rustls integration for tokio-postgres"
4-
version = "0.5.0"
4+
version = "0.6.0"
55
authors = ["Jasper <[email protected]>"]
66
repository = "https://github.com/jbg/tokio-postgres-rustls"
77
edition = "2018"
88
license = "MIT"
99
readme = "README.md"
1010

1111
[dependencies]
12-
bytes = "0.5.4"
13-
futures = "0.3.4"
14-
ring = "0.16.11"
15-
rustls = "0.18.0"
16-
tokio = "0.2.16"
17-
tokio-postgres = "0.5.3"
18-
tokio-rustls = "0.14.0"
19-
webpki = "0.21.2"
12+
bytes = "0.6"
13+
futures = "0.3"
14+
ring = "0.16"
15+
rustls = "0.19"
16+
tokio = "0.3"
17+
tokio-postgres = "0.6"
18+
tokio-rustls = "0.21"
19+
webpki = "0.21"
2020

2121
[dev-dependencies]
22-
env_logger = { version = "0.7.1", default-features = false }
23-
tokio = { version = "0.2.16", features = ["macros"] }
22+
env_logger = { version = "0.8", default-features = false }
23+
tokio = { version = "0.3", features = ["macros", "rt"] }

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ let connect_fut = tokio_postgres::connect("sslmode=require host=localhost user=p
1717

1818
# License
1919
tokio-postgres-rustls is distributed under the MIT license.
20-

src/lib.rs

+4-30
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
use std::{
22
future::Future,
33
io,
4-
mem::MaybeUninit,
54
pin::Pin,
65
sync::Arc,
76
task::{Context, Poll},
87
};
98

10-
use bytes::{Buf, BufMut};
119
use futures::future::{FutureExt, TryFutureExt};
1210
use ring::digest;
1311
use rustls::{ClientConfig, Session};
14-
use tokio::io::{AsyncRead, AsyncWrite};
12+
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
1513
use tokio_postgres::tls::{ChannelBinding, MakeTlsConnect, TlsConnect};
1614
use tokio_rustls::{client::TlsStream, TlsConnector};
1715
use webpki::{DNSName, DNSNameRef};
@@ -93,25 +91,11 @@ where
9391
fn poll_read(
9492
mut self: Pin<&mut Self>,
9593
cx: &mut Context,
96-
buf: &mut [u8],
97-
) -> Poll<tokio::io::Result<usize>> {
94+
buf: &mut ReadBuf<'_>,
95+
) -> Poll<tokio::io::Result<()>> {
9896
self.0.as_mut().poll_read(cx, buf)
9997
}
10098

101-
unsafe fn prepare_uninitialized_buffer(&self, buf: &mut [MaybeUninit<u8>]) -> bool {
102-
self.0.prepare_uninitialized_buffer(buf)
103-
}
104-
105-
fn poll_read_buf<B: BufMut>(
106-
mut self: Pin<&mut Self>,
107-
cx: &mut Context,
108-
buf: &mut B,
109-
) -> Poll<tokio::io::Result<usize>>
110-
where
111-
Self: Sized,
112-
{
113-
self.0.as_mut().poll_read_buf(cx, buf)
114-
}
11599
}
116100

117101
impl<S> AsyncWrite for RustlsStream<S>
@@ -134,16 +118,6 @@ where
134118
self.0.as_mut().poll_shutdown(cx)
135119
}
136120

137-
fn poll_write_buf<B: Buf>(
138-
mut self: Pin<&mut Self>,
139-
cx: &mut Context,
140-
buf: &mut B,
141-
) -> Poll<tokio::io::Result<usize>>
142-
where
143-
Self: Sized,
144-
{
145-
self.0.as_mut().poll_write_buf(cx, buf)
146-
}
147121
}
148122

149123
#[cfg(test)]
@@ -157,7 +131,7 @@ mod tests {
157131
let config = rustls::ClientConfig::new();
158132
let tls = super::MakeRustlsConnect::new(config);
159133
let (client, conn) =
160-
tokio_postgres::connect("sslmode=require host=localhost user=postgres", tls)
134+
tokio_postgres::connect("sslmode=require host=localhost port=5432 user=postgres", tls)
161135
.await
162136
.expect("connect");
163137
tokio::spawn(conn.map_err(|e| panic!("{:?}", e)));

0 commit comments

Comments
 (0)