summaryrefslogtreecommitdiffstats
path: root/tokio/src/net/udp
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/udp
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/udp')
-rw-r--r--tokio/src/net/udp/socket.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tokio/src/net/udp/socket.rs b/tokio/src/net/udp/socket.rs
index c22ebd92..909ef760 100644
--- a/tokio/src/net/udp/socket.rs
+++ b/tokio/src/net/udp/socket.rs
@@ -57,6 +57,14 @@ impl UdpSocket {
/// This can be used in conjunction with net2's `UdpBuilder` interface to
/// configure a socket before it's handed off, such as setting options like
/// `reuse_address` or binding to multiple addresses.
+ ///
+ /// # 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(socket: net::UdpSocket) -> io::Result<UdpSocket> {
let io = mio::net::UdpSocket::from_socket(socket)?;
let io = PollEvented::new(io)?;