pub struct PageStorageBucket { /* private fields */ }Expand description
A storage bucket associated with a page in an app.
Useful for storing per-page state that persists across navigations from one page to another.
A bucket has identity, so it is an arena object reached through its Handle.
Implementations§
Source§impl PageStorageBucket
impl PageStorageBucket
Sourcepub fn new(app: &mut App) -> Ref<PageStorageBucket>
pub fn new(app: &mut App) -> Ref<PageStorageBucket>
Creates an empty bucket.
Sourcepub fn write_state(
self: Handle<Self>,
app: &mut App,
context: BuildContext,
data: Rc<dyn Any>,
identifier: Option<KeyRef>,
)
pub fn write_state( self: Handle<Self>, app: &mut App, context: BuildContext, data: Rc<dyn Any>, identifier: Option<KeyRef>, )
Write the given data into this page storage bucket using the specified identifier or
an identifier computed from the given context. The computed identifier is based on
the PageStorageKeys found in the path from context to the PageStorage widget
that owns this page storage bucket.
If an explicit identifier is not provided and no PageStorageKeys are found, then
the data is not saved.
Sourcepub fn read_state(
self: Handle<Self>,
app: &App,
context: BuildContext,
identifier: Option<KeyRef>,
) -> Option<Rc<dyn Any>>
pub fn read_state( self: Handle<Self>, app: &App, context: BuildContext, identifier: Option<KeyRef>, ) -> Option<Rc<dyn Any>>
Read given data from into this page storage bucket using the specified identifier or
an identifier computed from the given context. The computed identifier is based on
the PageStorageKeys found in the path from context to the PageStorage widget
that owns this page storage bucket.
If an explicit identifier is not provided and no PageStorageKeys are found, then
null is returned.