Skip to main content

Store

Struct Store 

Source
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

Source

pub fn new() -> Self

Create an empty store.

The [egui::Context] used for repaint requests is a placeholder until the first Store::begin_pass.

Source

pub fn begin_pass(&mut self, ctx: &Context)

Start a new pass: bump the pass counter and adopt ctx for repaints.

Source

pub fn in_hidden(&self) -> bool

Is a hidden leaf being drawn right now?

Source

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.

Source

pub fn warn_on_collision(&self) -> bool

Whether id collisions are drawn as an on-screen overlay.

Defaults to cfg!(debug_assertions).

Source

pub fn set_warn_on_collision(&mut self, warn: bool)

Turn the collision overlay on or off.

Source

pub fn ctx(&self) -> &Context

The context repaints are requested on.

Source

pub fn pass(&self) -> u64

The current pass number. Starts at 1 after the first begin_pass.

Source

pub fn collisions(&self) -> Vec<Collision>

Id collisions recorded during the current pass.

Source

pub fn len(&self) -> usize

Number of live slots.

Source

pub fn is_empty(&self) -> bool

Whether the store holds no slots.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Default for Store

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,