Struct perseus::router::RouterState

source ·
pub struct RouterState { /* private fields */ }
Expand description

The state for the router. This makes use of RcSignals internally, and can be cheaply cloned.

Implementations§

source§

impl RouterState

source

pub fn get_load_state<'a>(&self, cx: Scope<'a>) -> &'a RcSignal<RouterLoadState>

Gets the load state of the router. You’ll still need to call .get() after this (this just returns a &'a RcSignal to derive other state from in a create_memo or the like).

source

pub fn get_last_verdict(&self) -> Option<RouteVerdict>

Gets the last verdict.

source

pub fn reload(&self)

Orders the router to reload the current page as if you’d called navigate() to it (but that would do nothing). This enables reloading in an SPA style (but you should almost never need it).

Warning: if you’re trying to rest your app, do NOT use this! Instead, reload the page fully through web_sys.

source

pub fn get_path(&self) -> Option<PathMaybeWithLocale>

Gets the current path within the app, including the locale if the app is using i18n. This will not have a leading/trailing forward slash.

If you’re executing this from within a page, it will always be Some(..). None will be returned if no page has been rendered yet (if you managed to call this from a plugin…), or, more likely, if an error occurred (i.e. this will probably be None in error pages, which are given the path anyway), or if we’re diverting to a localized version of the current path (in which case your code should not be running).

Trait Implementations§

source§

impl Clone for RouterState

source§

fn clone(&self) -> RouterState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RouterState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RouterState

source§

fn default() -> Self

Creates a default instance of the router state intended for usage at the startup of an app.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.