summaryrefslogtreecommitdiffstats
path: root/tokio/src/net/unix/listener.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/unix/listener.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/unix/listener.rs')
-rw-r--r--tokio/src/net/unix/listener.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tokio/src/net/unix/listener.rs b/tokio/src/net/unix/listener.rs
index 4b93bf82..d61d0392 100644
--- a/tokio/src/net/unix/listener.rs
+++ b/tokio/src/net/unix/listener.rs
@@ -21,6 +21,14 @@ cfg_uds! {
impl UnixListener {
/// Creates a new `UnixListener` bound to the specified path.
+ ///
+ /// # 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 bind<P>(path: P) -> io::Result<UnixListener>
where
P: AsRef<Path>,
@@ -35,6 +43,14 @@ impl UnixListener {
///
/// The returned listener will be associated with the given event loop
/// specified by `handle` and is ready to perform I/O.
+ ///
+ /// # 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(listener: net::UnixListener) -> io::Result<UnixListener> {
let listener = mio_uds::UnixListener::from_listener(listener)?;
let io = PollEvented::new(listener)?;