Files
noq/pr/430/docs/iroh_quinn/trait.AsyncUdpSocket.html
T
2026-02-16 18:31:18 +00:00

38 lines
12 KiB
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="Abstract implementation of a UDP socket for runtime independence"><title>AsyncUdpSocket in iroh_quinn - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_quinn" data-themes="" data-resource-suffix="" data-rustdoc-version="1.92.0-nightly (b6f0945e4 2025-10-08)" data-channel="nightly" data-search-js="search-8d3311b9.js" data-stringdex-js="stringdex-828709d0.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-ce535bd0.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">AsyncUdpSocket</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_quinn/index.html">iroh_<wbr>quinn</a><span class="version">0.16.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Async<wbr>UdpSocket</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.create_sender" title="create_sender">create_sender</a></li><li><a href="#tymethod.local_addr" title="local_addr">local_addr</a></li><li><a href="#tymethod.poll_recv" title="poll_recv">poll_recv</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.max_receive_segments" title="max_receive_segments">max_receive_segments</a></li><li><a href="#method.may_fragment" title="may_fragment">may_fragment</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate iroh_<wbr>quinn</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">iroh_quinn</a></div><h1>Trait <span class="trait">Async<wbr>UdpSocket</span>&nbsp;<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_quinn/runtime/mod.rs.html#44-80">Source</a> </span></div><pre class="rust item-decl"><code>pub trait AsyncUdpSocket:
<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>
+ <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>
+ <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>
+ 'static {
// Required methods
fn <a href="#tymethod.create_sender" class="fn">create_sender</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="trait.UdpSender.html" title="trait iroh_quinn::UdpSender">UdpSender</a>&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.poll_recv" class="fn">poll_recv</a>(
&amp;mut self,
cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;,
bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;],
meta: &amp;mut [<a class="struct" href="../iroh_quinn_udp/struct.RecvMeta.html" title="struct iroh_quinn_udp::RecvMeta">RecvMeta</a>],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.local_addr" class="fn">local_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::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>&gt;;
// Provided methods
fn <a href="#method.max_receive_segments" class="fn">max_receive_segments</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/num/nonzero/type.NonZeroUsize.html" title="type core::num::nonzero::NonZeroUsize">NonZeroUsize</a> { ... }
<span class="item-spacer"></span> fn <a href="#method.may_fragment" class="fn">may_fragment</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> { ... }
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Abstract implementation of a UDP socket for runtime independence</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.create_sender" class="method"><a class="src rightside" href="../src/iroh_quinn/runtime/mod.rs.html#55">Source</a><h4 class="code-header">fn <a href="#tymethod.create_sender" class="fn">create_sender</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="trait.UdpSender.html" title="trait iroh_quinn::UdpSender">UdpSender</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Create a <a href="trait.UdpSender.html" title="trait iroh_quinn::UdpSender"><code>UdpSender</code></a> that can register a single task for write-readiness notifications
and send a transmit, if ready.</p>
<p>A <code>poll_send</code> method on a single object can usually store only one <a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html" title="struct core::task::wake::Waker"><code>Waker</code></a> at a time,
i.e. allow at most one caller to wait for an event. This method allows any number of
interested tasks to construct their own <a href="trait.UdpSender.html" title="trait iroh_quinn::UdpSender"><code>UdpSender</code></a> object. They can all then wait for the
same event and be notified concurrently, because each <a href="trait.UdpSender.html" title="trait iroh_quinn::UdpSender"><code>UdpSender</code></a> can store a separate
<a href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Waker.html" title="struct core::task::wake::Waker"><code>Waker</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.poll_recv" class="method"><a class="src rightside" href="../src/iroh_quinn/runtime/mod.rs.html#58-63">Source</a><h4 class="code-header">fn <a href="#tymethod.poll_recv" class="fn">poll_recv</a>(
&amp;mut self,
cx: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/task/wake/struct.Context.html" title="struct core::task::wake::Context">Context</a>&lt;'_&gt;,
bufs: &amp;mut [<a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a>&lt;'_&gt;],
meta: &amp;mut [<a class="struct" href="../iroh_quinn_udp/struct.RecvMeta.html" title="struct iroh_quinn_udp::RecvMeta">RecvMeta</a>],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/task/poll/enum.Poll.html" title="enum core::task::poll::Poll">Poll</a>&lt;<a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Receive UDP datagrams, or register to be woken if receiving may succeed in the future</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.local_addr" class="method"><a class="src rightside" href="../src/iroh_quinn/runtime/mod.rs.html#66">Source</a><h4 class="code-header">fn <a href="#tymethod.local_addr" class="fn">local_addr</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::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>&gt;</h4></section></summary><div class="docblock"><p>Look up the local IP address and port used by this socket</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.max_receive_segments" class="method"><a class="src rightside" href="../src/iroh_quinn/runtime/mod.rs.html#69-71">Source</a><h4 class="code-header">fn <a href="#method.max_receive_segments" class="fn">max_receive_segments</a>(&amp;self) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/num/nonzero/type.NonZeroUsize.html" title="type core::num::nonzero::NonZeroUsize">NonZeroUsize</a></h4></section></summary><div class="docblock"><p>Maximum number of datagrams that might be described by a single <a href="../iroh_quinn_udp/struct.RecvMeta.html" title="struct iroh_quinn_udp::RecvMeta"><code>RecvMeta</code></a></p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.may_fragment" class="method"><a class="src rightside" href="../src/iroh_quinn/runtime/mod.rs.html#77-79">Source</a><h4 class="code-header">fn <a href="#method.may_fragment" class="fn">may_fragment</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Whether datagrams might get fragmented into multiple parts</p>
<p>Sockets should prevent this for best performance. See e.g. the <code>IPV6_DONTFRAG</code> socket
option.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/iroh_quinn/runtime/trait.AsyncUdpSocket.js" async></script></section></div></main></body></html>