Struct perseus::state::PageStateStore
source · [−]pub struct PageStateStore { /* private fields */ }
Expand description
A container for page state in Perseus. This is designed as a context store, in which one of each type can be stored. Therefore, it acts very similarly to Sycamore’s context system, though it’s specifically designed for each page to store one reactive properties object. In theory, you could interact with this entirely independently of Perseus’ state interface, though this isn’t recommended.
Note that the same pages in different locales will have different entries here. If you need to store state for a page across locales, you should use the global state system instead. For apps not using i18n, the page URL will not include any locale.
Implementations
sourceimpl PageStateStore
impl PageStateStore
sourcepub fn get<T: AnyFreeze + Clone>(&self, url: &str) -> Option<T>
pub fn get<T: AnyFreeze + Clone>(&self, url: &str) -> Option<T>
Gets an element out of the state by its type and URL. If the element stored for the given URL doesn’t match the provided type, None
will be returned.
sourceimpl PageStateStore
impl PageStateStore
sourcepub fn freeze_to_hash_map(&self) -> HashMap<String, String>
pub fn freeze_to_hash_map(&self) -> HashMap<String, String>
Freezes the component entries into a new HashMap
of String
s to avoid extra layers of deserialization.
Trait Implementations
sourceimpl Clone for PageStateStore
impl Clone for PageStateStore
sourcefn clone(&self) -> PageStateStore
fn clone(&self) -> PageStateStore
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PageStateStore
impl Debug for PageStateStore
sourceimpl Default for PageStateStore
impl Default for PageStateStore
sourcefn default() -> PageStateStore
fn default() -> PageStateStore
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for PageStateStore
impl !Send for PageStateStore
impl !Sync for PageStateStore
impl Unpin for PageStateStore
impl !UnwindSafe for PageStateStore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more