summaryrefslogtreecommitdiffstats
path: root/tokio/src/net/tcp/stream.rs
diff options
context:
space:
mode:
authorStepan Koltsov <stepan.koltsov@gmail.com>2020-01-06 18:06:39 +0000
committerCarl Lerche <me@carllerche.com>2020-01-06 10:06:39 -0800
commitd45f61c183b2e0bb0da196bdd13d77461dd03477 (patch)
tree88232363e6ba7ce30a7fb8177aba467b03008570 /tokio/src/net/tcp/stream.rs
parentdcfa895b512e3ed522b81b18baf3e33fd78a600c (diff)
doc: document `from_std` functions panic (#2056)
Document that conversion from `std` types must be done from within the Tokio runtime context.
Diffstat (limited to 'tokio/src/net/tcp/stream.rs')
-rw-r--r--tokio/src/net/tcp/stream.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs
index d35f1620..f32a6c4a 100644
--- a/tokio/src/net/tcp/stream.rs
+++ b/tokio/src/net/tcp/stream.rs
@@ -139,6 +139,22 @@ impl TcpStream {
/// Ok(())
/// }
/// ```
+ ///
+ /// # Panics
+ ///
+ /// This function panics if thread-local runtime is not set.
+ ///
+ /// The runtime is usually set implicitly when this function is called
+ /// from a future driven by a tokio runtime, otherwise runtime can be set
+ /// explicitly with [`Handle::enter`](crate::runtime::Handle::enter) function.
+ ///
+ /// # Panics
+ ///
+ /// This function panics if thread-local runtime is not set.
+ ///
+ /// The runtime is usually set implicitly when this function is called
+ /// from a future driven by a tokio runtime, otherwise runtime can be set
+ /// explicitly with [`Handle::enter`](crate::runtime::Handle::enter) function.
pub fn from_std(stream: net::TcpStream) -> io::Result<TcpStream> {
let io = mio::net::TcpStream::from_stream(stream)?;
let io = PollEvented::new(io)?;