pub struct PageState<'f, T: 'static> { /* private fields */ }Expand description
State a view owns for as long as its page is shown.
Created with T::default() the first time it is extracted, then kept from frame to frame:
use it for what the user does on the page (a form’s text, a toggle). Unlike the load’s
data, it survives invalidations. It is dropped when the user navigates away, and starts
over when they come back. For state that comes back with back/forward, use Snapshot.
In a page view, it belongs to the page instance, which shallow routing and invalidations keep. In a layout view, it belongs to the layout and lasts as long as the layout stays on screen, so it survives navigations between the pages below it.
Each type is one value per view: use a dedicated type, not String or bool.
use egui::Ui;
use egui_kit::extract::PageState;
#[derive(Default)]
struct Draft {
title: String,
}
fn view(ui: &mut Ui, mut draft: PageState<Draft>) {
ui.text_edit_singleline(&mut draft.title);
}To start from the load’s data, see PageStateFrom.
Trait Implementations§
Auto Trait Implementations§
impl<'f, T> !RefUnwindSafe for PageState<'f, T>
impl<'f, T> !Send for PageState<'f, T>
impl<'f, T> !Sync for PageState<'f, T>
impl<'f, T> !UnwindSafe for PageState<'f, T>
impl<'f, T> Freeze for PageState<'f, T>
impl<'f, T> Unpin for PageState<'f, T>
impl<'f, T> UnsafeUnpin for PageState<'f, T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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