<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="A temporary state of an application. There’s a stack of these, with the most recent being the active one."><metaname="keywords"content="rust, rustlang, rust-lang, State"><title>State in widgetry - Rust</title><linkrel="stylesheet"type="text/css"href="../normalize.css"><linkrel="stylesheet"type="text/css"href="../rustdoc.css"id="mainThemeStyle"><linkrel="stylesheet"type="text/css"href="../light.css"id="themeStyle"><linkrel="stylesheet"type="text/css"href="../dark.css"disabled><linkrel="stylesheet"type="text/css"href="../ayu.css"disabled><scriptid="default-settings"></script><scriptsrc="../storage.js"></script><scriptsrc="../crates.js"></script><noscript><linkrel="stylesheet"href="../noscript.css"></noscript><linkrel="icon"type="image/svg+xml"href="../favicon.svg"><linkrel="alternate icon"type="image/png"href="../favicon-16x16.png"><linkrel="alternate icon"type="image/png"href="../favicon-32x32.png"><styletype="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><bodyclass="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="sidebar"><divclass="sidebar-menu"role="button">☰</div><ahref='../widgetry/index.html'><divclass='logo-container rust-logo'><imgsrc='../rust-logo.png'alt='logo'></div></a><h2class="location">Trait State</h2><divclass="sidebar-elems"><divclass="block items"><h3class="sidebar-title"><ahref="#required-methods">Required Methods</a></h3><divclass="sidebar-links"><ahref="#tymethod.draw">draw</a><ahref="#tymethod.event">event</a></div><h3class="sidebar-title"><ahref="#provided-methods">Provided Methods</a></h3><divclass="sidebar-links"><ahref="#method.draw_baselayer">draw_baselayer</a><ahref="#method.on_destroy">on_destroy</a></div><h3class="sidebar-title"><ahref="#implementations">Methods</a></h3><divclass="sidebar-links"><ahref="#method.downcast">downcast</a><ahref="#method.downcast_mut">downcast_mut</a><ahref="#method.downcast_rc">downcast_rc</a><ahref="#method.downcast_ref">downcast_ref</a><ahref="#method.is">is</a></div><h3class="sidebar-title"><ahref="#implementors">Implementors</a></h3></div><h2class="location">Other items in<br><ahref="index.html">widgetry</a></h2><divid="sidebar-vars"data-name="State"data-ty="trait"data-relpath=""></div><scriptdefersrc="sidebar-items.js"></script></div></nav><divclass="theme-picker"><buttonid="theme-picker"aria-label="Pick another theme!"aria-haspopup="menu"title="themes"><imgwidth="18"height="18"alt="Pick another theme!"src="../brush.svg"></button><divid="theme-choices"role="menu"></div></div><navclass="sub"><formclass="search-form"><divclass="search-container"><div><selectid="crate-search"><optionvalue="All crates">All crates</option></select><inputclass="search-input"name="search"disabledautocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"></div><buttontype="button"id="help-button"title="help">?</button><aid="settings-menu"href="../settings.html"title="settings"><imgwidth="18"height="18"alt="Change settings"src="../wheel.svg"></a></div></form></nav><sectionid="main"class="content"><h1class="fqn"><spanclass="in-band">Trait <ahref="index.html">widgetry</a>::<wbr><aclass="trait"href="#">State</a><buttonid="copy-path"onclick="copy_path(this)"title="copy path"><imgsrc="../clipboard.svg"width="19"height="18"alt="Copy item import"title="Copy item import to clipboard"></button></span><spanclass="out-of-band"><spanid="render-detail"><aid="toggle-all-docs"href="javascript:void(0)"title="collapse all docs">[<spanclass="inner">−</span>]</a></span><aclass="srclink"href="../src/widgetry/app_state.rs.html#171-185"title="gotoso
}</pre></div><detailsclass="rustdoc-toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>A temporary state of an application. There’s a stack of these, with the most recent being the
</div></details><h2id="required-methods"class="small-section-header">Required methods<ahref="#required-methods"class="anchor"></a></h2><divclass="methods"><detailsclass="rustdoc-toggle"open><summary><divid="tymethod.event"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#173"title="goto source code">[src]</a></div><h4class="code-header">fn <ahref="#tymethod.event"class="fnname">event</a>(<br> &mut self, <br> ctx: &mut <aclass="struct"href="event_ctx/struct.EventCtx.html"title="struct widgetry::event_ctx::EventCtx">EventCtx</a><'_>, <br> shared_app_state: <aclass="primitive"href="https://doc.rust-lang.org/1.55.0/std/primitive.reference.html">&mut </a>A<br>) -><aclass="enum"href="app_state/enum.Transition.html"title="enum widgetry::app_state::Transition">Transition</a><A></h4></div></summary><divclass="docblock"><p>Respond to a UI event, such as input or time passing.</p>
</div></details></div><h2id="provided-methods"class="small-section-header">Provided methods<ahref="#provided-methods"class="anchor"></a></h2><divclass="methods"><detailsclass="rustdoc-toggle"open><summary><divid="method.draw_baselayer"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#178-180"title="goto source code">[src]</a></div><h4class="code-header">fn <ahref="#method.draw_baselayer"class="fnname">draw_baselayer</a>(&self) -><aclass="enum"href="app_state/enum.DrawBaselayer.html"title="enum widgetry::app_state::DrawBaselayer">DrawBaselayer</a></h4></div></summary><divclass="docblock"><p>Specifies what to draw before draw()</p>
</div></details><detailsclass="rustdoc-toggle"open><summary><divid="method.on_destroy"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#183"title="goto source code">[src]</a></div><h4class="code-header">fn <ahref="#method.on_destroy"class="fnname">on_destroy</a>(&mut self, _: &mut <aclass="struct"href="event_ctx/struct.EventCtx.html"title="struct widgetry::event_ctx::EventCtx">EventCtx</a><'_>, _: <aclass="primitive"href="https://doc.rust-lang.org/1.55.0/std/primitive.reference.html">&mut </a>A)</h4></div></summary><divclass="docblock"><p>Before this state is popped or replaced, call this.</p>
</div></details></div><h2id="implementations"class="small-section-header">Implementations<ahref="#implementations"class="anchor"></a></h2><detailsclass="rustdoc-toggle implementors-toggle"open><summary><divid="impl"class="impl has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#impl"class="anchor"></a><h3class="code-header in-band">impl<A> dyn <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A><spanclass="where fmt-newline">where<br> A: <aclass="trait"href="https://doc.rust-lang.org/1.55.0/core/any/trait.Any.html"title="trait core::any::Any">Any</a> + 'static, </span></h3></div></summary><divclass="impl-items"><detailsclass="rustdoc-toggle method-toggle"open><summary><divid="method.is"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#method.is"class="anchor"></a><h4class="code-header">pub fn <ahref="#method.is"class="fnname">is</a><__T: <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A>>(&self) -><aclass="primitive"href="https://doc.rust-lang.org/1.55.0/std/primitive.bool.html">bool</a></h4></div></summary><divclass="docblock"><p>Returns true if the trait object wraps an object of type <code>__T</code>.</p>
</div></details><detailsclass="rustdoc-toggle method-toggle"open><summary><divid="method.downcast"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#method.downcast"class="anchor"></a><h4class="code-header">pub fn <ahref="#method.downcast"class="fnname">downcast</a><__T: <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A>>(self: <aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/boxed/struct.Box.html"title="struct alloc::boxed::Box">Box</a><Self>) -><aclass="enum"href="https://doc.rust-lang.org/1.55.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/boxed/struct.Box.html"title="struct alloc::boxed::Box">Box</a><__T>, <aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/boxed/struct.Box.html"title="struct alloc::boxed::Box">Box</a><Self>></h4></div></summary><divclass="docblock"><p>Returns a boxed object from a boxed trait object if the underlying object is of type
</div></details><detailsclass="rustdoc-toggle method-toggle"open><summary><divid="method.downcast_rc"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#method.downcast_rc"class="anchor"></a><h4class="code-header">pub fn <ahref="#method.downcast_rc"class="fnname">downcast_rc</a><__T: <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A>>(self: <aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/rc/struct.Rc.html"title="struct alloc::rc::Rc">Rc</a><Self>) -><aclass="enum"href="https://doc.rust-lang.org/1.55.0/core/result/enum.Result.html"title="enum core::result::Result">Result</a><<aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/rc/struct.Rc.html"title="struct alloc::rc::Rc">Rc</a><__T>, <aclass="struct"href="https://doc.rust-lang.org/1.55.0/alloc/rc/struct.Rc.html"title="struct alloc::rc::Rc">Rc</a><Self>></h4></div></summary><divclass="docblock"><p>Returns an <code>Rc</code>-ed object from an <code>Rc</code>-ed trait object if the underlying object is of
</div></details><detailsclass="rustdoc-toggle method-toggle"open><summary><divid="method.downcast_ref"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#method.downcast_ref"class="anchor"></a><h4class="code-header">pub fn <ahref="#method.downcast_ref"class="fnname">downcast_ref</a><__T: <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A>>(&self) -><aclass="enum"href="https://doc.rust-lang.org/1.55.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.55.0/std/primitive.reference.html">&</a>__T></h4></div></summary><divclass="docblock"><p>Returns a reference to the object within the trait object if it is of type <code>__T</code>, or
</div></details><detailsclass="rustdoc-toggle method-toggle"open><summary><divid="method.downcast_mut"class="method has-srclink"><divclass="rightside"><aclass="srclink"href="../src/widgetry/app_state.rs.html#187"title="goto source code">[src]</a></div><ahref="#method.downcast_mut"class="anchor"></a><h4class="code-header">pub fn <ahref="#method.downcast_mut"class="fnname">downcast_mut</a><__T: <aclass="trait"href="app_state/trait.State.html"title="trait widgetry::app_state::State">State</a><A>>(&mut self) -><aclass="enum"href="https://doc.rust-lang.org/1.55.0/core/option/enum.Option.html"title="enum core::option::Option">Option</a><<aclass="primitive"href="https://doc.rust-lang.org/1.55.0/std/primitive.reference.html">&mut </a>__T></h4></div></summary><divclass="docblock"><p>Returns a mutable reference to the object within the trait object if it is of type