diff --git a/Cargo.toml b/Cargo.toml index f898bd0..2c4f022 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ bytes = "1.0.0" hyper = { version = "0.14", default-features = false, features = ["client", "http1", "tcp"] } pin-project-lite = "0.2" tokio = "1.0.0" -tokio-io-timeout = "1.0.1" +tokio-io-timeout = "1.1.0" [dev-dependencies] #FIXME enable when https://github.com/hyperium/hyper-tls/pull/79 lands diff --git a/src/stream.rs b/src/stream.rs index 2c0ab65..dd1bd35 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -36,11 +36,23 @@ where /// Sets the read timeout. /// - /// This will reset any pending read timeout. + /// This can only be used before the stream is pinned; use + /// [`set_read_timeout_pinned`](Self::set_read_timeout_pinned) otherwise. pub fn set_read_timeout(&mut self, timeout: Option) { self.stream.set_read_timeout(timeout) } + /// Sets the read timeout. + /// + /// This will reset any pending read timeout. Use + /// [`set_read_timeout`](Self::set_read_timeout) instead if the stream has not yet been pinned. + pub fn set_read_timeout_pinned(self: Pin<&mut Self>, timeout: Option) { + self.project() + .stream + .as_mut() + .set_read_timeout_pinned(timeout) + } + /// Returns the current write timeout. pub fn write_timeout(&self) -> Option { self.stream.write_timeout() @@ -48,11 +60,24 @@ where /// Sets the write timeout. /// - /// This will reset any pending write timeout. + /// This can only be used before the stream is pinned; use + /// [`set_write_timeout_pinned`](Self::set_write_timeout_pinned) otherwise. pub fn set_write_timeout(&mut self, timeout: Option) { self.stream.set_write_timeout(timeout) } + /// Sets the write timeout. + /// + /// This will reset any pending write timeout. Use + /// [`set_write_timeout`](Self::set_write_timeout) instead if the stream has not yet been + /// pinned. + pub fn set_write_timeout_pinned(self: Pin<&mut Self>, timeout: Option) { + self.project() + .stream + .as_mut() + .set_write_timeout_pinned(timeout) + } + /// Returns a shared reference to the inner stream. pub fn get_ref(&self) -> &S { self.stream.get_ref() @@ -63,6 +88,11 @@ where self.stream.get_mut() } + /// Returns a pinned mutable reference to the inner stream. + pub fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S> { + self.project().stream.get_pin_mut() + } + /// Consumes the stream, returning the inner stream. pub fn into_inner(self) -> S { self.stream.into_inner()