Skip to main content

StateStore

Struct StateStore 

Source
pub struct StateStore { /* private fields */ }
Expand description

What every component’s state, and every hook’s, is kept in between rebuilds. It lives in the Runtime, under the place of the component that owns it.

Implementations§

Source§

impl StateStore

Source

pub fn begin_build(&self)

A rebuild of the tree is about to run. Every state it reaches is marked as reached.

Source

pub fn end_frame(&self)

The frame is done laying out: the states a rebuild did not reach are disposed, and the effects it asked for run.

Effects run after the tree is built and laid out, so that what they do — start a timer, read a controller, ask for another rebuild — never happens in the middle of building.

Source

pub fn snapshot(&self) -> String

What every live state that opts in (State::save) wants kept across a restart, as text: a line a state, its place, its type and what it saved.

frus run asks for this just before it stops the application to start a new build, and hands it to StateStore::restore_from in the new one. A state is given back what it saved only by the component at the same place, of the same type.

Source

pub fn restore_from(&self, snapshot: &str)

Takes a StateStore::snapshot: each state it holds is given back to the component that mounts first at its place, with its type.

Source

pub fn provide<T: 'static>(&self, value: Rc<T>)

Makes value available to every component below as a service: the way an application-wide object — a router, a repository — is reached from a build.

Source

pub fn service<T: 'static>(&self) -> Option<Rc<T>>

The service of type T, if one was provided.

Source

pub fn len(&self) -> usize

How many components currently hold state. For tests and diagnostics.

Source

pub fn is_empty(&self) -> bool

Whether no component holds any state.

Trait Implementations§

Source§

impl Default for StateStore

Source§

fn default() -> Self

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

Auto Trait Implementations§

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.