pub struct SaveableScope { /* private fields */ }Expand description
Where the rememberSaveable calls in some content keep their values: a
key namespace, and whether the values are saved in preferences or kept
only in memory. A navigation host gives each back-stack entry its own, so
two visits of one screen keep apart.
Implementations§
Source§impl SaveableScope
impl SaveableScope
Sourcepub fn current() -> SaveableScope
pub fn current() -> SaveableScope
The scope where this is composed: the one ProvideSaveableScope
gives, else the root scope, which saves each key as it is in
preferences. Call it while composing.
Sourcepub fn child(&self, name: impl Display) -> SaveableScope
pub fn child(&self, name: impl Display) -> SaveableScope
The scope named name inside this one. It saves where this one does.
Sourcepub fn in_memory(self) -> SaveableScope
pub fn in_memory(self) -> SaveableScope
This scope with its values kept only in memory, until the scope is forgotten or the process ends.
Sourcepub fn namespace(&self) -> Option<&str>
pub fn namespace(&self) -> Option<&str>
The prefix of the keys this scope saves under; None for the root
scope, whose keys stand as they are.
Sourcepub fn is_durable(&self) -> bool
pub fn is_durable(&self) -> bool
Whether this scope saves its values in preferences, rather than
keeping them in memory.
Sourcepub fn restore(&self, key: &str) -> Option<String>
pub fn restore(&self, key: &str) -> Option<String>
The value last saved under key in this scope.
Sourcepub fn register(
&self,
key: &str,
read: impl Fn() -> Option<String> + 'static,
) -> SaveableRegistration
pub fn register( &self, key: &str, read: impl Fn() -> Option<String> + 'static, ) -> SaveableRegistration
Saves what read returns under key in this scope at each save
boundary while the registration lives, and keeps its last value once
it is dropped, as rememberSaveable does. read must not perform
storage I/O.
Sourcepub fn forget(&self)
pub fn forget(&self)
Forgets everything saved in this scope: the state of a back-stack entry once it is popped. Saves in it stop, and stored values are removed at the next save boundary. The root scope forgets nothing.
Sourcepub fn forget_children_except<N>(&self, keep: impl IntoIterator<Item = N>)where
N: Display,
pub fn forget_children_except<N>(&self, keep: impl IntoIterator<Item = N>)where
N: Display,
Forgets everything saved in this scope apart from the child scopes
named in keep, as SaveableScope::forget does.
Trait Implementations§
Source§impl Clone for SaveableScope
impl Clone for SaveableScope
Source§fn clone(&self) -> SaveableScope
fn clone(&self) -> SaveableScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SaveableScope
impl Debug for SaveableScope
impl Eq for SaveableScope
Source§impl PartialEq for SaveableScope
impl PartialEq for SaveableScope
impl StructuralPartialEq for SaveableScope
Auto Trait Implementations§
impl !Send for SaveableScope
impl !Sync for SaveableScope
impl Freeze for SaveableScope
impl RefUnwindSafe for SaveableScope
impl Unpin for SaveableScope
impl UnsafeUnpin for SaveableScope
impl UnwindSafe for SaveableScope
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.