pub struct WebHistory<R: Routable> { /* private fields */ }
Expand description

A HistoryProvider that integrates with a browser via the History API.

Prefix

This HistoryProvider supports a prefix, which can be used for web apps that aren’t located at the root of their domain.

Application developers are responsible for ensuring that right after the prefix comes a /. If that is not the case, this HistoryProvider will replace the first character after the prefix with one.

Application developers are responsible for not rendering the router if the prefix is not present in the URL. Otherwise, if a router navigation is triggered, the prefix will be added.

Implementations§

source§

impl<R: Routable> WebHistory<R>

source

pub fn new(prefix: Option<String>, do_scroll_restoration: bool) -> Selfwhere <R as FromStr>::Err: Display,

Create a new WebHistory.

If do_scroll_restoration is true, WebHistory will take control of the history state. It’ll also set the browsers scroll restoration to manual.

Trait Implementations§

source§

impl<R: Routable> Default for WebHistory<R>where <R as FromStr>::Err: Display,

source§

fn default() -> Self

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

impl<R: Routable> HistoryProvider<R> for WebHistory<R>where <R as FromStr>::Err: Display,

source§

fn current_route(&self) -> R

Get the path of the current URL. Read more
source§

fn current_prefix(&self) -> Option<String>

Get the current path prefix of the URL. Read more
source§

fn go_back(&mut self)

Go back to a previous page. Read more
source§

fn go_forward(&mut self)

Go forward to a future page. Read more
source§

fn push(&mut self, state: R)

Go to another page. Read more
source§

fn replace(&mut self, state: R)

Replace the current page with another one. Read more
source§

fn external(&mut self, url: String) -> bool

Navigate to an external URL. Read more
source§

fn updater(&mut self, callback: Arc<dyn Fn() + Send + Sync>)

Provide the HistoryProvider with an update callback. Read more
source§

fn can_go_back(&self) -> bool

Check whether there is a previous page to navigate back to. Read more
source§

fn can_go_forward(&self) -> bool

Check whether there is a future page to navigate forward to. Read more

Auto Trait Implementations§

§

impl<R> !RefUnwindSafe for WebHistory<R>

§

impl<R> !Send for WebHistory<R>

§

impl<R> !Sync for WebHistory<R>

§

impl<R> Unpin for WebHistory<R>where R: Unpin,

§

impl<R> !UnwindSafe for WebHistory<R>

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.

§

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

§

fn to<T>(self) -> Twhere Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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.