This commit is contained in:
wash2 2026-04-18 20:11:25 +00:00
commit 0fa87f2b35
16382 changed files with 734838 additions and 0 deletions

View file

@ -0,0 +1,64 @@
<!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 helper macro which delegates a set of `Dispatch` implementations for proxies to some other type which provides a generic `Dispatch` implementation."><title>delegate_dispatch in cosmic::cctk::sctk::reexports::client - 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" crossorigin href="../../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-aa0817cf.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="cosmic" data-themes="" data-resource-suffix="" data-rustdoc-version="1.90.0-nightly (3048886e5 2025-07-30)" data-channel="nightly" data-search-js="search-fa3e91e5.js" data-settings-js="settings-5514c975.js" ><script src="../../../../../static.files/storage-68b7e25d.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../../../static.files/main-eebb9057.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-32bb7600.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 macro"><!--[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="../../../../../cosmic/index.html">cosmic</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">delegate_<wbr>dispatch</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#usage" title="Usage">Usage</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In cosmic::<wbr>cctk::<wbr>sctk::<wbr>reexports::<wbr>client</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../../../index.html">cosmic</a>::<wbr><a href="../../../index.html">cctk</a>::<wbr><a href="../../index.html">sctk</a>::<wbr><a href="../index.html">reexports</a>::<wbr><a href="index.html">client</a></div><h1>Macro <span class="macro">delegate_dispatch</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>macro_rules! delegate_dispatch {
($(@&lt; $( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+ &gt;)? $dispatch_from:ty : [$interface: ty: $udata: ty] =&gt; $dispatch_to: ty) =&gt; { ... };
}</code></pre><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>wayland</code> and Linux</strong> only.</div></span><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A helper macro which delegates a set of <a href="trait.Dispatch.html" title="trait cosmic::cctk::sctk::reexports::client::Dispatch"><code>Dispatch</code></a> implementations for proxies to some other type which
provides a generic <a href="trait.Dispatch.html" title="trait cosmic::cctk::sctk::reexports::client::Dispatch"><code>Dispatch</code></a> implementation.</p>
<p>This macro allows more easily delegating smaller parts of the protocol an application may wish to handle
in a modular fashion.</p>
<h2 id="usage"><a class="doc-anchor" href="#usage">§</a>Usage</h2>
<p>For example, say you want to delegate events for <a href="protocol/wl_registry/struct.WlRegistry.html" title="struct cosmic::cctk::sctk::reexports::client::protocol::wl_registry::WlRegistry"><code>WlRegistry</code></a>
to the struct <code>DelegateToMe</code> for the <a href="trait.Dispatch.html" title="trait cosmic::cctk::sctk::reexports::client::Dispatch"><code>Dispatch</code></a> documentation example.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>wayland_client::{delegate_dispatch, protocol::wl_registry};
<span class="comment">// ExampleApp is the type events will be dispatched to.
</span><span class="doccomment">/// The application state
</span><span class="kw">struct </span>ExampleApp {
<span class="doccomment">/// The delegate for handling wl_registry events.
</span>delegate: DelegateToMe,
}
<span class="comment">// Use delegate_dispatch to implement Dispatch&lt;wl_registry::WlRegistry, MyUserData&gt; for ExampleApp
</span><span class="macro">delegate_dispatch!</span>(ExampleApp: [wl_registry::WlRegistry: MyUserData] =&gt; DelegateToMe);
<span class="comment">// DelegateToMe requires that ExampleApp implements AsMut&lt;DelegateToMe&gt;, so we provide the
// trait implementation.
</span><span class="kw">impl </span>AsMut&lt;DelegateToMe&gt; <span class="kw">for </span>ExampleApp {
<span class="kw">fn </span>as_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>DelegateToMe {
<span class="kw-2">&amp;mut </span><span class="self">self</span>.delegate
}
}
<span class="comment">// To explain the macro above, you may read it as the following:
//
// For ExampleApp, delegate WlRegistry to DelegateToMe.
// Assert ExampleApp can Dispatch events for wl_registry
</span><span class="kw">fn </span>assert_is_registry_delegate&lt;T&gt;()
<span class="kw">where
</span>T: Dispatch&lt;wl_registry::WlRegistry, MyUserData&gt;,
{
}
assert_is_registry_delegate::&lt;ExampleApp&gt;();
<span class="comment">// This macro can also be applied to a generic type using the `@&lt;&gt;` syntax:
</span><span class="doccomment">/// The application state
</span><span class="kw">struct </span>GenericApp&lt;T: Copy&gt; {
<span class="doccomment">/// The delegate for handling wl_registry events.
</span>delegate: DelegateToMe,
app_data: T,
}
<span class="macro">delegate_dispatch!</span>(@&lt;T: Copy&gt; GenericApp&lt;T&gt;: [wl_registry::WlRegistry: MyUserData] =&gt; DelegateToMe);
<span class="kw">impl</span>&lt;T: Copy&gt; AsMut&lt;DelegateToMe&gt; <span class="kw">for </span>GenericApp&lt;T&gt; {
<span class="kw">fn </span>as_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span>DelegateToMe {
<span class="kw-2">&amp;mut </span><span class="self">self</span>.delegate
}
}
<span class="comment">// Assert that the above setup applies to a concrete GenericApp type
</span>assert_is_registry_delegate::&lt;GenericApp&lt;u32&gt;&gt;();</code></pre></div>
</div></details></section></div></main></body></html>