Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 32 additions & 2 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,48 @@ 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<Duration>) {
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<Duration>) {
self.project()
.stream
.as_mut()
.set_read_timeout_pinned(timeout)
}

/// Returns the current write timeout.
pub fn write_timeout(&self) -> Option<Duration> {
self.stream.write_timeout()
}

/// 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<Duration>) {
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<Duration>) {
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()
Expand All @@ -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()
Expand Down