pub struct Store { /* private fields */ }Expand description
Owns every hook’s state, keyed by [egui::Id].
The runner (or a test) calls Store::begin_pass before the tree is drawn
and Store::end_pass after every guard has been dropped.
Implementations§
Source§impl Store
impl Store
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty store.
The [egui::Context] used for repaint requests is a placeholder until
the first Store::begin_pass.
Sourcepub fn begin_pass(&mut self, ctx: &Context)
pub fn begin_pass(&mut self, ctx: &Context)
Start a new pass: bump the pass counter and adopt ctx for repaints.
Is a hidden leaf being drawn right now?
Sourcepub fn end_pass(&mut self)
pub fn end_pass(&mut self)
Finish the pass: apply the deferred queue, then sweep, then warn.
Every crate::State guard must have been dropped before this is
called. The deferred queue runs first so that a queued write lands on a
slot that is still alive, and the collision overlay last so that it is
painted over the frame it describes.
Sourcepub fn warn_on_collision(&self) -> bool
pub fn warn_on_collision(&self) -> bool
Whether id collisions are drawn as an on-screen overlay.
Defaults to cfg!(debug_assertions).
Sourcepub fn set_warn_on_collision(&mut self, warn: bool)
pub fn set_warn_on_collision(&mut self, warn: bool)
Turn the collision overlay on or off.
Sourcepub fn collisions(&self) -> Vec<Collision>
pub fn collisions(&self) -> Vec<Collision>
Id collisions recorded during the current pass.
Sourcepub fn tree_count(&self) -> usize
pub fn tree_count(&self) -> usize
Number of live layout trees, one per <View> root drawn last pass.
For tests: it is how a test asks “did scrolling a list build a tree per row?” without reaching into egui memory.
Sourcepub fn begin_suspense(&self)
pub fn begin_suspense(&self)
Enter a <Suspense> boundary: push a counter of its own.
The stack is cleared by Store::begin_pass, so an early return out of
a boundary cannot leak a counter into the next pass.
Sourcepub fn end_suspense(&self) -> usize
pub fn end_suspense(&self) -> usize
Leave the innermost <Suspense> boundary.
Returns how many use_futures were pending inside it. Nested boundaries
keep their own count, so this only reports what nothing inner caught.
Sourcepub fn note_pending(&self)
pub fn note_pending(&self)
Count one pending use_future against the innermost boundary.
Does nothing outside a boundary: a use_future with no <Suspense>
above it just returns Poll::Pending to its component.
Sourcepub fn load_persisted(&mut self, json: &str)
pub fn load_persisted(&mut self, json: &str)
Restore what Store::save_persisted produced.
Call this before the first pass; keys that no use_persisted asks for
are kept as they are, so an unused value survives a run that never
mounted its component.
Sourcepub fn save_persisted(&self) -> String
pub fn save_persisted(&self) -> String
Serialise every use_persisted value into one JSON string.
Values whose component is currently mounted are read from their slot; unmounted ones come from what the sweep saved.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Store
impl !RefUnwindSafe for Store
impl !Send for Store
impl !Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl !UnwindSafe for Store
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more