deploy: e2d7de20131fce3cd140e07e12f311b6d1e04f54

This commit is contained in:
matheus23
2025-01-20 16:43:12 +00:00
parent 03e0e6bfb5
commit 4c1127b6d6
74 changed files with 1125 additions and 1054 deletions
+1 -1
View File
@@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Addr.html">Addr</a></li><li><a href="struct.Client.html">Client</a></li><li><a href="struct.Metrics.html">Metrics</a></li><li><a href="struct.Options.html">Options</a></li><li><a href="struct.QuicConfig.html">QuicConfig</a></li><li><a href="struct.RelayLatencies.html">RelayLatencies</a></li><li><a href="struct.Report.html">Report</a></li><li><a href="task/struct.AbortOnDropHandle.html">task::AbortOnDropHandle</a></li><li><a href="task/struct.JoinError.html">task::JoinError</a></li><li><a href="task/struct.JoinHandle.html">task::JoinHandle</a></li><li><a href="task/struct.JoinSet.html">task::JoinSet</a></li><li><a href="time/struct.Duration.html">time::Duration</a></li><li><a href="time/struct.Instant.html">time::Instant</a></li><li><a href="time/struct.Interval.html">time::Interval</a></li><li><a href="time/struct.Sleep.html">time::Sleep</a></li><li><a href="time/struct.Timeout.html">time::Timeout</a></li><li><a href="time/error/struct.Elapsed.html">time::error::Elapsed</a></li><li><a href="time/error/struct.Error.html">time::error::Error</a></li></ul><h3 id="enums">Enums</h3><ul class="all-items"><li><a href="time/enum.MissedTickBehavior.html">time::MissedTickBehavior</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="fn.bind_local_stun_socket.html">bind_local_stun_socket</a></li><li><a href="fn.os_has_ipv6.html">os_has_ipv6</a></li><li><a href="task/fn.spawn.html">task::spawn</a></li><li><a href="time/fn.interval.html">time::interval</a></li><li><a href="time/fn.interval_at.html">time::interval_at</a></li><li><a href="time/fn.sleep.html">time::sleep</a></li><li><a href="time/fn.sleep_until.html">time::sleep_until</a></li><li><a href="time/fn.timeout.html">time::timeout</a></li><li><a href="time/fn.timeout_at.html">time::timeout_at</a></li></ul></section></div></main></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Addr.html">Addr</a></li><li><a href="struct.Client.html">Client</a></li><li><a href="struct.Metrics.html">Metrics</a></li><li><a href="struct.Options.html">Options</a></li><li><a href="struct.QuicConfig.html">QuicConfig</a></li><li><a href="struct.RelayLatencies.html">RelayLatencies</a></li><li><a href="struct.Report.html">Report</a></li><li><a href="task/struct.AbortOnDropHandle.html">task::AbortOnDropHandle</a></li><li><a href="task/struct.JoinError.html">task::JoinError</a></li><li><a href="task/struct.JoinHandle.html">task::JoinHandle</a></li><li><a href="task/struct.JoinSet.html">task::JoinSet</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="fn.bind_local_stun_socket.html">bind_local_stun_socket</a></li><li><a href="fn.os_has_ipv6.html">os_has_ipv6</a></li><li><a href="task/fn.spawn.html">task::spawn</a></li></ul></section></div></main></body></html>
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Attempts to bind a local socket to send STUN packets from."><title>bind_local_stun_socket in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">bind_local_stun_socket</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#957-1001">Source</a> </span></div><pre class="rust item-decl"><code>pub fn bind_local_stun_socket(
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Attempts to bind a local socket to send STUN packets from."><title>bind_local_stun_socket in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">bind_local_stun_socket</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#939-983">Source</a> </span></div><pre class="rust item-decl"><code>pub fn bind_local_stun_socket(
network: IpFamily,
actor_addr: <a class="struct" href="struct.Addr.html" title="struct iroh_net_report::Addr">Addr</a>,
cancel_token: CancellationToken,
@@ -1,2 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Test if IPv6 works at all, or if it’s been hard disabled at the OS level."><title>os_has_ipv6 in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">os_has_ipv6</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#935-937">Source</a> </span></div><pre class="rust item-decl"><code>pub fn os_has_ipv6() -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Test if IPv6 works at all, or if it’s been hard disabled at the OS level."><title>os_has_ipv6 in iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">iroh_net_report</a></span><h1>Function <span class="fn">os_has_ipv6</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#922-924">Source</a> </span></div><pre class="rust item-decl"><code>pub fn os_has_ipv6() -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</p>
</div></details></section></div></main></body></html>
+2 -2
View File
@@ -1,6 +1,6 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Checks the network conditions from the current host."><title>iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_net_report</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#1-1538">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks the network conditions from the current host.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Checks the network conditions from the current host."><title>iroh_net_report - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_net_report</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_net_report/lib.rs.html#1-1520">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks the network conditions from the current host.</p>
<p>NetReport is responsible for finding out the network conditions of the current host, like
whether it is connected to the internet via IPv4 and/or IPv6, what the NAT situation is
etc and reachability to the configured relays.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="task/index.html" title="mod iroh_net_report::task">task</a></div><div class="desc docblock-short">Async rust task spawning and utilities that work natively (using tokio) and in browsers
(using wasm-bindgen-futures).</div></li><li><div class="item-name"><a class="mod" href="time/index.html" title="mod iroh_net_report::time">time</a></div><div class="desc docblock-short">Sleep and timeout utilities that work natively (via tokio) and in the browser.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Addr.html" title="struct iroh_net_report::Addr">Addr</a></div><div class="desc docblock-short">Sender to the main service.</div></li><li><div class="item-name"><a class="struct" href="struct.Client.html" title="struct iroh_net_report::Client">Client</a></div><div class="desc docblock-short">Client to run net_reports.</div></li><li><div class="item-name"><a class="struct" href="struct.Metrics.html" title="struct iroh_net_report::Metrics">Metrics</a></div><div class="desc docblock-short">Enum of metrics for the module</div></li><li><div class="item-name"><a class="struct" href="struct.Options.html" title="struct iroh_net_report::Options">Options</a></div><div class="desc docblock-short">Options for running probes</div></li><li><div class="item-name"><a class="struct" href="struct.QuicConfig.html" title="struct iroh_net_report::QuicConfig">Quic<wbr>Config</a></div><div class="desc docblock-short">Pieces needed to do QUIC address discovery.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayLatencies.html" title="struct iroh_net_report::RelayLatencies">Relay<wbr>Latencies</a></div><div class="desc docblock-short">Latencies per relay node.</div></li><li><div class="item-name"><a class="struct" href="struct.Report.html" title="struct iroh_net_report::Report">Report</a></div><div class="desc docblock-short">A net_report report.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.bind_local_stun_socket.html" title="fn iroh_net_report::bind_local_stun_socket">bind_<wbr>local_<wbr>stun_<wbr>socket</a><wbr><span class="stab portability" title="Available on crate feature `stun-utils` only"><code>stun-utils</code></span></div><div class="desc docblock-short">Attempts to bind a local socket to send STUN packets from.</div></li><li><div class="item-name"><a class="fn" href="fn.os_has_ipv6.html" title="fn iroh_net_report::os_has_ipv6">os_<wbr>has_<wbr>ipv6</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</div></li></ul></section></div></main></body></html>
(using wasm-bindgen-futures).</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Addr.html" title="struct iroh_net_report::Addr">Addr</a></div><div class="desc docblock-short">Sender to the main service.</div></li><li><div class="item-name"><a class="struct" href="struct.Client.html" title="struct iroh_net_report::Client">Client</a></div><div class="desc docblock-short">Client to run net_reports.</div></li><li><div class="item-name"><a class="struct" href="struct.Metrics.html" title="struct iroh_net_report::Metrics">Metrics</a></div><div class="desc docblock-short">Enum of metrics for the module</div></li><li><div class="item-name"><a class="struct" href="struct.Options.html" title="struct iroh_net_report::Options">Options</a></div><div class="desc docblock-short">Options for running probes</div></li><li><div class="item-name"><a class="struct" href="struct.QuicConfig.html" title="struct iroh_net_report::QuicConfig">Quic<wbr>Config</a></div><div class="desc docblock-short">Pieces needed to do QUIC address discovery.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayLatencies.html" title="struct iroh_net_report::RelayLatencies">Relay<wbr>Latencies</a></div><div class="desc docblock-short">Latencies per relay node.</div></li><li><div class="item-name"><a class="struct" href="struct.Report.html" title="struct iroh_net_report::Report">Report</a></div><div class="desc docblock-short">A net_report report.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.bind_local_stun_socket.html" title="fn iroh_net_report::bind_local_stun_socket">bind_<wbr>local_<wbr>stun_<wbr>socket</a><wbr><span class="stab portability" title="Available on crate feature `stun-utils` only"><code>stun-utils</code></span></div><div class="desc docblock-short">Attempts to bind a local socket to send STUN packets from.</div></li><li><div class="item-name"><a class="fn" href="fn.os_has_ipv6.html" title="fn iroh_net_report::os_has_ipv6">os_<wbr>has_<wbr>ipv6</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Test if IPv6 works at all, or if it’s been hard disabled at the OS level.</div></li></ul></section></div></main></body></html>
@@ -1 +1 @@
window.SIDEBAR_ITEMS = {"fn":["bind_local_stun_socket","os_has_ipv6"],"mod":["task","time"],"struct":["Addr","Client","Metrics","Options","QuicConfig","RelayLatencies","Report"]};
window.SIDEBAR_ITEMS = {"fn":["bind_local_stun_socket","os_has_ipv6"],"mod":["task"],"struct":["Addr","Client","Metrics","Options","QuicConfig","RelayLatencies","Report"]};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Spawns a new asynchronous task, returning a `JoinHandle` for it."><title>spawn in iroh_net_report::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">spawn</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#using-send-values-from-a-task" title="Using `!Send` values from a task">Using <code>!Send</code> values from a task</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>task</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">task</a></span><h1>Function <span class="fn">spawn</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn spawn&lt;F&gt;(future: F) -&gt; <a class="struct" href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle">JoinHandle</a>&lt;&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>&gt; <a href="#" class="tooltip" data-notable-ty="JoinHandle&lt;&lt;F as Future&gt;::Output&gt;">ⓘ</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,
&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawns a new asynchronous task, returning a
&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output" title="type core::future::future::Future::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,</div></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawns a new asynchronous task, returning a
<a href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle"><code>JoinHandle</code></a> for it.</p>
<p>The provided future will start running in the background immediately
when <code>spawn</code> is called, even if you don’t await the returned
+3 -3
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Async rust task spawning and utilities that work natively (using tokio) and in browsers (using wasm-bindgen-futures)."><title>iroh_net_report::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module task</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>net_<wbr>report</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a></span><h1>Module <span>task</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_net_report/task.rs.html#1-12">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Async rust task spawning and utilities that work natively (using tokio) and in browsers
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Async rust task spawning and utilities that work natively (using tokio) and in browsers (using wasm-bindgen-futures)."><title>iroh_net_report::task - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module task</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>net_<wbr>report</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a></span><h1>Module <span>task</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_net_report/task.rs.html#1-322">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Async rust task spawning and utilities that work natively (using tokio) and in browsers
(using wasm-bindgen-futures).</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AbortOnDropHandle.html" title="struct iroh_net_report::task::AbortOnDropHandle">Abort<wbr>OnDrop<wbr>Handle</a></div><div class="desc docblock-short">A wrapper around a <a href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle"><code>tokio::task::JoinHandle</code></a>,
which <a href="struct.JoinHandle.html#method.abort" title="method iroh_net_report::task::JoinHandle::abort">aborts</a> the task when it is dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.JoinError.html" title="struct iroh_net_report::task::JoinError">Join<wbr>Error</a></div><div class="desc docblock-short">Task failed to execute to completion.</div></li><li><div class="item-name"><a class="struct" href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle">Join<wbr>Handle</a></div><div class="desc docblock-short">An owned permission to join on a task (await its termination).</div></li><li><div class="item-name"><a class="struct" href="struct.JoinSet.html" title="struct iroh_net_report::task::JoinSet">JoinSet</a></div><div class="desc docblock-short">A collection of tasks spawned on a Tokio runtime.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.spawn.html" title="fn iroh_net_report::task::spawn">spawn</a></div><div class="desc docblock-short">Spawns a new asynchronous task, returning a
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AbortOnDropHandle.html" title="struct iroh_net_report::task::AbortOnDropHandle">Abort<wbr>OnDrop<wbr>Handle</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A wrapper around a <a href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle"><code>tokio::task::JoinHandle</code></a>,
which <a href="struct.JoinHandle.html#method.abort" title="method iroh_net_report::task::JoinHandle::abort">aborts</a> the task when it is dropped.</div></li><li><div class="item-name"><a class="struct" href="struct.JoinError.html" title="struct iroh_net_report::task::JoinError">Join<wbr>Error</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Task failed to execute to completion.</div></li><li><div class="item-name"><a class="struct" href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle">Join<wbr>Handle</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">An owned permission to join on a task (await its termination).</div></li><li><div class="item-name"><a class="struct" href="struct.JoinSet.html" title="struct iroh_net_report::task::JoinSet">JoinSet</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A collection of tasks spawned on a Tokio runtime.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.spawn.html" title="fn iroh_net_report::task::spawn">spawn</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Spawns a new asynchronous task, returning a
<a href="struct.JoinHandle.html" title="struct iroh_net_report::task::JoinHandle"><code>JoinHandle</code></a> for it.</div></li></ul></section></div></main></body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../iroh_net_report/task/fn.spawn.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../iroh_net_report/task/fn.spawn.html">../../../iroh_net_report/task/fn.spawn.html</a>...</p>
<script>location.replace("../../../iroh_net_report/task/fn.spawn.html" + location.search + location.hash);</script>
</body>
</html>
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../iroh_net_report/task/struct.AbortOnDropHandle.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../iroh_net_report/task/struct.AbortOnDropHandle.html">../../../iroh_net_report/task/struct.AbortOnDropHandle.html</a>...</p>
<script>location.replace("../../../iroh_net_report/task/struct.AbortOnDropHandle.html" + location.search + location.hash);</script>
</body>
</html>
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../iroh_net_report/task/struct.JoinError.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../iroh_net_report/task/struct.JoinError.html">../../../iroh_net_report/task/struct.JoinError.html</a>...</p>
<script>location.replace("../../../iroh_net_report/task/struct.JoinError.html" + location.search + location.hash);</script>
</body>
</html>
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../iroh_net_report/task/struct.JoinHandle.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../iroh_net_report/task/struct.JoinHandle.html">../../../iroh_net_report/task/struct.JoinHandle.html</a>...</p>
<script>location.replace("../../../iroh_net_report/task/struct.JoinHandle.html" + location.search + location.hash);</script>
</body>
</html>
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../iroh_net_report/task/struct.JoinSet.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../iroh_net_report/task/struct.JoinSet.html">../../../iroh_net_report/task/struct.JoinSet.html</a>...</p>
<script>location.replace("../../../iroh_net_report/task/struct.JoinSet.html" + location.search + location.hash);</script>
</body>
</html>
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Time error types."><title>iroh_net_report::time::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module error</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">iroh_net_report</a>::<wbr><a href="../index.html">time</a></span><h1>Module <span>error</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Time error types.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Elapsed.html" title="struct iroh_net_report::time::error::Elapsed">Elapsed</a></div><div class="desc docblock-short">Errors returned by <code>Timeout</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Error.html" title="struct iroh_net_report::time::error::Error">Error</a></div><div class="desc docblock-short">Errors encountered by the timer implementation.</div></li></ul></section></div></main></body></html>
@@ -1 +0,0 @@
window.SIDEBAR_ITEMS = {"struct":["Elapsed","Error"]};
File diff suppressed because one or more lines are too long
@@ -1,48 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Creates new `Interval` that yields with interval of `period`. The first tick completes immediately. The default `MissedTickBehavior` is `Burst`, but this can be configured by calling `set_missed_tick_behavior`."><title>interval in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">interval</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">interval</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn interval(period: <a class="struct" href="struct.Duration.html" title="struct iroh_net_report::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct iroh_net_report::time::Interval">Interval</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates new <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default <a href="enum.MissedTickBehavior.html" title="enum iroh_net_report::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant iroh_net_report::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method iroh_net_report::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</p>
<p>An interval will tick indefinitely. At any time, the <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> value can
be dropped. This cancels the interval.</p>
<p>This function is equivalent to
<a href="fn.interval_at.html" title="fn iroh_net_report::time::interval_at"><code>interval_at(Instant::now(), period)</code></a>.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if <code>period</code> is zero.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{<span class="self">self</span>, Duration};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span><span class="kw-2">mut </span>interval = time::interval(Duration::from_millis(<span class="number">10</span>));
interval.tick().<span class="kw">await</span>; <span class="comment">// ticks immediately
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
// approximately 20ms have elapsed.
</span>}</code></pre></div>
<p>A simple example using <code>interval</code> to execute a task every two seconds.</p>
<p>The difference between <code>interval</code> and <a href="fn.sleep.html" title="fn iroh_net_report::time::sleep"><code>sleep</code></a> is that an <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a>
measures the time since the last tick, which means that <a href="struct.Interval.html#method.tick" title="method iroh_net_report::time::Interval::tick"><code>.tick().await</code></a>
may wait for a shorter time than the duration specified for the interval
if some time has passed between calls to <a href="struct.Interval.html#method.tick" title="method iroh_net_report::time::Interval::tick"><code>.tick().await</code></a>.</p>
<p>If the tick in the example below was replaced with <a href="fn.sleep.html" title="fn iroh_net_report::time::sleep"><code>sleep</code></a>, the task
would only be executed once every three seconds, and not every two
seconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time;
<span class="kw">async fn </span>task_that_takes_a_second() {
<span class="macro">println!</span>(<span class="string">"hello"</span>);
time::sleep(time::Duration::from_secs(<span class="number">1</span>)).<span class="kw">await
</span>}
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span><span class="kw-2">mut </span>interval = time::interval(time::Duration::from_secs(<span class="number">2</span>));
<span class="kw">for </span>_i <span class="kw">in </span><span class="number">0</span>..<span class="number">5 </span>{
interval.tick().<span class="kw">await</span>;
task_that_takes_a_second().<span class="kw">await</span>;
}
}</code></pre></div>
</div></details></section></div></main></body></html>
@@ -1,23 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Creates new `Interval` that yields with interval of `period` with the first tick completing at `start`. The default `MissedTickBehavior` is `Burst`, but this can be configured by calling `set_missed_tick_behavior`."><title>interval_at in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">interval_<wbr>at</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#panics" title="Panics">Panics</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">interval_at</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn interval_at(start: <a class="struct" href="struct.Instant.html" title="struct iroh_net_report::time::Instant">Instant</a>, period: <a class="struct" href="struct.Duration.html" title="struct iroh_net_report::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Interval.html" title="struct iroh_net_report::time::Interval">Interval</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Creates new <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code> with the
first tick completing at <code>start</code>. The default <a href="enum.MissedTickBehavior.html" title="enum iroh_net_report::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant iroh_net_report::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method iroh_net_report::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</p>
<p>An interval will tick indefinitely. At any time, the <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> value can
be dropped. This cancels the interval.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if <code>period</code> is zero.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{interval_at, Duration, Instant};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span>start = Instant::now() + Duration::from_millis(<span class="number">50</span>);
<span class="kw">let </span><span class="kw-2">mut </span>interval = interval_at(start, Duration::from_millis(<span class="number">10</span>));
interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 50ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
</span>interval.tick().<span class="kw">await</span>; <span class="comment">// ticks after 10ms
// approximately 70ms have elapsed.
</span>}</code></pre></div>
</div></details></section></div></main></body></html>
@@ -1,36 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Waits until `duration` has elapsed."><title>sleep in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">sleep</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn sleep(duration: <a class="struct" href="struct.Duration.html" title="struct iroh_net_report::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct iroh_net_report::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep">ⓘ</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>duration</code> has elapsed.</p>
<p>Equivalent to <code>sleep_until(Instant::now() + duration)</code>. An asynchronous
analog to <code>std::thread::sleep</code>.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers. The implementation is platform specific,
and some platforms (specifically Windows) will provide timers with a
larger resolution than 1 ms.</p>
<p>To run something regularly on a schedule, see <a href="fn.interval.html" title="fn iroh_net_report::time::interval"><code>interval</code></a>.</p>
<p>The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep, Duration};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
sleep(Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);
}</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct iroh_net_report::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_net_report::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_net_report::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>
@@ -1,31 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Waits until `deadline` is reached."><title>sleep_until in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep_<wbr>until</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">sleep_until</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn sleep_until(deadline: <a class="struct" href="struct.Instant.html" title="struct iroh_net_report::time::Instant">Instant</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct iroh_net_report::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep">ⓘ</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>deadline</code> is reached.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers.</p>
<p>To run something regularly on a schedule, see <a href="fn.interval.html" title="fn iroh_net_report::time::interval"><code>interval</code></a>.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep_until, Instant, Duration};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
sleep_until(Instant::now() + Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);
}</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct iroh_net_report::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_net_report::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_net_report::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>
@@ -1,47 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Requires a `Future` to complete before the specified duration has elapsed."><title>timeout in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">timeout</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">timeout</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn timeout&lt;F&gt;(
duration: <a class="struct" href="struct.Duration.html" title="struct iroh_net_report::time::Duration">Duration</a>,
future: F,
) -&gt; <a class="struct" href="struct.Timeout.html" title="struct iroh_net_report::time::Timeout">Timeout</a>&lt;&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html#associatedtype.IntoFuture" title="type core::future::into_future::IntoFuture::IntoFuture">IntoFuture</a>&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;&lt;F as IntoFuture&gt;::IntoFuture&gt;">ⓘ</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>,</div></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Requires a <code>Future</code> to complete before the specified duration has elapsed.</p>
<p>If the future completes before the duration has elapsed, then the completed
value is returned. Otherwise, an error is returned and the future is
canceled.</p>
<p>Note that the timeout is checked before polling the future, so if the future
does not yield during execution then it is possible for the future to complete
and exceed the timeout <em>without</em> returning an error.</p>
<p>This function returns a future whose return type is <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="error/struct.Elapsed.html" title="struct iroh_net_report::time::error::Elapsed"><code>Elapsed</code></a><code>&gt;</code>, where <code>T</code> is the
return type of the provided future.</p>
<p>If the provided future completes immediately, then the future returned from
this function is guaranteed to complete immediately with an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a> variant
no matter the provided duration.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Cancelling a timeout is done by dropping the future. No additional cleanup
or other work is required.</p>
<p>The original future may be obtained by calling <a href="struct.Timeout.html#method.into_inner" title="method iroh_net_report::time::Timeout::into_inner"><code>Timeout::into_inner</code></a>. This
consumes the <code>Timeout</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Create a new <code>Timeout</code> set to expire in 10 milliseconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::timeout;
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>std::time::Duration;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
<span class="comment">// Wrap the future with a `Timeout` set to expire in 10 milliseconds.
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = timeout(Duration::from_millis(<span class="number">10</span>), rx).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"did not receive value within 10 ms"</span>);
}</code></pre></div>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Timeout<<F as IntoFuture>::IntoFuture>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_net_report::time::Timeout\">Timeout</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_net_report::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/nightly/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;&lt;T as <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, <a class=\"struct\" href=\"error/struct.Elapsed.html\" title=\"struct iroh_net_report::time::error::Elapsed\">Elapsed</a>&gt;;</div>"}</script></section></div></main></body></html>
@@ -1,33 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Requires a `Future` to complete before the specified instant in time."><title>timeout_at in iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">timeout_<wbr>at</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>net_<wbr>report::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">timeout_at</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn timeout_at&lt;F&gt;(
deadline: <a class="struct" href="struct.Instant.html" title="struct iroh_net_report::time::Instant">Instant</a>,
future: F,
) -&gt; <a class="struct" href="struct.Timeout.html" title="struct iroh_net_report::time::Timeout">Timeout</a>&lt;&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html#associatedtype.IntoFuture" title="type core::future::into_future::IntoFuture::IntoFuture">IntoFuture</a>&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;&lt;F as IntoFuture&gt;::IntoFuture&gt;">ⓘ</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>,</div></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Requires a <code>Future</code> to complete before the specified instant in time.</p>
<p>If the future completes before the instant is reached, then the completed
value is returned. Otherwise, an error is returned.</p>
<p>This function returns a future whose return type is <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="error/struct.Elapsed.html" title="struct iroh_net_report::time::error::Elapsed"><code>Elapsed</code></a><code>&gt;</code>, where <code>T</code> is the
return type of the provided future.</p>
<p>If the provided future completes immediately, then the future returned from
this function is guaranteed to complete immediately with an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a> variant
no matter the provided deadline.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Cancelling a timeout is done by dropping the future. No additional cleanup
or other work is required.</p>
<p>The original future may be obtained by calling <a href="struct.Timeout.html#method.into_inner" title="method iroh_net_report::time::Timeout::into_inner"><code>Timeout::into_inner</code></a>. This
consumes the <code>Timeout</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Create a new <code>Timeout</code> set to expire in 10 milliseconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{Instant, timeout_at};
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>std::time::Duration;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
<span class="comment">// Wrap the future with a `Timeout` set to expire 10 milliseconds into the
// future.
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = timeout_at(Instant::now() + Duration::from_millis(<span class="number">10</span>), rx).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"did not receive value within 10 ms"</span>);
}</code></pre></div>
</div></details><script type="text/json" id="notable-traits-data">{"Timeout<<F as IntoFuture>::IntoFuture>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_net_report::time::Timeout\">Timeout</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_net_report::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/nightly/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;&lt;T as <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, <a class=\"struct\" href=\"error/struct.Elapsed.html\" title=\"struct iroh_net_report::time::error::Elapsed\">Elapsed</a>&gt;;</div>"}</script></section></div></main></body></html>
@@ -1,10 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Sleep and timeout utilities that work natively (via tokio) and in the browser."><title>iroh_net_report::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_net_report/index.html">iroh_<wbr>net_<wbr>report</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module time</a></h2><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>net_<wbr>report</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_net_report</a></span><h1>Module <span>time</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_net_report/time.rs.html#1-246">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sleep and timeout utilities that work natively (via tokio) and in the browser.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="error/index.html" title="mod iroh_net_report::time::error">error</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Time error types.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Duration.html" title="struct iroh_net_report::time::Duration">Duration</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A <code>Duration</code> type to represent a span of time, typically used for system
timeouts.</div></li><li><div class="item-name"><a class="struct" href="struct.Instant.html" title="struct iroh_net_report::time::Instant">Instant</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A measurement of a monotonically nondecreasing clock.
Opaque and useful only with <code>Duration</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Interval.html" title="struct iroh_net_report::time::Interval">Interval</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Interval returned by <a href="fn.interval.html" title="fn iroh_net_report::time::interval"><code>interval</code></a> and <a href="fn.interval_at.html" title="fn iroh_net_report::time::interval_at"><code>interval_at</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Sleep.html" title="struct iroh_net_report::time::Sleep">Sleep</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Future returned by <a href="fn.sleep.html" title="fn iroh_net_report::time::sleep"><code>sleep</code></a> and <a href="fn.sleep_until.html" title="fn iroh_net_report::time::sleep_until"><code>sleep_until</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Timeout.html" title="struct iroh_net_report::time::Timeout">Timeout</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Future returned by <a href="fn.timeout.html" title="fn iroh_net_report::time::timeout"><code>timeout</code></a> and <a href="fn.timeout_at.html" title="fn iroh_net_report::time::timeout_at"><code>timeout_at</code></a>.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.MissedTickBehavior.html" title="enum iroh_net_report::time::MissedTickBehavior">Missed<wbr>Tick<wbr>Behavior</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Defines the behavior of an <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> when it misses a tick.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.interval.html" title="fn iroh_net_report::time::interval">interval</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Creates new <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code>. The first
tick completes immediately. The default <a href="enum.MissedTickBehavior.html" title="enum iroh_net_report::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant iroh_net_report::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method iroh_net_report::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</div></li><li><div class="item-name"><a class="fn" href="fn.interval_at.html" title="fn iroh_net_report::time::interval_at">interval_<wbr>at</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Creates new <a href="struct.Interval.html" title="struct iroh_net_report::time::Interval"><code>Interval</code></a> that yields with interval of <code>period</code> with the
first tick completing at <code>start</code>. The default <a href="enum.MissedTickBehavior.html" title="enum iroh_net_report::time::MissedTickBehavior"><code>MissedTickBehavior</code></a> is
<a href="enum.MissedTickBehavior.html#variant.Burst" title="variant iroh_net_report::time::MissedTickBehavior::Burst"><code>Burst</code></a>, but this can be configured
by calling <a href="struct.Interval.html#method.set_missed_tick_behavior" title="method iroh_net_report::time::Interval::set_missed_tick_behavior"><code>set_missed_tick_behavior</code></a>.</div></li><li><div class="item-name"><a class="fn" href="fn.sleep.html" title="fn iroh_net_report::time::sleep">sleep</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Waits until <code>duration</code> has elapsed.</div></li><li><div class="item-name"><a class="fn" href="fn.sleep_until.html" title="fn iroh_net_report::time::sleep_until">sleep_<wbr>until</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Waits until <code>deadline</code> is reached.</div></li><li><div class="item-name"><a class="fn" href="fn.timeout.html" title="fn iroh_net_report::time::timeout">timeout</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Requires a <code>Future</code> to complete before the specified duration has elapsed.</div></li><li><div class="item-name"><a class="fn" href="fn.timeout_at.html" title="fn iroh_net_report::time::timeout_at">timeout_<wbr>at</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Requires a <code>Future</code> to complete before the specified instant in time.</div></li></ul></section></div></main></body></html>
@@ -1 +0,0 @@
window.SIDEBAR_ITEMS = {"enum":["MissedTickBehavior"],"fn":["interval","interval_at","sleep","sleep_until","timeout","timeout_at"],"mod":["error"],"struct":["Duration","Instant","Interval","Sleep","Timeout"]};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,8 +11,8 @@
problem: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;,
},
ServerRestarting {
reconnect_in: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>,
try_for: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>,
reconnect_in: <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>,
try_for: <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>,
},
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The messages received from a framed relay stream.</p>
<p>This is a type-validated version of the <code>Frame</code>s on the <code>RelayCodec</code>.</p>
@@ -34,9 +34,9 @@ a reply from the client.</p>
<p>The default condition is healthy, so the server doesn’t broadcast a <a href="enum.ReceivedMessage.html#variant.Health" title="variant iroh_relay::client::ReceivedMessage::Health"><code>ReceivedMessage::Health</code></a>
until a problem exists.</p>
</div></div></div><section id="variant.ServerRestarting" class="variant"><a href="#variant.ServerRestarting" class="anchor">§</a><h3 class="code-header">ServerRestarting</h3></section><div class="docblock"><p>A one-way message from server to client, advertising that the server is restarting.</p>
</div><div class="sub-variant" id="variant.ServerRestarting.fields"><h4>Fields</h4><div class="sub-variant-field"><span id="variant.ServerRestarting.field.reconnect_in" class="section-header"><a href="#variant.ServerRestarting.field.reconnect_in" class="anchor field">§</a><code>reconnect_in: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a></code></span><div class="docblock"><p>An advisory duration that the client should wait before attempting to reconnect.
</div><div class="sub-variant" id="variant.ServerRestarting.fields"><h4>Fields</h4><div class="sub-variant-field"><span id="variant.ServerRestarting.field.reconnect_in" class="section-header"><a href="#variant.ServerRestarting.field.reconnect_in" class="anchor field">§</a><code>reconnect_in: <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a></code></span><div class="docblock"><p>An advisory duration that the client should wait before attempting to reconnect.
It might be zero. It exists for the server to smear out the reconnects.</p>
</div></div><div class="sub-variant-field"><span id="variant.ServerRestarting.field.try_for" class="section-header"><a href="#variant.ServerRestarting.field.try_for" class="anchor field">§</a><code>try_for: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a></code></span><div class="docblock"><p>An advisory duration for how long the client should attempt to reconnect
</div></div><div class="sub-variant-field"><span id="variant.ServerRestarting.field.try_for" class="section-header"><a href="#variant.ServerRestarting.field.try_for" class="anchor field">§</a><code>try_for: <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a></code></span><div class="docblock"><p>An advisory duration for how long the client should attempt to reconnect
before giving up and proceeding with its normal connection failure logic. The interval
between retries is undefined for now. A server should not send a TryFor duration more
than a few seconds.</p>
+2 -2
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Iroh’s relay is a feature within iroh, a peer-to-peer networking system designed to facilitate direct, encrypted connections between devices. Iroh aims to simplify decentralized communication by automatically handling connections through “relays” when direct connections aren’t immediately possible. The relay server helps establish connections by temporarily routing encrypted traffic until a direct, P2P connection is feasible. Once this direct path is set up, the relay server steps back, and the data flows directly between devices. This approach allows Iroh to maintain a secure, low-latency connection, even in challenging network situations."><title>iroh_relay - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_relay</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_relay/lib.rs.html#1-55">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Iroh’s relay is a feature within <a href="https://github.com/n0-computer/iroh">iroh</a>, a peer-to-peer
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Iroh’s relay is a feature within iroh, a peer-to-peer networking system designed to facilitate direct, encrypted connections between devices. Iroh aims to simplify decentralized communication by automatically handling connections through “relays” when direct connections aren’t immediately possible. The relay server helps establish connections by temporarily routing encrypted traffic until a direct, P2P connection is feasible. Once this direct path is set up, the relay server steps back, and the data flows directly between devices. This approach allows Iroh to maintain a secure, low-latency connection, even in challenging network situations."><title>iroh_relay - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_relay</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_relay/lib.rs.html#1-57">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Iroh’s relay is a feature within <a href="https://github.com/n0-computer/iroh">iroh</a>, a peer-to-peer
networking system designed to facilitate direct, encrypted connections between devices. Iroh
aims to simplify decentralized communication by automatically handling connections through
“relays” when direct connections aren’t immediately possible. The relay server helps establish
@@ -26,5 +26,5 @@ STUN support and expose metrics.</p>
</li>
</ul>
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.MAX_PACKET_SIZE"><code>pub use protos::relay::<a class="constant" href="protos/relay/constant.MAX_PACKET_SIZE.html" title="constant iroh_relay::protos::relay::MAX_PACKET_SIZE">MAX_PACKET_SIZE</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="client/index.html" title="mod iroh_relay::client">client</a></div><div class="desc docblock-short">Exposes <a href="client/struct.Client.html" title="struct iroh_relay::client::Client"><code>Client</code></a>, which allows to establish connections to a relay server.</div></li><li><div class="item-name"><a class="mod" href="defaults/index.html" title="mod iroh_relay::defaults">defaults</a></div><div class="desc docblock-short">Default values used in the relay.</div></li><li><div class="item-name"><a class="mod" href="http/index.html" title="mod iroh_relay::http">http</a></div><div class="desc docblock-short">HTTP-specific constants for the relay server and client.</div></li><li><div class="item-name"><a class="mod" href="protos/index.html" title="mod iroh_relay::protos">protos</a></div><div class="desc docblock-short">Protocols used by the iroh-relay</div></li><li><div class="item-name"><a class="mod" href="quic/index.html" title="mod iroh_relay::quic">quic</a></div><div class="desc docblock-short">Create a QUIC server that accepts connections
for QUIC address discovery.</div></li><li><div class="item-name"><a class="mod" href="server/index.html" title="mod iroh_relay::server">server</a><wbr><span class="stab portability" title="Available on crate feature `server` only"><code>server</code></span></div><div class="desc docblock-short">A fully-fledged iroh-relay server over HTTP or HTTPS.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.PingTracker.html" title="struct iroh_relay::PingTracker">Ping<wbr>Tracker</a></div><div class="desc docblock-short">Tracks pings on a single relay connection.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayMap.html" title="struct iroh_relay::RelayMap">Relay<wbr>Map</a></div><div class="desc docblock-short">Configuration of all the relay servers that can be used.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayNode.html" title="struct iroh_relay::RelayNode">Relay<wbr>Node</a></div><div class="desc docblock-short">Information on a specific relay server.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayQuicConfig.html" title="struct iroh_relay::RelayQuicConfig">Relay<wbr>Quic<wbr>Config</a></div><div class="desc docblock-short">Configuration for speaking to the QUIC endpoint on the relay
for QUIC address discovery.</div></li><li><div class="item-name"><a class="mod" href="server/index.html" title="mod iroh_relay::server">server</a><wbr><span class="stab portability" title="Available on crate feature `server` only"><code>server</code></span></div><div class="desc docblock-short">A fully-fledged iroh-relay server over HTTP or HTTPS.</div></li><li><div class="item-name"><a class="mod" href="time/index.html" title="mod iroh_relay::time">time</a></div><div class="desc docblock-short">Sleep and timeout utilities that work natively (via tokio) and in the browser.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.PingTracker.html" title="struct iroh_relay::PingTracker">Ping<wbr>Tracker</a></div><div class="desc docblock-short">Tracks pings on a single relay connection.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayMap.html" title="struct iroh_relay::RelayMap">Relay<wbr>Map</a></div><div class="desc docblock-short">Configuration of all the relay servers that can be used.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayNode.html" title="struct iroh_relay::RelayNode">Relay<wbr>Node</a></div><div class="desc docblock-short">Information on a specific relay server.</div></li><li><div class="item-name"><a class="struct" href="struct.RelayQuicConfig.html" title="struct iroh_relay::RelayQuicConfig">Relay<wbr>Quic<wbr>Config</a></div><div class="desc docblock-short">Configuration for speaking to the QUIC endpoint on the relay
server to do QUIC address discovery.</div></li></ul></section></div></main></body></html>
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="This module implements the relaying protocol used by the `server` and `client`."><title>iroh_relay::protos::relay - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module relay</a></h2><h3><a href="#constants">Module Items</a></h3><ul class="block"><li><a href="#constants" title="Constants">Constants</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In iroh_<wbr>relay::<wbr>protos</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">iroh_relay</a>::<wbr><a href="../index.html">protos</a></span><h1>Module <span>relay</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/iroh_relay/protos/relay.rs.html#1-863">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module implements the relaying protocol used by the <code>server</code> and <code>client</code>.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="This module implements the relaying protocol used by the `server` and `client`."><title>iroh_relay::protos::relay - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module relay</a></h2><h3><a href="#constants">Module Items</a></h3><ul class="block"><li><a href="#constants" title="Constants">Constants</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In iroh_<wbr>relay::<wbr>protos</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../index.html">iroh_relay</a>::<wbr><a href="../index.html">protos</a></span><h1>Module <span>relay</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../../src/iroh_relay/protos/relay.rs.html#1-868">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module implements the relaying protocol used by the <code>server</code> and <code>client</code>.</p>
<p>Protocol flow:</p>
<p>Login:</p>
<ul>
@@ -5,7 +5,7 @@ address discovery.</p>
&amp;self,
server_addr: <a class="enum" href="https://doc.rust-lang.org/nightly/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</a>,
host: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
) -&gt; <a class="type" href="https://docs.rs/anyhow/1.0.95/anyhow/type.Result.html" title="type anyhow::Result">Result</a>&lt;(<a class="enum" href="https://doc.rust-lang.org/nightly/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)&gt;</h4></section></summary><div class="docblock"><p>Client side of QUIC address discovery.</p>
) -&gt; <a class="type" href="https://docs.rs/anyhow/1.0.95/anyhow/type.Result.html" title="type anyhow::Result">Result</a>&lt;(<a class="enum" href="https://doc.rust-lang.org/nightly/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</a>, <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>)&gt;</h4></section></summary><div class="docblock"><p>Client side of QUIC address discovery.</p>
<p>Creates a connection and returns the observed address
and estimated latency of the connection.</p>
<p>Consumes and gracefully closes the connection.</p>
@@ -1,2 +1,2 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The default certificate reload interval."><title>DEFAULT_CERT_RELOAD_INTERVAL in iroh_relay::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>relay::<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a>::<wbr><a href="index.html">server</a></span><h1>Constant <span class="constant">DEFAULT_CERT_RELOAD_INTERVAL</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_relay/server/resolver.rs.html#12">Source</a> </span></div><pre class="rust item-decl"><code>pub const DEFAULT_CERT_RELOAD_INTERVAL: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>;</code></pre><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>server</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The default certificate reload interval.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The default certificate reload interval."><title>DEFAULT_CERT_RELOAD_INTERVAL in iroh_relay::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>relay::<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a>::<wbr><a href="index.html">server</a></span><h1>Constant <span class="constant">DEFAULT_CERT_RELOAD_INTERVAL</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_relay/server/resolver.rs.html#12">Source</a> </span></div><pre class="rust item-decl"><code>pub const DEFAULT_CERT_RELOAD_INTERVAL: <a class="struct" href="../time/struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>;</code></pre><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>server</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The default certificate reload interval.</p>
</div></details></section></div></main></body></html>
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A fully-fledged iroh-relay server over HTTP or HTTPS."><title>iroh_relay::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module server</a></h2><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#constants" title="Constants">Constants</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>relay</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a></span><h1>Module <span>server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_relay/server.rs.html#1-1239">Source</a> </span></div><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>server</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A fully-fledged iroh-relay server over HTTP or HTTPS.</p>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A fully-fledged iroh-relay server over HTTP or HTTPS."><title>iroh_relay::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module server</a></h2><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#constants" title="Constants">Constants</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>relay</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a></span><h1>Module <span>server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_relay/server.rs.html#1-1240">Source</a> </span></div><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>server</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A fully-fledged iroh-relay server over HTTP or HTTPS.</p>
<p>This module provides an API to run a full fledged iroh-relay server. It is primarily
used by the <code>iroh-relay</code> binary in this crate. It can be used to run a relay server in
other locations however.</p>
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
window.SIDEBAR_ITEMS = {"mod":["client","defaults","http","protos","quic","server"],"struct":["PingTracker","RelayMap","RelayNode","RelayQuicConfig"]};
window.SIDEBAR_ITEMS = {"mod":["client","defaults","http","protos","quic","server","time"],"struct":["PingTracker","RelayMap","RelayNode","RelayQuicConfig"]};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,36 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Waits until `duration` has elapsed."><title>sleep in iroh_relay::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>relay::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">sleep</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn sleep(duration: <a class="struct" href="struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct iroh_relay::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep">ⓘ</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>duration</code> has elapsed.</p>
<p>Equivalent to <code>sleep_until(Instant::now() + duration)</code>. An asynchronous
analog to <code>std::thread::sleep</code>.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers. The implementation is platform specific,
and some platforms (specifically Windows) will provide timers with a
larger resolution than 1 ms.</p>
<p>To run something regularly on a schedule, see <a href="crate::time::interval()"><code>interval</code></a>.</p>
<p>The maximum duration for a sleep is 68719476734 milliseconds (approximately 2.2 years).</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep, Duration};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
sleep(Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);
}</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct iroh_relay::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_relay::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_relay::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>
@@ -0,0 +1,31 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Waits until `deadline` is reached."><title>sleep_until in iroh_relay::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">sleep_<wbr>until</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>relay::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">sleep_until</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn sleep_until(deadline: <a class="struct" href="struct.Instant.html" title="struct iroh_relay::time::Instant">Instant</a>) -&gt; <a class="struct" href="struct.Sleep.html" title="struct iroh_relay::time::Sleep">Sleep</a> <a href="#" class="tooltip" data-notable-ty="Sleep">ⓘ</a></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Waits until <code>deadline</code> is reached.</p>
<p>No work is performed while awaiting on the sleep future to complete. <code>Sleep</code>
operates at millisecond granularity and should not be used for tasks that
require high-resolution timers.</p>
<p>To run something regularly on a schedule, see <a href="crate::time::interval()"><code>interval</code></a>.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Canceling a sleep instance is done by dropping the returned future. No additional
cleanup work is required.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Wait 100ms and print “100 ms have elapsed”.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::{sleep_until, Instant, Duration};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
sleep_until(Instant::now() + Duration::from_millis(<span class="number">100</span>)).<span class="kw">await</span>;
<span class="macro">println!</span>(<span class="string">"100 ms have elapsed"</span>);
}</code></pre></div>
<p>See the documentation for the <a href="struct.Sleep.html" title="struct iroh_relay::time::Sleep"><code>Sleep</code></a> type for more examples.</p>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Sleep":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_relay::time::Sleep\">Sleep</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Sleep.html\" title=\"struct iroh_relay::time::Sleep\">Sleep</a></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"primitive\" href=\"https://doc.rust-lang.org/nightly/std/primitive.unit.html\">()</a>;</div>"}</script></section></div></main></body></html>
@@ -0,0 +1,47 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Requires a `Future` to complete before the specified duration has elapsed."><title>timeout in iroh_relay::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">timeout</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#cancellation" title="Cancellation">Cancellation</a></li><li><a href="#examples" title="Examples">Examples</a></li><li><a href="#panics" title="Panics">Panics</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>relay::<wbr>time</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a>::<wbr><a href="index.html">time</a></span><h1>Function <span class="fn">timeout</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"></span></div><pre class="rust item-decl"><code>pub fn timeout&lt;F&gt;(
duration: <a class="struct" href="struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a>,
future: F,
) -&gt; <a class="struct" href="struct.Timeout.html" title="struct iroh_relay::time::Timeout">Timeout</a>&lt;&lt;F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html#associatedtype.IntoFuture" title="type core::future::into_future::IntoFuture::IntoFuture">IntoFuture</a>&gt; <a href="#" class="tooltip" data-notable-ty="Timeout&lt;&lt;F as IntoFuture&gt;::IntoFuture&gt;">ⓘ</a><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/into_future/trait.IntoFuture.html" title="trait core::future::into_future::IntoFuture">IntoFuture</a>,</div></code></pre><span class="item-info"><div class="stab portability">Available on <strong>non-<code>wasm_browser</code></strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Requires a <code>Future</code> to complete before the specified duration has elapsed.</p>
<p>If the future completes before the duration has elapsed, then the completed
value is returned. Otherwise, an error is returned and the future is
canceled.</p>
<p>Note that the timeout is checked before polling the future, so if the future
does not yield during execution then it is possible for the future to complete
and exceed the timeout <em>without</em> returning an error.</p>
<p>This function returns a future whose return type is <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a><code>&lt;T,</code><a href="struct.Elapsed.html" title="struct iroh_relay::time::Elapsed"><code>Elapsed</code></a><code>&gt;</code>, where <code>T</code> is the
return type of the provided future.</p>
<p>If the provided future completes immediately, then the future returned from
this function is guaranteed to complete immediately with an <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a> variant
no matter the provided duration.</p>
<h2 id="cancellation"><a class="doc-anchor" href="#cancellation">§</a>Cancellation</h2>
<p>Cancelling a timeout is done by dropping the future. No additional cleanup
or other work is required.</p>
<p>The original future may be obtained by calling <a href="struct.Timeout.html#method.into_inner" title="method iroh_relay::time::Timeout::into_inner"><code>Timeout::into_inner</code></a>. This
consumes the <code>Timeout</code>.</p>
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
<p>Create a new <code>Timeout</code> set to expire in 10 milliseconds.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio::time::timeout;
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>std::time::Duration;
<span class="kw">let </span>(tx, rx) = oneshot::channel();
<span class="comment">// Wrap the future with a `Timeout` set to expire in 10 milliseconds.
</span><span class="kw">if let </span><span class="prelude-val">Err</span>(<span class="kw">_</span>) = timeout(Duration::from_millis(<span class="number">10</span>), rx).<span class="kw">await </span>{
<span class="macro">println!</span>(<span class="string">"did not receive value within 10 ms"</span>);
}</code></pre></div>
<h2 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h2>
<p>This function panics if there is no current timer set.</p>
<p>It can be triggered when <a href="crate::runtime::Builder::enable_time"><code>Builder::enable_time</code></a> or
<a href="crate::runtime::Builder::enable_all"><code>Builder::enable_all</code></a> are not included in the builder.</p>
<p>It can also panic whenever a timer is created outside of a
Tokio runtime. That is why <code>rt.block_on(sleep(...))</code> will panic,
since the function is executed outside of the runtime.
Whereas <code>rt.block_on(async {sleep(...).await})</code> doesn’t panic.
And this is because wrapping the function on an async makes it lazy,
and so gets executed inside the runtime successfully without
panicking.</p>
</div></details><script type="text/json" id="notable-traits-data">{"Timeout<<F as IntoFuture>::IntoFuture>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_relay::time::Timeout\">Timeout</a>&lt;T&gt;</code></h3><pre><code><div class=\"where\">impl&lt;T&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a> for <a class=\"struct\" href=\"struct.Timeout.html\" title=\"struct iroh_relay::time::Timeout\">Timeout</a>&lt;T&gt;<div class=\"where\">where\n T: <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>,</div></div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" class=\"associatedtype\">Output</a> = <a class=\"enum\" href=\"https://doc.rust-lang.org/nightly/core/result/enum.Result.html\" title=\"enum core::result::Result\">Result</a>&lt;&lt;T as <a class=\"trait\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html\" title=\"trait core::future::future::Future\">Future</a>&gt;::<a class=\"associatedtype\" href=\"https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output\" title=\"type core::future::future::Future::Output\">Output</a>, <a class=\"struct\" href=\"struct.Elapsed.html\" title=\"struct iroh_relay::time::Elapsed\">Elapsed</a>&gt;;</div>"}</script></section></div></main></body></html>
+4
View File
@@ -0,0 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Sleep and timeout utilities that work natively (via tokio) and in the browser."><title>iroh_relay::time - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_relay/index.html">iroh_<wbr>relay</a><span class="version">0.31.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module time</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>relay</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_relay</a></span><h1>Module <span>time</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_relay/time.rs.html#1-285">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Sleep and timeout utilities that work natively (via tokio) and in the browser.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Duration.html" title="struct iroh_relay::time::Duration">Duration</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A <code>Duration</code> type to represent a span of time, typically used for system
timeouts.</div></li><li><div class="item-name"><a class="struct" href="struct.Elapsed.html" title="struct iroh_relay::time::Elapsed">Elapsed</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Errors returned by <code>Timeout</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Instant.html" title="struct iroh_relay::time::Instant">Instant</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">A measurement of a monotonically nondecreasing clock.
Opaque and useful only with <code>Duration</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.Sleep.html" title="struct iroh_relay::time::Sleep">Sleep</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Future returned by <a href="fn.sleep.html" title="fn iroh_relay::time::sleep"><code>sleep</code></a> and <a href="fn.sleep_until.html" title="fn iroh_relay::time::sleep_until"><code>sleep_until</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.Timeout.html" title="struct iroh_relay::time::Timeout">Timeout</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Future returned by <a href="fn.timeout.html" title="fn iroh_relay::time::timeout"><code>timeout</code></a> and <a href="timeout_at"><code>timeout_at</code></a>.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.sleep.html" title="fn iroh_relay::time::sleep">sleep</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Waits until <code>duration</code> has elapsed.</div></li><li><div class="item-name"><a class="fn" href="fn.sleep_until.html" title="fn iroh_relay::time::sleep_until">sleep_<wbr>until</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Waits until <code>deadline</code> is reached.</div></li><li><div class="item-name"><a class="fn" href="fn.timeout.html" title="fn iroh_relay::time::timeout">timeout</a><wbr><span class="stab portability" title="Available on non-`wasm_browser` only">Non-<code>wasm_browser</code></span></div><div class="desc docblock-short">Requires a <code>Future</code> to complete before the specified duration has elapsed.</div></li></ul></section></div></main></body></html>
@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"fn":["sleep","sleep_until","timeout"],"struct":["Duration","Elapsed","Instant","Sleep","Timeout"]};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,3 +1,3 @@
var srcIndex = new Map(JSON.parse('[["bulk",["",[],["bulk.rs"]]],["iroh",["",[["discovery",[["pkarr",[],["dht.rs"]]],["dns.rs","local_swarm_discovery.rs","pkarr.rs","static_provider.rs"]],["dns",[],["node_info.rs"]],["endpoint",[],["rtt_actor.rs"]],["magicsock",[["node_map",[],["best_addr.rs","node_state.rs","path_state.rs","udp_paths.rs"]]],["metrics.rs","node_map.rs","relay_actor.rs","timer.rs","udp_conn.rs"]],["tls",[],["certificate.rs","verifier.rs"]]],["defaults.rs","disco.rs","discovery.rs","dns.rs","endpoint.rs","key.rs","lib.rs","magicsock.rs","metrics.rs","protocol.rs","test_utils.rs","tls.rs","util.rs","watchable.rs"]]],["iroh_base",["",[["ticket",[],["node.rs"]]],["key.rs","lib.rs","node_addr.rs","relay_url.rs","ticket.rs"]]],["iroh_bench",["",[],["iroh.rs","lib.rs","quinn.rs","s2n.rs","stats.rs"]]],["iroh_dns_server",["",[["dns",[],["node_authority.rs"]],["http",[["doh",[],["extract.rs","response.rs"]]],["doh.rs","error.rs","pkarr.rs","rate_limiting.rs","tls.rs"]],["store",[],["signed_packets.rs"]]],["config.rs","dns.rs","http.rs","lib.rs","metrics.rs","server.rs","state.rs","store.rs","util.rs"]]],["iroh_net_report",["",[["reportgen",[],["hairpin.rs","probes.rs"]],["task",[],["tokio.rs"]]],["defaults.rs","dns.rs","lib.rs","metrics.rs","ping.rs","reportgen.rs","task.rs","time.rs"]]],["iroh_relay",["",[["client",[],["conn.rs","connect_relay.rs","streams.rs","util.rs"]],["protos",[],["disco.rs","relay.rs","stun.rs"]],["server",[],["client.rs","clients.rs","http_server.rs","metrics.rs","resolver.rs","streams.rs","testing.rs"]]],["client.rs","defaults.rs","http.rs","key_cache.rs","lib.rs","ping_tracker.rs","protos.rs","quic.rs","relay_map.rs","server.rs"]]],["iroh_test",["",[],["hexdump.rs","lib.rs","logging.rs"]]]]'));
var srcIndex = new Map(JSON.parse('[["bulk",["",[],["bulk.rs"]]],["iroh",["",[["discovery",[["pkarr",[],["dht.rs"]]],["dns.rs","local_swarm_discovery.rs","pkarr.rs","static_provider.rs"]],["dns",[],["node_info.rs"]],["endpoint",[],["rtt_actor.rs"]],["magicsock",[["node_map",[],["best_addr.rs","node_state.rs","path_state.rs","udp_paths.rs"]]],["metrics.rs","node_map.rs","relay_actor.rs","timer.rs","udp_conn.rs"]],["tls",[],["certificate.rs","verifier.rs"]]],["defaults.rs","disco.rs","discovery.rs","dns.rs","endpoint.rs","key.rs","lib.rs","magicsock.rs","metrics.rs","protocol.rs","test_utils.rs","tls.rs","util.rs","watchable.rs"]]],["iroh_base",["",[["ticket",[],["node.rs"]]],["key.rs","lib.rs","node_addr.rs","relay_url.rs","ticket.rs"]]],["iroh_bench",["",[],["iroh.rs","lib.rs","quinn.rs","s2n.rs","stats.rs"]]],["iroh_dns_server",["",[["dns",[],["node_authority.rs"]],["http",[["doh",[],["extract.rs","response.rs"]]],["doh.rs","error.rs","pkarr.rs","rate_limiting.rs","tls.rs"]],["store",[],["signed_packets.rs"]]],["config.rs","dns.rs","http.rs","lib.rs","metrics.rs","server.rs","state.rs","store.rs","util.rs"]]],["iroh_net_report",["",[["reportgen",[],["hairpin.rs","probes.rs"]]],["defaults.rs","dns.rs","lib.rs","metrics.rs","ping.rs","reportgen.rs","task.rs"]]],["iroh_relay",["",[["client",[],["conn.rs","connect_relay.rs","streams.rs","util.rs"]],["protos",[],["disco.rs","relay.rs","stun.rs"]],["server",[],["client.rs","clients.rs","http_server.rs","metrics.rs","resolver.rs","streams.rs","testing.rs"]]],["client.rs","defaults.rs","http.rs","key_cache.rs","lib.rs","ping_tracker.rs","protos.rs","quic.rs","relay_map.rs","server.rs","time.rs"]]],["iroh_test",["",[],["hexdump.rs","lib.rs","logging.rs"]]]]'));
createSrcSidebar();
//{"start":36,"fragment_lengths":[28,573,109,75,306,188,378,59]}
//{"start":36,"fragment_lengths":[28,573,109,75,306,153,388,59]}
@@ -40,7 +40,7 @@
/// Contains all timeouts that we use in `iroh-net-report`.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">mod </span>timeouts {
<span class="kw">use </span><span class="kw">crate</span>::time::Duration;
<span class="kw">use </span>iroh_relay::time::Duration;
<span class="comment">// Timeouts for net_report
+4 -2
View File
@@ -260,13 +260,15 @@
<a href="#259" id="259">259</a>
<a href="#260" id="260">260</a>
<a href="#261" id="261">261</a>
<a href="#262" id="262">262</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{fmt::Write, net::IpAddr};
<a href="#262" id="262">262</a>
<a href="#263" id="263">263</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{fmt::Write, net::IpAddr};
<span class="kw">use </span>anyhow::Result;
<span class="kw">use </span>futures_lite::{Future, StreamExt};
<span class="kw">use </span>hickory_resolver::{IntoName, TokioResolver};
<span class="kw">use </span>iroh_relay::time;
<span class="kw">use crate</span>::{defaults::timeouts::DNS_TIMEOUT, time};
<span class="kw">use </span><span class="kw">crate</span>::defaults::timeouts::DNS_TIMEOUT;
<span class="doccomment">/// Delay used to perform staggered dns queries.
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">const </span>DNS_STAGGERING_MS: <span class="kw-2">&amp;</span>[u64] = <span class="kw-2">&amp;</span>[<span class="number">200</span>, <span class="number">300</span>];
+28 -64
View File
@@ -1518,25 +1518,7 @@
<a href="#1517" id="1517">1517</a>
<a href="#1518" id="1518">1518</a>
<a href="#1519" id="1519">1519</a>
<a href="#1520" id="1520">1520</a>
<a href="#1521" id="1521">1521</a>
<a href="#1522" id="1522">1522</a>
<a href="#1523" id="1523">1523</a>
<a href="#1524" id="1524">1524</a>
<a href="#1525" id="1525">1525</a>
<a href="#1526" id="1526">1526</a>
<a href="#1527" id="1527">1527</a>
<a href="#1528" id="1528">1528</a>
<a href="#1529" id="1529">1529</a>
<a href="#1530" id="1530">1530</a>
<a href="#1531" id="1531">1531</a>
<a href="#1532" id="1532">1532</a>
<a href="#1533" id="1533">1533</a>
<a href="#1534" id="1534">1534</a>
<a href="#1535" id="1535">1535</a>
<a href="#1536" id="1536">1536</a>
<a href="#1537" id="1537">1537</a>
<a href="#1538" id="1538">1538</a></pre></div><pre class="rust"><code><span class="doccomment">//! Checks the network conditions from the current host.
<a href="#1520" id="1520">1520</a></pre></div><pre class="rust"><code><span class="doccomment">//! Checks the network conditions from the current host.
//!
//! NetReport is responsible for finding out the network conditions of the current host, like
//! whether it is connected to the internet via IPv4 and/or IPv6, what the NAT situation is
@@ -1544,8 +1526,8 @@
</span><span class="comment">// Based on &lt;https://github.com/tailscale/tailscale/blob/main/net/netcheck/netcheck.go&gt;
</span><span class="attr">#![cfg_attr(iroh_docsrs, feature(doc_auto_cfg))]
</span><span class="comment">// #![deny(missing_docs, rustdoc::broken_intra_doc_links)]
</span><span class="attr">#![cfg_attr(not(test), deny(clippy::unwrap_used))]
#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
</span><span class="kw">use </span>std::{
collections::{BTreeMap, BTreeSet, HashMap},
@@ -1555,7 +1537,6 @@
};
<span class="kw">use </span><span class="kw">crate</span>::task::AbortOnDropHandle;
<span class="kw">use </span><span class="kw">crate</span>::time::{Duration, Instant};
<span class="kw">use </span>anyhow::{anyhow, <span class="prelude-ty">Result</span>};
<span class="kw">use </span>bytes::Bytes;
<span class="attr">#[cfg(not(wasm_browser))]
@@ -1563,7 +1544,11 @@
<span class="kw">use </span>iroh_base::RelayUrl;
<span class="attr">#[cfg(feature = <span class="string">"metrics"</span>)]
</span><span class="kw">use </span>iroh_metrics::inc;
<span class="kw">use </span>iroh_relay::{protos::stun, RelayMap};
<span class="kw">use </span>iroh_relay::{
protos::stun,
time::{<span class="self">self</span>, Duration, Instant},
RelayMap,
};
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">use </span>netwatch::UdpSocket;
<span class="kw">use </span>tokio::sync::{<span class="self">self</span>, mpsc, oneshot};
@@ -1578,7 +1563,6 @@
<span class="kw">mod </span>reportgen;
<span class="kw">pub mod </span>task;
<span class="kw">pub mod </span>time;
<span class="kw">pub use </span>metrics::Metrics;
<span class="kw">use </span>reportgen::ProbeProto;
@@ -1917,23 +1901,16 @@
///
/// This starts a connected actor in the background. Once the client is dropped it will
/// stop running.
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub fn </span>new(port_mapper: <span class="prelude-ty">Option</span>&lt;portmapper::Client&gt;, dns_resolver: DnsResolver) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>actor = Actor::new(port_mapper, dns_resolver)<span class="question-mark">?</span>;
<span class="kw">let </span>addr = actor.addr();
<span class="kw">let </span>task = task::spawn(
<span class="kw">async move </span>{ actor.run().<span class="kw">await </span>}.instrument(<span class="macro">info_span!</span>(<span class="string">"net_report.actor"</span>)),
);
<span class="kw">let </span>drop_guard = AbortOnDropHandle::new(task);
<span class="prelude-val">Ok</span>(Client {
addr,
_drop_guard: Arc::new(drop_guard),
})
}
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub fn </span>new() -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>actor = Actor::new();
</span><span class="kw">pub fn </span>new(
<span class="attr">#[cfg(not(wasm_browser))] </span>port_mapper: <span class="prelude-ty">Option</span>&lt;portmapper::Client&gt;,
<span class="attr">#[cfg(not(wasm_browser))] </span>dns_resolver: DnsResolver,
) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>actor = Actor::new(
<span class="attr">#[cfg(not(wasm_browser))]
</span>port_mapper,
<span class="attr">#[cfg(not(wasm_browser))]
</span>dns_resolver,
)<span class="question-mark">?</span>;
<span class="kw">let </span>addr = actor.addr();
<span class="kw">let </span>task = task::spawn(
<span class="kw">async move </span>{ actor.run().<span class="kw">await </span>}.instrument(<span class="macro">info_span!</span>(<span class="string">"net_report.actor"</span>)),
@@ -2162,33 +2139,25 @@
///
/// This does not start the actor, see [`Actor::run`] for this. You should not
/// normally create this directly but rather create a [`Client`].
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">fn </span>new(port_mapper: <span class="prelude-ty">Option</span>&lt;portmapper::Client&gt;, dns_resolver: DnsResolver) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
</span><span class="kw">fn </span>new(
<span class="attr">#[cfg(not(wasm_browser))] </span>port_mapper: <span class="prelude-ty">Option</span>&lt;portmapper::Client&gt;,
<span class="attr">#[cfg(not(wasm_browser))] </span>dns_resolver: DnsResolver,
) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>&gt; {
<span class="comment">// TODO: consider an instrumented flume channel so we have metrics.
</span><span class="kw">let </span>(sender, receiver) = mpsc::channel(<span class="number">32</span>);
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
receiver,
sender,
reports: Default::default(),
port_mapper,
<span class="attr">#[cfg(not(wasm_browser))]
</span>port_mapper,
in_flight_stun_requests: Default::default(),
current_report_run: <span class="prelude-val">None</span>,
dns_resolver,
<span class="attr">#[cfg(not(wasm_browser))]
</span>dns_resolver,
})
}
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">fn </span>new() -&gt; <span class="self">Self </span>{
<span class="kw">let </span>(sender, receiver) = mpsc::channel(<span class="number">32</span>);
<span class="self">Self </span>{
receiver,
sender,
reports: Default::default(),
in_flight_stun_requests: Default::default(),
current_report_run: <span class="prelude-val">None</span>,
}
}
<span class="doccomment">/// Returns the channel to send messages to the actor.
</span><span class="kw">fn </span>addr(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Addr {
Addr {
@@ -2474,11 +2443,6 @@
UdpSocket::bind_local_v6(<span class="number">0</span>).is_ok()
}
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub fn </span>os_has_ipv6() -&gt; bool {
<span class="bool-val">false
</span>}
<span class="attr">#[cfg(any(test, feature = <span class="string">"stun-utils"</span>))]
</span><span class="kw">pub</span>(<span class="kw">crate</span>) <span class="kw">mod </span>stun_utils {
<span class="kw">use </span>anyhow::Context <span class="kw">as _</span>;
@@ -2606,7 +2570,7 @@
<span class="kw">use </span>tracing::info;
<span class="kw">use super</span>::<span class="kw-2">*</span>;
<span class="kw">use crate</span>::{ping::Pinger, stun_utils::bind_local_stun_socket, time};
<span class="kw">use crate</span>::{ping::Pinger, stun_utils::bind_local_stun_socket};
<span class="kw">mod </span>stun_utils {
<span class="doccomment">//! Utils for testing that expose a simple stun server.
@@ -3001,7 +2965,7 @@
<span class="kw">let </span><span class="kw-2">mut </span>actor = Actor::new(<span class="prelude-val">None</span>, resolver.clone()).unwrap();
<span class="kw">for </span>s <span class="kw">in </span><span class="kw-2">&amp;mut </span>tt.steps {
<span class="comment">// trigger the timer
</span>time::advance(Duration::from_secs(s.after)).<span class="kw">await</span>;
</span>tokio::time::advance(Duration::from_secs(s.after)).<span class="kw">await</span>;
<span class="kw">let </span>r = Arc::try_unwrap(s.r.take().unwrap()).unwrap();
s.r = <span class="prelude-val">Some</span>(actor.add_report_history_and_set_preferred_relay(r));
}
@@ -197,10 +197,10 @@
fmt::Debug,
net::IpAddr,
sync::{Arc, Mutex},
time::Duration,
};
<span class="kw">use </span>anyhow::{Context, <span class="prelude-ty">Result</span>};
<span class="kw">use </span>iroh_relay::time::Duration;
<span class="kw">use </span>surge_ping::{Client, Config, IcmpPacket, PingIdentifier, PingSequence, ICMP};
<span class="kw">use </span>tracing::debug;
@@ -1710,7 +1710,9 @@
<a href="#1709" id="1709">1709</a>
<a href="#1710" id="1710">1710</a>
<a href="#1711" id="1711">1711</a>
<a href="#1712" id="1712">1712</a></pre></div><pre class="rust"><code><span class="doccomment">//! The reportgen actor is responsible for generating a single net_report report.
<a href="#1712" id="1712">1712</a>
<a href="#1713" id="1713">1713</a>
<a href="#1714" id="1714">1714</a></pre></div><pre class="rust"><code><span class="doccomment">//! The reportgen actor is responsible for generating a single net_report report.
//!
//! It is implemented as an actor with [`Client`] as handle.
//!
@@ -1735,11 +1737,9 @@
pin::Pin,
sync::Arc,
task::{Context, Poll},
time::Duration,
};
<span class="kw">use </span><span class="kw">crate</span>::task::{<span class="self">self</span>, AbortOnDropHandle, JoinSet};
<span class="kw">use </span><span class="kw">crate</span>::time::{<span class="self">self</span>, Instant};
<span class="kw">use </span>anyhow::{anyhow, bail, Context <span class="kw">as _</span>, <span class="prelude-ty">Result</span>};
<span class="kw">use </span>futures_lite::StreamExt <span class="kw">as _</span>;
<span class="attr">#[cfg(not(wasm_browser))]
@@ -1751,6 +1751,7 @@
defaults::{DEFAULT_RELAY_QUIC_PORT, DEFAULT_STUN_PORT},
http::RELAY_PROBE_PATH,
protos::stun,
time::{<span class="self">self</span>, Duration, Instant},
RelayMap, RelayNode,
};
<span class="attr">#[cfg(not(wasm_browser))]
@@ -1963,7 +1964,10 @@
</span><span class="kw">let </span>port_mapper = <span class="bool-val">false</span>;
<span class="macro">debug!</span>(%port_mapper, <span class="string">"reportstate actor starting"</span>);
<span class="self">self</span>.report.os_has_ipv6 = <span class="kw">super</span>::os_has_ipv6();
<span class="attr">#[cfg(not(wasm_browser))]
</span>{
<span class="self">self</span>.report.os_has_ipv6 = <span class="kw">super</span>::os_has_ipv6();
}
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">let </span><span class="kw-2">mut </span>port_mapping = <span class="self">self</span>.prepare_portmapper_task();
@@ -302,7 +302,11 @@
<a href="#301" id="301">301</a>
<a href="#302" id="302">302</a>
<a href="#303" id="303">303</a>
<a href="#304" id="304">304</a></pre></div><pre class="rust"><code><span class="doccomment">//! Actor to run hairpinning check.
<a href="#304" id="304">304</a>
<a href="#305" id="305">305</a>
<a href="#306" id="306">306</a>
<a href="#307" id="307">307</a>
<a href="#308" id="308">308</a></pre></div><pre class="rust"><code><span class="doccomment">//! Actor to run hairpinning check.
//!
//! This actor works as follows:
//!
@@ -321,12 +325,16 @@
<span class="kw">use </span>anyhow::{bail, Context, <span class="prelude-ty">Result</span>};
<span class="kw">use </span>iroh_relay::protos::stun;
<span class="kw">use </span>netwatch::UdpSocket;
<span class="kw">use </span>tokio::{sync::oneshot, time::Instant};
<span class="kw">use </span>tokio::sync::oneshot;
<span class="kw">use </span>tokio_util::task::AbortOnDropHandle;
<span class="kw">use </span>tracing::{debug, error, info_span, trace, warn, Instrument};
<span class="kw">use crate</span>::{
<span class="self">self </span><span class="kw">as </span>net_report, defaults::timeouts::HAIRPIN_CHECK_TIMEOUT, reportgen, task, time, Inflight,
<span class="self">self </span><span class="kw">as </span>net_report,
defaults::timeouts::HAIRPIN_CHECK_TIMEOUT,
reportgen, task,
time::{<span class="self">self</span>, Instant},
Inflight,
};
<span class="doccomment">/// Handle to the hairpin actor.
@@ -479,8 +487,8 @@
<span class="attr">#[cfg(test)]
</span><span class="kw">mod </span>tests {
<span class="kw">use </span><span class="kw">crate</span>::time::Duration;
<span class="kw">use </span>bytes::BytesMut;
<span class="kw">use </span>iroh_relay::time::Duration;
<span class="kw">use </span>tokio::sync::mpsc;
<span class="kw">use </span>tracing::info;
@@ -1205,8 +1205,8 @@
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">use </span>netwatch::interfaces;
<span class="kw">use </span><span class="kw">crate</span>::time::Duration;
<span class="kw">use </span><span class="kw">crate</span>::Report;
<span class="kw">use </span>iroh_relay::time::Duration;
<span class="doccomment">/// The retransmit interval used when net_report first runs.
///
+626 -6
View File
@@ -10,16 +10,636 @@
<a href="#9" id="9">9</a>
<a href="#10" id="10">10</a>
<a href="#11" id="11">11</a>
<a href="#12" id="12">12</a></pre></div><pre class="rust"><code><span class="doccomment">//! Async rust task spawning and utilities that work natively (using tokio) and in browsers
<a href="#12" id="12">12</a>
<a href="#13" id="13">13</a>
<a href="#14" id="14">14</a>
<a href="#15" id="15">15</a>
<a href="#16" id="16">16</a>
<a href="#17" id="17">17</a>
<a href="#18" id="18">18</a>
<a href="#19" id="19">19</a>
<a href="#20" id="20">20</a>
<a href="#21" id="21">21</a>
<a href="#22" id="22">22</a>
<a href="#23" id="23">23</a>
<a href="#24" id="24">24</a>
<a href="#25" id="25">25</a>
<a href="#26" id="26">26</a>
<a href="#27" id="27">27</a>
<a href="#28" id="28">28</a>
<a href="#29" id="29">29</a>
<a href="#30" id="30">30</a>
<a href="#31" id="31">31</a>
<a href="#32" id="32">32</a>
<a href="#33" id="33">33</a>
<a href="#34" id="34">34</a>
<a href="#35" id="35">35</a>
<a href="#36" id="36">36</a>
<a href="#37" id="37">37</a>
<a href="#38" id="38">38</a>
<a href="#39" id="39">39</a>
<a href="#40" id="40">40</a>
<a href="#41" id="41">41</a>
<a href="#42" id="42">42</a>
<a href="#43" id="43">43</a>
<a href="#44" id="44">44</a>
<a href="#45" id="45">45</a>
<a href="#46" id="46">46</a>
<a href="#47" id="47">47</a>
<a href="#48" id="48">48</a>
<a href="#49" id="49">49</a>
<a href="#50" id="50">50</a>
<a href="#51" id="51">51</a>
<a href="#52" id="52">52</a>
<a href="#53" id="53">53</a>
<a href="#54" id="54">54</a>
<a href="#55" id="55">55</a>
<a href="#56" id="56">56</a>
<a href="#57" id="57">57</a>
<a href="#58" id="58">58</a>
<a href="#59" id="59">59</a>
<a href="#60" id="60">60</a>
<a href="#61" id="61">61</a>
<a href="#62" id="62">62</a>
<a href="#63" id="63">63</a>
<a href="#64" id="64">64</a>
<a href="#65" id="65">65</a>
<a href="#66" id="66">66</a>
<a href="#67" id="67">67</a>
<a href="#68" id="68">68</a>
<a href="#69" id="69">69</a>
<a href="#70" id="70">70</a>
<a href="#71" id="71">71</a>
<a href="#72" id="72">72</a>
<a href="#73" id="73">73</a>
<a href="#74" id="74">74</a>
<a href="#75" id="75">75</a>
<a href="#76" id="76">76</a>
<a href="#77" id="77">77</a>
<a href="#78" id="78">78</a>
<a href="#79" id="79">79</a>
<a href="#80" id="80">80</a>
<a href="#81" id="81">81</a>
<a href="#82" id="82">82</a>
<a href="#83" id="83">83</a>
<a href="#84" id="84">84</a>
<a href="#85" id="85">85</a>
<a href="#86" id="86">86</a>
<a href="#87" id="87">87</a>
<a href="#88" id="88">88</a>
<a href="#89" id="89">89</a>
<a href="#90" id="90">90</a>
<a href="#91" id="91">91</a>
<a href="#92" id="92">92</a>
<a href="#93" id="93">93</a>
<a href="#94" id="94">94</a>
<a href="#95" id="95">95</a>
<a href="#96" id="96">96</a>
<a href="#97" id="97">97</a>
<a href="#98" id="98">98</a>
<a href="#99" id="99">99</a>
<a href="#100" id="100">100</a>
<a href="#101" id="101">101</a>
<a href="#102" id="102">102</a>
<a href="#103" id="103">103</a>
<a href="#104" id="104">104</a>
<a href="#105" id="105">105</a>
<a href="#106" id="106">106</a>
<a href="#107" id="107">107</a>
<a href="#108" id="108">108</a>
<a href="#109" id="109">109</a>
<a href="#110" id="110">110</a>
<a href="#111" id="111">111</a>
<a href="#112" id="112">112</a>
<a href="#113" id="113">113</a>
<a href="#114" id="114">114</a>
<a href="#115" id="115">115</a>
<a href="#116" id="116">116</a>
<a href="#117" id="117">117</a>
<a href="#118" id="118">118</a>
<a href="#119" id="119">119</a>
<a href="#120" id="120">120</a>
<a href="#121" id="121">121</a>
<a href="#122" id="122">122</a>
<a href="#123" id="123">123</a>
<a href="#124" id="124">124</a>
<a href="#125" id="125">125</a>
<a href="#126" id="126">126</a>
<a href="#127" id="127">127</a>
<a href="#128" id="128">128</a>
<a href="#129" id="129">129</a>
<a href="#130" id="130">130</a>
<a href="#131" id="131">131</a>
<a href="#132" id="132">132</a>
<a href="#133" id="133">133</a>
<a href="#134" id="134">134</a>
<a href="#135" id="135">135</a>
<a href="#136" id="136">136</a>
<a href="#137" id="137">137</a>
<a href="#138" id="138">138</a>
<a href="#139" id="139">139</a>
<a href="#140" id="140">140</a>
<a href="#141" id="141">141</a>
<a href="#142" id="142">142</a>
<a href="#143" id="143">143</a>
<a href="#144" id="144">144</a>
<a href="#145" id="145">145</a>
<a href="#146" id="146">146</a>
<a href="#147" id="147">147</a>
<a href="#148" id="148">148</a>
<a href="#149" id="149">149</a>
<a href="#150" id="150">150</a>
<a href="#151" id="151">151</a>
<a href="#152" id="152">152</a>
<a href="#153" id="153">153</a>
<a href="#154" id="154">154</a>
<a href="#155" id="155">155</a>
<a href="#156" id="156">156</a>
<a href="#157" id="157">157</a>
<a href="#158" id="158">158</a>
<a href="#159" id="159">159</a>
<a href="#160" id="160">160</a>
<a href="#161" id="161">161</a>
<a href="#162" id="162">162</a>
<a href="#163" id="163">163</a>
<a href="#164" id="164">164</a>
<a href="#165" id="165">165</a>
<a href="#166" id="166">166</a>
<a href="#167" id="167">167</a>
<a href="#168" id="168">168</a>
<a href="#169" id="169">169</a>
<a href="#170" id="170">170</a>
<a href="#171" id="171">171</a>
<a href="#172" id="172">172</a>
<a href="#173" id="173">173</a>
<a href="#174" id="174">174</a>
<a href="#175" id="175">175</a>
<a href="#176" id="176">176</a>
<a href="#177" id="177">177</a>
<a href="#178" id="178">178</a>
<a href="#179" id="179">179</a>
<a href="#180" id="180">180</a>
<a href="#181" id="181">181</a>
<a href="#182" id="182">182</a>
<a href="#183" id="183">183</a>
<a href="#184" id="184">184</a>
<a href="#185" id="185">185</a>
<a href="#186" id="186">186</a>
<a href="#187" id="187">187</a>
<a href="#188" id="188">188</a>
<a href="#189" id="189">189</a>
<a href="#190" id="190">190</a>
<a href="#191" id="191">191</a>
<a href="#192" id="192">192</a>
<a href="#193" id="193">193</a>
<a href="#194" id="194">194</a>
<a href="#195" id="195">195</a>
<a href="#196" id="196">196</a>
<a href="#197" id="197">197</a>
<a href="#198" id="198">198</a>
<a href="#199" id="199">199</a>
<a href="#200" id="200">200</a>
<a href="#201" id="201">201</a>
<a href="#202" id="202">202</a>
<a href="#203" id="203">203</a>
<a href="#204" id="204">204</a>
<a href="#205" id="205">205</a>
<a href="#206" id="206">206</a>
<a href="#207" id="207">207</a>
<a href="#208" id="208">208</a>
<a href="#209" id="209">209</a>
<a href="#210" id="210">210</a>
<a href="#211" id="211">211</a>
<a href="#212" id="212">212</a>
<a href="#213" id="213">213</a>
<a href="#214" id="214">214</a>
<a href="#215" id="215">215</a>
<a href="#216" id="216">216</a>
<a href="#217" id="217">217</a>
<a href="#218" id="218">218</a>
<a href="#219" id="219">219</a>
<a href="#220" id="220">220</a>
<a href="#221" id="221">221</a>
<a href="#222" id="222">222</a>
<a href="#223" id="223">223</a>
<a href="#224" id="224">224</a>
<a href="#225" id="225">225</a>
<a href="#226" id="226">226</a>
<a href="#227" id="227">227</a>
<a href="#228" id="228">228</a>
<a href="#229" id="229">229</a>
<a href="#230" id="230">230</a>
<a href="#231" id="231">231</a>
<a href="#232" id="232">232</a>
<a href="#233" id="233">233</a>
<a href="#234" id="234">234</a>
<a href="#235" id="235">235</a>
<a href="#236" id="236">236</a>
<a href="#237" id="237">237</a>
<a href="#238" id="238">238</a>
<a href="#239" id="239">239</a>
<a href="#240" id="240">240</a>
<a href="#241" id="241">241</a>
<a href="#242" id="242">242</a>
<a href="#243" id="243">243</a>
<a href="#244" id="244">244</a>
<a href="#245" id="245">245</a>
<a href="#246" id="246">246</a>
<a href="#247" id="247">247</a>
<a href="#248" id="248">248</a>
<a href="#249" id="249">249</a>
<a href="#250" id="250">250</a>
<a href="#251" id="251">251</a>
<a href="#252" id="252">252</a>
<a href="#253" id="253">253</a>
<a href="#254" id="254">254</a>
<a href="#255" id="255">255</a>
<a href="#256" id="256">256</a>
<a href="#257" id="257">257</a>
<a href="#258" id="258">258</a>
<a href="#259" id="259">259</a>
<a href="#260" id="260">260</a>
<a href="#261" id="261">261</a>
<a href="#262" id="262">262</a>
<a href="#263" id="263">263</a>
<a href="#264" id="264">264</a>
<a href="#265" id="265">265</a>
<a href="#266" id="266">266</a>
<a href="#267" id="267">267</a>
<a href="#268" id="268">268</a>
<a href="#269" id="269">269</a>
<a href="#270" id="270">270</a>
<a href="#271" id="271">271</a>
<a href="#272" id="272">272</a>
<a href="#273" id="273">273</a>
<a href="#274" id="274">274</a>
<a href="#275" id="275">275</a>
<a href="#276" id="276">276</a>
<a href="#277" id="277">277</a>
<a href="#278" id="278">278</a>
<a href="#279" id="279">279</a>
<a href="#280" id="280">280</a>
<a href="#281" id="281">281</a>
<a href="#282" id="282">282</a>
<a href="#283" id="283">283</a>
<a href="#284" id="284">284</a>
<a href="#285" id="285">285</a>
<a href="#286" id="286">286</a>
<a href="#287" id="287">287</a>
<a href="#288" id="288">288</a>
<a href="#289" id="289">289</a>
<a href="#290" id="290">290</a>
<a href="#291" id="291">291</a>
<a href="#292" id="292">292</a>
<a href="#293" id="293">293</a>
<a href="#294" id="294">294</a>
<a href="#295" id="295">295</a>
<a href="#296" id="296">296</a>
<a href="#297" id="297">297</a>
<a href="#298" id="298">298</a>
<a href="#299" id="299">299</a>
<a href="#300" id="300">300</a>
<a href="#301" id="301">301</a>
<a href="#302" id="302">302</a>
<a href="#303" id="303">303</a>
<a href="#304" id="304">304</a>
<a href="#305" id="305">305</a>
<a href="#306" id="306">306</a>
<a href="#307" id="307">307</a>
<a href="#308" id="308">308</a>
<a href="#309" id="309">309</a>
<a href="#310" id="310">310</a>
<a href="#311" id="311">311</a>
<a href="#312" id="312">312</a>
<a href="#313" id="313">313</a>
<a href="#314" id="314">314</a>
<a href="#315" id="315">315</a>
<a href="#316" id="316">316</a>
<a href="#317" id="317">317</a>
<a href="#318" id="318">318</a>
<a href="#319" id="319">319</a>
<a href="#320" id="320">320</a>
<a href="#321" id="321">321</a>
<a href="#322" id="322">322</a></pre></div><pre class="rust"><code><span class="doccomment">//! Async rust task spawning and utilities that work natively (using tokio) and in browsers
//! (using wasm-bindgen-futures).
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">mod </span>tokio;
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">mod </span>wasm;
</span><span class="kw">pub use </span>tokio::spawn;
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub use </span>tokio::<span class="kw-2">*</span>;
</span><span class="kw">pub use </span>tokio::task::{JoinError, JoinHandle, JoinSet};
<span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub use </span>tokio_util::task::AbortOnDropHandle;
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub use </span>wasm::<span class="kw-2">*</span>;
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">mod </span>wasm {
<span class="kw">use </span>std::{
cell::RefCell,
fmt::Debug,
future::{Future, IntoFuture},
pin::Pin,
rc::Rc,
task::{Context, Poll, Waker},
};
<span class="kw">use </span>futures_lite::stream::StreamExt;
<span class="kw">use </span>wasm_bindgen::prelude::wasm_bindgen;
<span class="doccomment">/// Wasm shim for tokio's `JoinSet`.
///
/// Uses a `futures_buffered::FuturesUnordered` queue of
/// `JoinHandle`s inside.
</span><span class="kw">pub struct </span>JoinSet&lt;T&gt; {
handles: futures_buffered::FuturesUnordered&lt;JoinHandle&lt;T&gt;&gt;,
<span class="comment">// We need to keep a second list of JoinHandles so we can access them for cancellation
</span>to_cancel: Vec&lt;JoinHandle&lt;T&gt;&gt;,
}
<span class="kw">impl</span>&lt;T&gt; Default <span class="kw">for </span>JoinSet&lt;T&gt; {
<span class="kw">fn </span>default() -&gt; <span class="self">Self </span>{
<span class="self">Self</span>::new()
}
}
<span class="kw">impl</span>&lt;T&gt; JoinSet&lt;T&gt; {
<span class="doccomment">/// Creates a new, empty `JoinSet`
</span><span class="kw">pub fn </span>new() -&gt; <span class="self">Self </span>{
<span class="self">Self </span>{
handles: futures_buffered::FuturesUnordered::new(),
to_cancel: Vec::new(),
}
}
<span class="doccomment">/// Spawns a task into this `JoinSet`.
///
/// (Doesn't return an `AbortHandle` unlike the original `tokio::task::JoinSet` yet.)
</span><span class="kw">pub fn </span>spawn(<span class="kw-2">&amp;mut </span><span class="self">self</span>, fut: <span class="kw">impl </span>IntoFuture&lt;Output = T&gt; + <span class="lifetime">'static</span>)
<span class="kw">where
</span>T: <span class="lifetime">'static</span>,
{
<span class="kw">let </span>handle = JoinHandle::new();
<span class="kw">let </span>handle_for_spawn = JoinHandle {
task: handle.task.clone(),
};
<span class="kw">let </span>handle_for_cancel = JoinHandle {
task: handle.task.clone(),
};
wasm_bindgen_futures::spawn_local(SpawnFuture {
handle: handle_for_spawn,
fut: fut.into_future(),
});
<span class="self">self</span>.handles.push(handle);
<span class="self">self</span>.to_cancel.push(handle_for_cancel);
}
<span class="doccomment">/// Aborts all tasks inside this `JoinSet`
</span><span class="kw">pub fn </span>abort_all(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="self">self</span>.to_cancel.iter().for_each(JoinHandle::abort);
}
<span class="doccomment">/// Awaits the next `JoinSet`'s completion.
///
/// If you `.spawn` a new task onto this `JoinSet` while the future
/// returned from this is currently pending, then this future will
/// continue to be pending, even if the newly spawned future is already
/// finished.
///
/// TODO(matheus23): Fix this limitation.
///
/// Current work around is to recreate the `join_next` future when
/// you newly spawned a task onto it. This seems to be the usual way
/// the `JoinSet` is used *most of the time* in the iroh codebase anyways.
</span><span class="kw">pub async fn </span>join_next(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="prelude-ty">Result</span>&lt;T, JoinError&gt;&gt; {
futures_lite::future::poll_fn(|cx| {
<span class="kw">let </span>ret = <span class="self">self</span>.handles.poll_next(cx);
<span class="kw">match </span><span class="kw-2">&amp;</span>ret {
Poll::Pending =&gt; <span class="macro">tracing::info!</span>(<span class="string">"polled JoinSet::join_next (pending)"</span>),
Poll::Ready(<span class="prelude-val">None</span>) =&gt; <span class="macro">tracing::info!</span>(<span class="string">"polled JoinSet::join_next: None"</span>),
Poll::Ready(<span class="prelude-val">Some</span>(<span class="prelude-val">Ok</span>(<span class="kw">_</span>))) =&gt; {
<span class="macro">tracing::info!</span>(<span class="string">"polled JoinSet::join_next: Some(Ok(_))"</span>)
}
Poll::Ready(<span class="prelude-val">Some</span>(<span class="prelude-val">Err</span>(e))) =&gt; {
<span class="macro">tracing::info!</span>(<span class="string">"polled JoinSet::join_next: Some(Err({e:?}))"</span>)
}
}
<span class="comment">// clean up handles that are either cancelled or have finished
</span><span class="self">self</span>.to_cancel.retain(JoinHandle::is_running);
ret
})
.<span class="kw">await
</span>}
<span class="doccomment">/// Returns whether there's any tasks that are either still running or
/// have pending results in this `JoinSet`.
</span><span class="kw">pub fn </span>is_empty(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.handles.is_empty()
}
<span class="doccomment">/// Returns the amount of tasks that are either still running or have
/// pending results in this `JoinSet`.
</span><span class="kw">pub fn </span>len(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; usize {
<span class="self">self</span>.handles.len()
}
}
<span class="kw">impl</span>&lt;T&gt; Drop <span class="kw">for </span>JoinSet&lt;T&gt; {
<span class="kw">fn </span>drop(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="self">self</span>.abort_all()
}
}
<span class="doccomment">/// A handle to a spawned task.
</span><span class="kw">pub struct </span>JoinHandle&lt;T&gt; {
task: Rc&lt;RefCell&lt;Task&lt;T&gt;&gt;&gt;,
}
<span class="kw">struct </span>Task&lt;T&gt; {
cancelled: bool,
completed: bool,
waker_handler: <span class="prelude-ty">Option</span>&lt;Waker&gt;,
waker_spawn_fn: <span class="prelude-ty">Option</span>&lt;Waker&gt;,
result: <span class="prelude-ty">Option</span>&lt;T&gt;,
}
<span class="kw">impl</span>&lt;T&gt; Task&lt;T&gt; {
<span class="kw">fn </span>cancel(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">if </span>!<span class="self">self</span>.cancelled {
<span class="self">self</span>.cancelled = <span class="bool-val">true</span>;
<span class="self">self</span>.wake();
}
}
<span class="kw">fn </span>complete(<span class="kw-2">&amp;mut </span><span class="self">self</span>, value: T) {
<span class="self">self</span>.result = <span class="prelude-val">Some</span>(value);
<span class="self">self</span>.completed = <span class="bool-val">true</span>;
<span class="self">self</span>.wake();
}
<span class="kw">fn </span>wake(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">if let </span><span class="prelude-val">Some</span>(waker) = <span class="self">self</span>.waker_handler.take() {
waker.wake();
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(waker) = <span class="self">self</span>.waker_spawn_fn.take() {
waker.wake();
}
}
<span class="kw">fn </span>register_handler(<span class="kw-2">&amp;mut </span><span class="self">self</span>, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) {
<span class="kw">match </span><span class="self">self</span>.waker_handler {
<span class="comment">// clone_from can be marginally faster in some cases
</span><span class="prelude-val">Some</span>(<span class="kw-2">ref mut </span>waker) =&gt; waker.clone_from(cx.waker()),
<span class="prelude-val">None </span>=&gt; <span class="self">self</span>.waker_handler = <span class="prelude-val">Some</span>(cx.waker().clone()),
}
}
<span class="kw">fn </span>register_spawn_fn(<span class="kw-2">&amp;mut </span><span class="self">self</span>, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) {
<span class="kw">match </span><span class="self">self</span>.waker_spawn_fn {
<span class="comment">// clone_from can be marginally faster in some cases
</span><span class="prelude-val">Some</span>(<span class="kw-2">ref mut </span>waker) =&gt; waker.clone_from(cx.waker()),
<span class="prelude-val">None </span>=&gt; <span class="self">self</span>.waker_spawn_fn = <span class="prelude-val">Some</span>(cx.waker().clone()),
}
}
}
<span class="kw">impl</span>&lt;T&gt; JoinHandle&lt;T&gt; {
<span class="kw">fn </span>new() -&gt; <span class="self">Self </span>{
<span class="self">Self </span>{
task: Rc::new(RefCell::new(Task {
cancelled: <span class="bool-val">false</span>,
completed: <span class="bool-val">false</span>,
waker_handler: <span class="prelude-val">None</span>,
waker_spawn_fn: <span class="prelude-val">None</span>,
result: <span class="prelude-val">None</span>,
})),
}
}
<span class="doccomment">/// Aborts this task.
</span><span class="kw">pub fn </span>abort(<span class="kw-2">&amp;</span><span class="self">self</span>) {
<span class="self">self</span>.task.borrow_mut().cancel();
}
<span class="kw">fn </span>is_running(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="kw">let </span>task = <span class="self">self</span>.task.borrow();
!task.cancelled &amp;&amp; !task.completed
}
}
<span class="doccomment">/// An error that can occur when waiting for the completion of a task.
</span><span class="attr">#[derive(derive_more::Display, Debug, Clone, Copy)]
</span><span class="kw">pub enum </span>JoinError {
<span class="doccomment">/// The error that's returned when the task that's being waited on
/// has been cancelled.
</span><span class="attr">#[display(<span class="string">"task was cancelled"</span>)]
</span>Cancelled,
}
<span class="kw">impl</span>&lt;T&gt; Future <span class="kw">for </span>JoinHandle&lt;T&gt; {
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;T, JoinError&gt;;
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="macro">tracing::info!</span>(<span class="string">"JoinHandle::poll"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>task = <span class="self">self</span>.task.borrow_mut();
<span class="kw">if </span>task.cancelled {
<span class="macro">tracing::info!</span>(<span class="string">"JoinHandle::poll: cancelled"</span>);
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Err</span>(JoinError::Cancelled));
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(result) = task.result.take() {
<span class="macro">tracing::info!</span>(<span class="string">"JoinHandle::poll: Ready(Ok(_))"</span>);
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Ok</span>(result));
}
<span class="macro">tracing::info!</span>(<span class="string">"JoinHandle::poll: Pending"</span>);
task.register_handler(cx);
Poll::Pending
}
}
<span class="attr">#[pin_project::pin_project]
</span><span class="kw">struct </span>SpawnFuture&lt;Fut: Future&lt;Output = T&gt;, T&gt; {
handle: JoinHandle&lt;T&gt;,
<span class="attr">#[pin]
</span>fut: Fut,
}
<span class="kw">impl</span>&lt;Fut: Future&lt;Output = T&gt;, T&gt; Future <span class="kw">for </span>SpawnFuture&lt;Fut, T&gt; {
<span class="kw">type </span>Output = ();
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">let </span>this = <span class="self">self</span>.project();
<span class="kw">let </span><span class="kw-2">mut </span>task = this.handle.task.borrow_mut();
<span class="kw">if </span>task.cancelled {
<span class="kw">return </span>Poll::Ready(());
}
<span class="kw">match </span>this.fut.poll(cx) {
Poll::Ready(value) =&gt; {
<span class="macro">tracing::info!</span>(<span class="string">"waking up"</span>);
task.complete(value);
Poll::Ready(())
}
Poll::Pending =&gt; {
task.register_spawn_fn(cx);
Poll::Pending
}
}
}
}
<span class="doccomment">/// Similar to a `JoinHandle`, except it automatically aborts
/// the task when it's dropped.
</span><span class="attr">#[pin_project::pin_project(PinnedDrop)]
#[derive(derive_more::Debug)]
#[debug(<span class="string">"AbortOnDropHandle"</span>)]
</span><span class="kw">pub struct </span>AbortOnDropHandle&lt;T&gt;(<span class="attr">#[pin] </span>JoinHandle&lt;T&gt;);
<span class="attr">#[pin_project::pinned_drop]
</span><span class="kw">impl</span>&lt;T&gt; PinnedDrop <span class="kw">for </span>AbortOnDropHandle&lt;T&gt; {
<span class="kw">fn </span>drop(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;) {
<span class="self">self</span>.<span class="number">0</span>.abort();
}
}
<span class="kw">impl</span>&lt;T&gt; Future <span class="kw">for </span>AbortOnDropHandle&lt;T&gt; {
<span class="kw">type </span>Output = &lt;JoinHandle&lt;T&gt; <span class="kw">as </span>Future&gt;::Output;
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="self">self</span>.project().<span class="number">0</span>.poll(cx)
}
}
<span class="kw">impl</span>&lt;T&gt; AbortOnDropHandle&lt;T&gt; {
<span class="doccomment">/// Converts a `JoinHandle` into one that aborts on drop.
</span><span class="kw">pub fn </span>new(task: JoinHandle&lt;T&gt;) -&gt; <span class="self">Self </span>{
<span class="self">Self</span>(task)
}
}
<span class="doccomment">/// Spawns a future as a task in the browser runtime.
///
/// This is powered by `wasm_bidngen_futures`.
</span><span class="kw">pub fn </span>spawn&lt;T: <span class="lifetime">'static</span>&gt;(fut: <span class="kw">impl </span>IntoFuture&lt;Output = T&gt; + <span class="lifetime">'static</span>) -&gt; JoinHandle&lt;T&gt; {
<span class="kw">let </span>handle = JoinHandle::new();
wasm_bindgen_futures::spawn_local(SpawnFuture {
handle: JoinHandle {
task: handle.task.clone(),
},
fut: fut.into_future(),
});
handle
}
}
<span class="attr">#[cfg(test)]
</span><span class="kw">mod </span>test {
<span class="comment">// TODO(matheus23): Test wasm shims using wasm-bindgen-test
</span>}
</code></pre></div></section></main></body></html>
@@ -1,7 +0,0 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `iroh-net-report/src/task/tokio.rs`."><title>tokio.rs - source</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../../" data-static-root-path="../../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../../static.files/storage-59e33391.js"></script><script defer src="../../../static.files/src-script-56102188.js"></script><script defer src="../../../src-files.js"></script><script defer src="../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../static.files/favicon-044be391.svg"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="src-sidebar-title"><h2>Files</h2></div></nav><div class="sidebar-resizer"></div><main><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1><div class="sub-heading">iroh_net_report/task/</div>tokio.rs</h1><rustdoc-toolbar></rustdoc-toolbar></div><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers">
<a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a></pre></div><pre class="rust"><code><span class="kw">pub use </span>tokio::spawn;
<span class="kw">pub use </span>tokio::task::{JoinError, JoinHandle, JoinSet};
<span class="kw">pub use </span>tokio_util::task::AbortOnDropHandle;
</code></pre></div></section></main></body></html>
+5 -1
View File
@@ -53,7 +53,9 @@
<a href="#52" id="52">52</a>
<a href="#53" id="53">53</a>
<a href="#54" id="54">54</a>
<a href="#55" id="55">55</a></pre></div><pre class="rust"><code><span class="doccomment">//! Iroh's relay is a feature within [iroh](https://github.com/n0-computer/iroh), a peer-to-peer
<a href="#55" id="55">55</a>
<a href="#56" id="56">56</a>
<a href="#57" id="57">57</a></pre></div><pre class="rust"><code><span class="doccomment">//! Iroh's relay is a feature within [iroh](https://github.com/n0-computer/iroh), a peer-to-peer
//! networking system designed to facilitate direct, encrypted connections between devices. Iroh
//! aims to simplify decentralized communication by automatically handling connections through
//! "relays" when direct connections aren't immediately possible. The relay server helps establish
@@ -93,6 +95,8 @@
<span class="attr">#[cfg(feature = <span class="string">"server"</span>)]
</span><span class="kw">pub mod </span>server;
<span class="kw">pub mod </span>time;
<span class="kw">mod </span>ping_tracker;
<span class="kw">mod </span>key_cache;
@@ -76,9 +76,9 @@
<a href="#75" id="75">75</a>
<a href="#76" id="76">76</a>
<a href="#77" id="77">77</a>
<a href="#78" id="78">78</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::time::{Duration, Instant};
<a href="#78" id="78">78</a></pre></div><pre class="rust"><code><span class="kw">use </span>tracing::debug;
<span class="kw">use </span>tracing::debug;
<span class="kw">use </span><span class="kw">crate</span>::time::{<span class="self">self</span>, Duration, Instant};
<span class="doccomment">/// Maximum time for a ping response in the relay protocol.
</span><span class="kw">pub const </span>PING_TIMEOUT: Duration = Duration::from_secs(<span class="number">5</span>);
@@ -146,7 +146,7 @@
</span><span class="kw">pub async fn </span>timeout(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="kw">match </span><span class="self">self</span>.inner {
<span class="prelude-val">Some</span>(PingInner { deadline, data }) =&gt; {
tokio::time::sleep_until(deadline.into()).<span class="kw">await</span>;
time::sleep_until(deadline.into()).<span class="kw">await</span>;
<span class="macro">debug!</span>(<span class="question-mark">?</span>data, <span class="string">"Ping timeout."</span>);
<span class="self">self</span>.inner = <span class="prelude-val">None</span>;
}
@@ -861,7 +861,12 @@
<a href="#860" id="860">860</a>
<a href="#861" id="861">861</a>
<a href="#862" id="862">862</a>
<a href="#863" id="863">863</a></pre></div><pre class="rust"><code><span class="doccomment">//! This module implements the relaying protocol used by the `server` and `client`.
<a href="#863" id="863">863</a>
<a href="#864" id="864">864</a>
<a href="#865" id="865">865</a>
<a href="#866" id="866">866</a>
<a href="#867" id="867">867</a>
<a href="#868" id="868">868</a></pre></div><pre class="rust"><code><span class="doccomment">//! This module implements the relaying protocol used by the `server` and `client`.
//!
//! Protocol flow:
//!
@@ -1364,6 +1369,11 @@
<span class="comment">// No need for framing when using websockets, thus this is cfg-ed out for browsers:
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="comment">// For some reason rustc doesn't realize that this import is needed when
// - the server feature is turned *off*
// - we're *outside* wasm
// Because we need the `Decoder` and `Encoder` impls.
</span><span class="attr">#[allow(unused)]
</span><span class="kw">use </span>framing::<span class="kw-2">*</span>;
<span class="attr">#[cfg(not(wasm_browser))]
+3 -1
View File
@@ -1237,7 +1237,8 @@
<a href="#1236" id="1236">1236</a>
<a href="#1237" id="1237">1237</a>
<a href="#1238" id="1238">1238</a>
<a href="#1239" id="1239">1239</a></pre></div><pre class="rust"><code><span class="doccomment">//! A fully-fledged iroh-relay server over HTTP or HTTPS.
<a href="#1239" id="1239">1239</a>
<a href="#1240" id="1240">1240</a></pre></div><pre class="rust"><code><span class="doccomment">//! A fully-fledged iroh-relay server over HTTP or HTTPS.
//!
//! This module provides an API to run a full fledged iroh-relay server. It is primarily
//! used by the `iroh-relay` binary in this crate. It can be used to run a relay server in
@@ -1916,6 +1917,7 @@
) -&gt; HyperResult&lt;Response&lt;BytesBody&gt;&gt; {
response
.status(StatusCode::OK)
.header(<span class="string">"Access-Control-Allow-Origin"</span>, <span class="string">"*"</span>)
.body(body_empty())
.map_err(|err| Box::new(err) <span class="kw">as </span>HyperError)
}
@@ -1155,38 +1155,7 @@
<a href="#1154" id="1154">1154</a>
<a href="#1155" id="1155">1155</a>
<a href="#1156" id="1156">1156</a>
<a href="#1157" id="1157">1157</a>
<a href="#1158" id="1158">1158</a>
<a href="#1159" id="1159">1159</a>
<a href="#1160" id="1160">1160</a>
<a href="#1161" id="1161">1161</a>
<a href="#1162" id="1162">1162</a>
<a href="#1163" id="1163">1163</a>
<a href="#1164" id="1164">1164</a>
<a href="#1165" id="1165">1165</a>
<a href="#1166" id="1166">1166</a>
<a href="#1167" id="1167">1167</a>
<a href="#1168" id="1168">1168</a>
<a href="#1169" id="1169">1169</a>
<a href="#1170" id="1170">1170</a>
<a href="#1171" id="1171">1171</a>
<a href="#1172" id="1172">1172</a>
<a href="#1173" id="1173">1173</a>
<a href="#1174" id="1174">1174</a>
<a href="#1175" id="1175">1175</a>
<a href="#1176" id="1176">1176</a>
<a href="#1177" id="1177">1177</a>
<a href="#1178" id="1178">1178</a>
<a href="#1179" id="1179">1179</a>
<a href="#1180" id="1180">1180</a>
<a href="#1181" id="1181">1181</a>
<a href="#1182" id="1182">1182</a>
<a href="#1183" id="1183">1183</a>
<a href="#1184" id="1184">1184</a>
<a href="#1185" id="1185">1185</a>
<a href="#1186" id="1186">1186</a>
<a href="#1187" id="1187">1187</a>
<a href="#1188" id="1188">1188</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
<a href="#1157" id="1157">1157</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
collections::HashMap, future::Future, net::SocketAddr, pin::Pin, sync::Arc, time::Duration,
};
@@ -1195,13 +1164,7 @@
<span class="kw">use </span>derive_more::Debug;
<span class="kw">use </span>futures_lite::FutureExt;
<span class="kw">use </span>futures_util::SinkExt;
<span class="kw">use </span>http::{
header::{
ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN,
ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, CONNECTION, ORIGIN,
},
response::Builder <span class="kw">as </span>ResponseBuilder,
};
<span class="kw">use </span>http::{header::CONNECTION, response::Builder <span class="kw">as </span>ResponseBuilder};
<span class="kw">use </span>hyper::{
body::Incoming,
header::{HeaderValue, UPGRADE},
@@ -1526,9 +1489,6 @@
<span class="kw">for </span>(key, value) <span class="kw">in </span><span class="self">self</span>.<span class="number">0</span>.headers.iter() {
builder = builder.header(key, value);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(origin) = req.headers().get(ORIGIN) {
builder = builder.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
<span class="kw">async move </span>{
{
@@ -1630,25 +1590,6 @@
<span class="kw">type </span>Future = Pin&lt;Box&lt;<span class="kw">dyn </span>Future&lt;Output = <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Response, <span class="self">Self</span>::Error&gt;&gt; + Send&gt;&gt;;
<span class="kw">fn </span>call(<span class="kw-2">&amp;</span><span class="self">self</span>, req: Request&lt;Incoming&gt;) -&gt; <span class="self">Self</span>::Future {
<span class="kw">let </span>origin = req.headers().get(ORIGIN).cloned();
<span class="kw">if </span>req.method() == Method::OPTIONS {
<span class="kw">return </span>Box::pin(<span class="kw">async move </span>{
<span class="kw">let </span><span class="kw-2">mut </span>builder = Response::builder();
<span class="kw">if let </span><span class="prelude-val">Some</span>(method) = req.headers().get(ACCESS_CONTROL_REQUEST_METHOD) {
builder = builder.header(ACCESS_CONTROL_ALLOW_METHODS, method);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(headers) = req.headers().get(ACCESS_CONTROL_REQUEST_HEADERS) {
builder = builder.header(ACCESS_CONTROL_ALLOW_HEADERS, headers);
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(origin) = origin {
builder = builder.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
<span class="prelude-val">Ok</span>(builder.status(StatusCode::OK).body(body_empty())<span class="question-mark">?</span>)
});
}
<span class="comment">// Create a client if the request hits the relay endpoint.
</span><span class="kw">if </span><span class="macro">matches!</span>(
(req.method(), req.uri().path()),
@@ -1662,24 +1603,21 @@
// Check all other possible endpoints.
</span><span class="kw">let </span>uri = req.uri().clone();
<span class="kw">if let </span><span class="prelude-val">Some</span>(res) = <span class="self">self</span>.<span class="number">0</span>.handlers.get(<span class="kw-2">&amp;</span>(req.method().clone(), uri.path())) {
<span class="kw">let </span>f = res(req, <span class="self">self</span>.<span class="number">0</span>.default_response(origin));
<span class="kw">let </span>f = res(req, <span class="self">self</span>.<span class="number">0</span>.default_response());
<span class="kw">return </span>Box::pin(<span class="kw">async move </span>{ f });
}
<span class="comment">// Otherwise return 404
</span><span class="kw">let </span>res = <span class="self">self</span>.<span class="number">0</span>.not_found_fn(req, <span class="self">self</span>.<span class="number">0</span>.default_response(origin));
</span><span class="kw">let </span>res = <span class="self">self</span>.<span class="number">0</span>.not_found_fn(req, <span class="self">self</span>.<span class="number">0</span>.default_response());
Box::pin(<span class="kw">async move </span>{ res })
}
}
<span class="kw">impl </span>Inner {
<span class="kw">fn </span>default_response(<span class="kw-2">&amp;</span><span class="self">self</span>, origin: <span class="prelude-ty">Option</span>&lt;HeaderValue&gt;) -&gt; ResponseBuilder {
<span class="kw">fn </span>default_response(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; ResponseBuilder {
<span class="kw">let </span><span class="kw-2">mut </span>response = Response::builder();
<span class="kw">for </span>(key, value) <span class="kw">in </span><span class="self">self</span>.headers.iter() {
response = response.header(key.clone(), value.clone());
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(origin) = origin {
response = response.header(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
}
response
}
@@ -1,4 +1,4 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `iroh-net-report/src/time.rs`."><title>time.rs - source</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_net_report" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../../static.files/src-script-56102188.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="src-sidebar-title"><h2>Files</h2></div></nav><div class="sidebar-resizer"></div><main><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1><div class="sub-heading">iroh_net_report/</div>time.rs</h1><rustdoc-toolbar></rustdoc-toolbar></div><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers">
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Source of the Rust file `iroh-relay/src/time.rs`."><title>time.rs - source</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_relay" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../../static.files/src-script-56102188.js"></script><script defer src="../../src-files.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc src"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="src-sidebar-title"><h2>Files</h2></div></nav><div class="sidebar-resizer"></div><main><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1><div class="sub-heading">iroh_relay/</div>time.rs</h1><rustdoc-toolbar></rustdoc-toolbar></div><div class="example-wrap"><div data-nosnippet><pre class="src-line-numbers">
<a href="#1" id="1">1</a>
<a href="#2" id="2">2</a>
<a href="#3" id="3">3</a>
@@ -244,13 +244,54 @@
<a href="#243" id="243">243</a>
<a href="#244" id="244">244</a>
<a href="#245" id="245">245</a>
<a href="#246" id="246">246</a></pre></div><pre class="rust"><code><span class="doccomment">//! Sleep and timeout utilities that work natively (via tokio) and in the browser.
<a href="#246" id="246">246</a>
<a href="#247" id="247">247</a>
<a href="#248" id="248">248</a>
<a href="#249" id="249">249</a>
<a href="#250" id="250">250</a>
<a href="#251" id="251">251</a>
<a href="#252" id="252">252</a>
<a href="#253" id="253">253</a>
<a href="#254" id="254">254</a>
<a href="#255" id="255">255</a>
<a href="#256" id="256">256</a>
<a href="#257" id="257">257</a>
<a href="#258" id="258">258</a>
<a href="#259" id="259">259</a>
<a href="#260" id="260">260</a>
<a href="#261" id="261">261</a>
<a href="#262" id="262">262</a>
<a href="#263" id="263">263</a>
<a href="#264" id="264">264</a>
<a href="#265" id="265">265</a>
<a href="#266" id="266">266</a>
<a href="#267" id="267">267</a>
<a href="#268" id="268">268</a>
<a href="#269" id="269">269</a>
<a href="#270" id="270">270</a>
<a href="#271" id="271">271</a>
<a href="#272" id="272">272</a>
<a href="#273" id="273">273</a>
<a href="#274" id="274">274</a>
<a href="#275" id="275">275</a>
<a href="#276" id="276">276</a>
<a href="#277" id="277">277</a>
<a href="#278" id="278">278</a>
<a href="#279" id="279">279</a>
<a href="#280" id="280">280</a>
<a href="#281" id="281">281</a>
<a href="#282" id="282">282</a>
<a href="#283" id="283">283</a>
<a href="#284" id="284">284</a>
<a href="#285" id="285">285</a></pre></div><pre class="rust"><code><span class="doccomment">//! Sleep and timeout utilities that work natively (via tokio) and in the browser.
</span><span class="attr">#[cfg(not(wasm_browser))]
</span><span class="kw">pub use </span>tokio::time::<span class="kw-2">*</span>;
</span><span class="kw">pub use </span>tokio::time::{
error::Elapsed, sleep, sleep_until, timeout, Duration, Instant, Sleep, Timeout,
};
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">pub use </span>wasm::{sleep, timeout, Duration, Elapsed, Instant, Sleep, Timeout};
</span><span class="kw">pub use </span>wasm::{error::Elapsed, sleep, sleep_until, timeout, Duration, Instant, Sleep, Timeout};
<span class="attr">#[cfg(wasm_browser)]
</span><span class="kw">mod </span>wasm {
@@ -269,16 +310,29 @@
<span class="kw">pub use </span>web_time::{Duration, Instant};
<span class="attr">#[derive(Debug)]
<span class="doccomment">/// Future that will wake up once its deadline is reached.
</span><span class="attr">#[derive(Debug)]
</span><span class="kw">pub struct </span>Sleep {
deadline: Instant,
triggered: Flag,
timeout_id: SendWrapper&lt;JsValue&gt;,
}
<span class="kw">pub fn </span>sleep(duration: Duration) -&gt; Sleep {
<span class="doccomment">/// Sleeps for given duration
</span><span class="kw">pub fn </span>sleep(duration: Duration) -&gt; Sleep {
<span class="kw">let </span>now = Instant::now();
<span class="kw">let </span>deadline = now + duration;
sleep_impl(duration, deadline)
}
<span class="doccomment">/// Sleeps until given deadline
</span><span class="kw">pub fn </span>sleep_until(deadline: Instant) -&gt; Sleep {
<span class="kw">let </span>now = Instant::now();
<span class="kw">let </span>duration = deadline.duration_since(now);
sleep_impl(duration, deadline)
}
<span class="kw">fn </span>sleep_impl(duration: Duration, deadline: Instant) -&gt; Sleep {
<span class="kw">let </span>triggered = Flag::new();
<span class="kw">let </span>closure = Closure::once({
@@ -319,15 +373,22 @@
}
<span class="kw">impl </span>Sleep {
<span class="kw">pub fn </span>deadline(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Instant {
<span class="doccomment">/// Returns the instant at which the sleep is scheduled to wake up
</span><span class="kw">pub fn </span>deadline(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; Instant {
<span class="self">self</span>.deadline
}
<span class="kw">pub fn </span>is_elapsed(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="doccomment">/// Returns whether the sleep has reached its deadline
/// (and the scheduler has handled the sleep's timer).
</span><span class="kw">pub fn </span>is_elapsed(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; bool {
<span class="self">self</span>.triggered.has_triggered()
}
<span class="kw">pub fn </span>reset(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, deadline: Instant) {
<span class="doccomment">/// Resets this sleep's deadline to given instant.
///
/// Also works with sleeps that have already reached their deadline
/// in the past.
</span><span class="kw">pub fn </span>reset(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, deadline: Instant) {
<span class="kw">let </span>duration = deadline.duration_since(Instant::now());
<span class="kw">let </span>triggered = Flag::new();
@@ -358,7 +419,9 @@
}
}
<span class="attr">#[derive(Debug)]
<span class="doccomment">/// Future that either resolves to [`error::Elapsed`] if the timeout
/// is hit first. Otherwise, it resolves to `Ok` of the wrapped future.
</span><span class="attr">#[derive(Debug)]
#[pin_project::pin_project]
</span><span class="kw">pub struct </span>Timeout&lt;T&gt; {
<span class="attr">#[pin]
@@ -367,9 +430,15 @@
</span>sleep: Sleep,
}
<span class="kw">pub struct </span>Elapsed;
<span class="doccomment">/// Error structs for time utilities (wasm mirror for `tokio::time::error`).
</span><span class="kw">pub mod </span>error {
<span class="doccomment">/// Error when a timeout is elapsed.
</span><span class="attr">#[derive(Debug)]
</span><span class="kw">pub struct </span>Elapsed;
}
<span class="kw">pub fn </span>timeout&lt;F&gt;(duration: Duration, future: F) -&gt; Timeout&lt;F::IntoFuture&gt;
<span class="doccomment">/// Timeout of a function in wasm.
</span><span class="kw">pub fn </span>timeout&lt;F&gt;(duration: Duration, future: F) -&gt; Timeout&lt;F::IntoFuture&gt;
<span class="kw">where
</span>F: IntoFuture,
{
@@ -380,17 +449,17 @@
}
<span class="kw">impl</span>&lt;T: Future&gt; Future <span class="kw">for </span>Timeout&lt;T&gt; {
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;T::Output, Elapsed&gt;;
<span class="kw">type </span>Output = <span class="prelude-ty">Result</span>&lt;T::Output, error::Elapsed&gt;;
<span class="kw">fn </span>poll(<span class="kw-2">mut </span><span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>this = <span class="self">self</span>.project();
<span class="kw">fn </span>poll(<span class="self">self</span>: Pin&lt;<span class="kw-2">&amp;mut </span><span class="self">Self</span>&gt;, cx: <span class="kw-2">&amp;mut </span>Context&lt;<span class="lifetime">'_</span>&gt;) -&gt; Poll&lt;<span class="self">Self</span>::Output&gt; {
<span class="kw">let </span>this = <span class="self">self</span>.project();
<span class="kw">if let </span>Poll::Ready(result) = this.future.poll(cx) {
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Ok</span>(result));
}
<span class="kw">if let </span>Poll::Ready(()) = this.sleep.poll(cx) {
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Err</span>(Elapsed));
<span class="kw">return </span>Poll::Ready(<span class="prelude-val">Err</span>(error::Elapsed));
}
Poll::Pending
@@ -398,15 +467,19 @@
}
<span class="kw">impl</span>&lt;T&gt; Timeout&lt;T&gt; {
<span class="kw">pub fn </span>get_ref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>T {
<span class="doccomment">/// Returns a reference of the wrapped future.
</span><span class="kw">pub fn </span>get_ref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>T {
<span class="kw-2">&amp;</span><span class="self">self</span>.future
}
<span class="kw">pub fn </span>get_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>T {
<span class="doccomment">/// Returns a mutable reference to the wrapped future.
</span><span class="kw">pub fn </span>get_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>T {
<span class="kw-2">&amp;mut </span><span class="self">self</span>.future
}
<span class="kw">pub fn </span>into_inner(<span class="self">self</span>) -&gt; T {
<span class="doccomment">/// Returns the wrapped future and throws away and cancels the
/// associated timeout.
</span><span class="kw">pub fn </span>into_inner(<span class="self">self</span>) -&gt; T {
<span class="self">self</span>.future
}
}
@@ -490,4 +563,9 @@
global_scope.clear_timeout_with_handle(timeout_id)
}
}
<span class="attr">#[cfg(test)]
</span><span class="kw">mod </span>tests {
<span class="comment">// TODO(matheus23): Write some tests for `sleep`, `sleep_until`, `timeout` and `Sleep::reset`
</span>}
</code></pre></div></section></main></body></html>