libcosmic/cosmic/cctk/sctk/reexports/client/backend/trait.ObjectData.html
2026-04-18 20:11:25 +00:00

58 lines
No EOL
22 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 trait representing your data associated to an object"><title>ObjectData in cosmic::cctk::sctk::reexports::client::backend - 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 trait"><!--[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="#">Object<wbr>Data</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.destroyed" title="destroyed">destroyed</a></li><li><a href="#tymethod.event" title="event">event</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.data_as_any" title="data_as_any">data_as_any</a></li><li><a href="#method.debug" title="debug">debug</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.downcast" title="downcast">downcast</a></li><li><a href="#method.downcast_arc" title="downcast_arc">downcast_arc</a></li><li><a href="#method.downcast_mut" title="downcast_mut">downcast_mut</a></li><li><a href="#method.downcast_rc" title="downcast_rc">downcast_rc</a></li><li><a href="#method.downcast_ref" title="downcast_ref">downcast_ref</a></li><li><a href="#method.is" title="is">is</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-dyn+ObjectData" title="Debug">Debug</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In cosmic::<wbr>cctk::<wbr>sctk::<wbr>reexports::<wbr>client::<wbr>backend</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>::<wbr><a href="index.html">backend</a></div><h1>Trait <span class="trait">ObjectData</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 trait ObjectData: DowncastSync {
// Required methods
fn <a href="#tymethod.event" class="fn">event</a>(
self: <a class="struct" href="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;Self&gt;,
backend: &amp;<a class="struct" href="struct.Backend.html" title="struct cosmic::cctk::sctk::reexports::client::backend::Backend">Backend</a>,
msg: <a class="struct" href="protocol/struct.Message.html" title="struct cosmic::cctk::sctk::reexports::client::backend::protocol::Message">Message</a>&lt;<a class="struct" href="struct.ObjectId.html" title="struct cosmic::cctk::sctk::reexports::client::backend::ObjectId">ObjectId</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>&gt;,
) -&gt; <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="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.destroyed" class="fn">destroyed</a>(&amp;self, object_id: <a class="struct" href="struct.ObjectId.html" title="struct cosmic::cctk::sctk::reexports::client::backend::ObjectId">ObjectId</a>);
// Provided methods
fn <a href="#method.debug" class="fn">debug</a>(&amp;self, f: &amp;mut <a class="struct" href="smallvec/alloc/fmt/struct.Formatter.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="smallvec/alloc/fmt/struct.Error.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Error">Error</a>&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.data_as_any" class="fn">data_as_any</a>(&amp;self) -&gt; &amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + 'static) { ... }
}</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 trait representing your data associated to an object</p>
<p>You will only be given access to it as a <code>&amp;</code> reference, so you
need to handle interior mutability by yourself.</p>
<p>The methods of this trait will be invoked internally every time a
new object is created to initialize its data.</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.event" class="method"><h4 class="code-header">fn <a href="#tymethod.event" class="fn">event</a>(
self: <a class="struct" href="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;Self&gt;,
backend: &amp;<a class="struct" href="struct.Backend.html" title="struct cosmic::cctk::sctk::reexports::client::backend::Backend">Backend</a>,
msg: <a class="struct" href="protocol/struct.Message.html" title="struct cosmic::cctk::sctk::reexports::client::backend::protocol::Message">Message</a>&lt;<a class="struct" href="struct.ObjectId.html" title="struct cosmic::cctk::sctk::reexports::client::backend::ObjectId">ObjectId</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/os/fd/owned/struct.OwnedFd.html" title="struct std::os::fd::owned::OwnedFd">OwnedFd</a>&gt;,
) -&gt; <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="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Dispatch an event for the associated object</p>
<p>If the event has a <code>NewId</code> argument, the callback must return the object data
for the newly created object</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.destroyed" class="method"><h4 class="code-header">fn <a href="#tymethod.destroyed" class="fn">destroyed</a>(&amp;self, object_id: <a class="struct" href="struct.ObjectId.html" title="struct cosmic::cctk::sctk::reexports::client::backend::ObjectId">ObjectId</a>)</h4></section></summary><div class="docblock"><p>Notification that the object has been destroyed and is no longer active</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.debug" class="method"><h4 class="code-header">fn <a href="#method.debug" class="fn">debug</a>(&amp;self, f: &amp;mut <a class="struct" href="smallvec/alloc/fmt/struct.Formatter.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="smallvec/alloc/fmt/struct.Error.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Helper for forwarding a Debug implementation of your <code>ObjectData</code> type</p>
<p>By default will just print <code>ObjectData { ... }</code></p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.data_as_any" class="method"><h4 class="code-header">fn <a href="#method.data_as_any" class="fn">data_as_any</a>(&amp;self) -&gt; &amp;(dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + 'static)</h4></section></summary><div class="docblock"><p>Helper for accessing user data</p>
<p>This function is used to back the <code>Proxy::data()</code> function in <code>wayland_client</code>. By default,
it returns <code>self</code> (via [<code>Downcast</code>][downcast_rs::DowncastSync]), but this may be overridden to allow downcasting user data
without needing to have access to the full type.</p>
</div></details></div><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-dyn+ObjectData" class="impl"><a href="#impl-dyn+ObjectData" class="anchor">§</a><h3 class="code-header">impl dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.is" class="method"><h4 class="code-header">pub fn <a href="#method.is" class="fn">is</a>&lt;__T&gt;(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a><div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>,</div></h4></section></summary><div class="docblock"><p>Returns true if the trait object wraps an object of type <code>__T</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast" class="method"><h4 class="code-header">pub fn <a href="#method.downcast" class="fn">downcast</a>&lt;__T&gt;(
self: <a class="struct" href="smallvec/alloc/boxed/struct.Box.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="smallvec/alloc/boxed/struct.Box.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::boxed::Box">Box</a>&lt;__T&gt;, <a class="struct" href="smallvec/alloc/boxed/struct.Box.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;&gt;<div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>,</div></h4></section></summary><div class="docblock"><p>Returns a boxed object from a boxed trait object if the underlying object is of type
<code>__T</code>. Returns the original boxed trait if it isnt.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_rc" class="method"><h4 class="code-header">pub fn <a href="#method.downcast_rc" class="fn">downcast_rc</a>&lt;__T&gt;(
self: <a class="struct" href="smallvec/alloc/rc/struct.Rc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::rc::Rc">Rc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="smallvec/alloc/rc/struct.Rc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::rc::Rc">Rc</a>&lt;__T&gt;, <a class="struct" href="smallvec/alloc/rc/struct.Rc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::rc::Rc">Rc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;&gt;<div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>,</div></h4></section></summary><div class="docblock"><p>Returns an <code>Rc</code>-ed object from an <code>Rc</code>-ed trait object if the underlying object is of
type <code>__T</code>. Returns the original <code>Rc</code>-ed trait if it isnt.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_ref" class="method"><h4 class="code-header">pub fn <a href="#method.downcast_ref" class="fn">downcast_ref</a>&lt;__T&gt;(&amp;self) -&gt; <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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;__T</a>&gt;<div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>,</div></h4></section></summary><div class="docblock"><p>Returns a reference to the object within the trait object if it is of type <code>__T</code>, or
<code>None</code> if it isnt.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_mut" class="method"><h4 class="code-header">pub fn <a href="#method.downcast_mut" class="fn">downcast_mut</a>&lt;__T&gt;(&amp;mut self) -&gt; <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="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut __T</a>&gt;<div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>,</div></h4></section></summary><div class="docblock"><p>Returns a mutable reference to the object within the trait object if it is of type
<code>__T</code>, or <code>None</code> if it isnt.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_arc" class="method"><h4 class="code-header">pub fn <a href="#method.downcast_arc" class="fn">downcast_arc</a>&lt;__T&gt;(
self: <a class="struct" href="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;__T&gt;, <a class="struct" href="smallvec/alloc/sync/struct.Arc.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::sync::Arc">Arc</a>&lt;dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a>&gt;&gt;<div class="where">where
__T: <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> + <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>,</div></h4></section></summary><div class="docblock"><p>Returns an <code>Arc</code>-ed object from an <code>Arc</code>-ed trait object if the underlying object is of
type <code>__T</code>. Returns the original <code>Arc</code>-ed trait if it isnt.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-dyn+ObjectData" class="impl"><a href="#impl-Debug-for-dyn+ObjectData" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="smallvec/alloc/fmt/trait.Debug.html" title="trait cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Debug">Debug</a> for dyn <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="smallvec/alloc/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="smallvec/alloc/fmt/struct.Formatter.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="smallvec/alloc/fmt/struct.Error.html" title="struct cosmic::cctk::sctk::reexports::client::backend::smallvec::alloc::fmt::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="smallvec/alloc/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-ObjectData-for-QueueProxyData%3CI,+U,+State%3E" class="impl"><a href="#impl-ObjectData-for-QueueProxyData%3CI,+U,+State%3E" class="anchor">§</a><h3 class="code-header">impl&lt;I, U, State&gt; <a class="trait" href="trait.ObjectData.html" title="trait cosmic::cctk::sctk::reexports::client::backend::ObjectData">ObjectData</a> for <a class="struct" href="../struct.QueueProxyData.html" title="struct cosmic::cctk::sctk::reexports::client::QueueProxyData">QueueProxyData</a>&lt;I, U, State&gt;<div class="where">where
I: <a class="trait" href="../trait.Proxy.html" title="trait cosmic::cctk::sctk::reexports::client::Proxy">Proxy</a> + 'static,
U: <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> + 'static,
State: <a class="trait" href="../trait.Dispatch.html" title="trait cosmic::cctk::sctk::reexports::client::Dispatch">Dispatch</a>&lt;I, U&gt; + 'static,</div></h3></section></div><script src="../../../../../../trait.impl/wayland_backend/sys/client/trait.ObjectData.js" data-ignore-extern-crates="wayland_client" async></script></section></div></main></body></html>