Skip to content

Commit 33947b1

Browse files
committed
Add TimeoutConnectorStream::{set_read_timeout_pinned,set_write_timeout_pinned,get_pin_mut}
1 parent 22e2e95 commit 33947b1

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bytes = "1.0.0"
1515
hyper = { version = "0.14", default-features = false, features = ["client", "http1", "tcp"] }
1616
pin-project-lite = "0.2"
1717
tokio = "1.0.0"
18-
tokio-io-timeout = "1.0.1"
18+
tokio-io-timeout = "1.1.0"
1919

2020
[dev-dependencies]
2121
#FIXME enable when https://github.com/hyperium/hyper-tls/pull/79 lands

src/stream.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,48 @@ where
3636

3737
/// Sets the read timeout.
3838
///
39-
/// This will reset any pending read timeout.
39+
/// This can only be used before the stream is pinned; use
40+
/// [`set_read_timeout_pinned`](Self::set_read_timeout_pinned) otherwise.
4041
pub fn set_read_timeout(&mut self, timeout: Option<Duration>) {
4142
self.stream.set_read_timeout(timeout)
4243
}
4344

45+
/// Sets the read timeout.
46+
///
47+
/// This will reset any pending read timeout. Use
48+
/// [`set_read_timeout`](Self::set_read_timeout) instead if the stream has not yet been pinned.
49+
pub fn set_read_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>) {
50+
self.project()
51+
.stream
52+
.as_mut()
53+
.set_read_timeout_pinned(timeout)
54+
}
55+
4456
/// Returns the current write timeout.
4557
pub fn write_timeout(&self) -> Option<Duration> {
4658
self.stream.write_timeout()
4759
}
4860

4961
/// Sets the write timeout.
5062
///
51-
/// This will reset any pending write timeout.
63+
/// This can only be used before the stream is pinned; use
64+
/// [`set_write_timeout_pinned`](Self::set_write_timeout_pinned) otherwise.
5265
pub fn set_write_timeout(&mut self, timeout: Option<Duration>) {
5366
self.stream.set_write_timeout(timeout)
5467
}
5568

69+
/// Sets the write timeout.
70+
///
71+
/// This will reset any pending write timeout. Use
72+
/// [`set_write_timeout`](Self::set_write_timeout) instead if the stream has not yet been
73+
/// pinned.
74+
pub fn set_write_timeout_pinned(self: Pin<&mut Self>, timeout: Option<Duration>) {
75+
self.project()
76+
.stream
77+
.as_mut()
78+
.set_write_timeout_pinned(timeout)
79+
}
80+
5681
/// Returns a shared reference to the inner stream.
5782
pub fn get_ref(&self) -> &S {
5883
self.stream.get_ref()
@@ -63,6 +88,11 @@ where
6388
self.stream.get_mut()
6489
}
6590

91+
/// Returns a pinned mutable reference to the inner stream.
92+
pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S> {
93+
self.project().stream.get_pin_mut()
94+
}
95+
6696
/// Consumes the stream, returning the inner stream.
6797
pub fn into_inner(self) -> S {
6898
self.stream.into_inner()

0 commit comments

Comments
 (0)