pub struct Nav<'f> { /* private fields */ }Expand description
The router, as seen by a view: navigating, loading, shallow routing and blocking.
An extractor: add a nav: Nav argument to any view. It is Copy, so it can be used in
nested closures. Requests are queued and applied after the frame.
Implementations§
Sourcepub fn url(&self) -> &'f str
pub fn url(&self) -> &'f str
The url of the current history entry. Differs from the page’s
Request after Nav::push_state / Nav::replace_state with a
new url.
Sourcepub fn is_active(&self, href: &str) -> bool
pub fn is_active(&self, href: &str) -> bool
Whether href is the current path, or (for anything but /) a parent of it.
Sourcepub fn is_outgoing(&self) -> bool
pub fn is_outgoing(&self) -> bool
Whether this is the previous page, rendered while a ViewTransition
animates it out. Its navigation calls are ignored. Skip things that live outside the
page’s Ui (windows, modals, popups), which the transition can’t fade or clip.
Sourcepub fn goto(&self, url: impl Into<String>)
pub fn goto(&self, url: impl Into<String>)
Navigates to url, adding a history entry.
The current page stays visible until all hooks and load handlers of the new route finished.
Sourcepub fn replace(&self, url: impl Into<String>)
pub fn replace(&self, url: impl Into<String>)
Navigates to url, replacing the current history entry.
pub fn back(&self)
pub fn forward(&self)
pub fn can_go_back(&self) -> bool
pub fn can_go_forward(&self) -> bool
Sourcepub fn link(
&self,
ui: &mut Ui,
text: impl Into<WidgetText>,
href: &str,
) -> Response
pub fn link( &self, ui: &mut Ui, text: impl Into<WidgetText>, href: &str, ) -> Response
A hyperlink that navigates within the app. Preloads the target while hovered, unless disabled.
A selectable label that is highlighted when href is active.
Sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Whether a navigation is in progress.
Sourcepub fn loading_url(&self) -> Option<String>
pub fn loading_url(&self) -> Option<String>
The url currently being loaded, if any.
Sourcepub fn preload(&self, url: impl Into<String>)
pub fn preload(&self, url: impl Into<String>)
Starts loading url (hooks and loads) in the background, so that navigating there is
instant. Preloads are dropped once any navigation finishes.
Sourcepub fn invalidate(&self, key: impl Into<String>)
pub fn invalidate(&self, key: impl Into<String>)
Sourcepub fn invalidate_all(&self)
pub fn invalidate_all(&self)
Reruns all loads of the current page.
Sourcepub fn push_state<T: Any>(&self, url: impl Into<String>, state: T)
pub fn push_state<T: Any>(&self, url: impl Into<String>, state: T)
Adds a history entry with url ("" keeps the current url) and attaches state to it,
without running hooks or loads. The page stays as it is and can read the state with the
HistoryState extractor.
Going back and forward between entries of the same page only swaps the page state.
Entries of a page that is no longer shown are loaded normally, and get their state back.
A browser reload loses all page state, so url should also work on its own, e.g. for a
photo opened in a modal, the photo’s own page.
Sourcepub fn replace_state<T: Any>(&self, url: impl Into<String>, state: T)
pub fn replace_state<T: Any>(&self, url: impl Into<String>, state: T)
Like Nav::push_state, but replaces the state (and url) of the current entry.
Sourcepub fn clear_history_state(&self)
pub fn clear_history_state(&self)
Removes the state of the current entry, keeping its url.
Call every frame while leaving the page would lose something (e.g. unsaved changes).
Navigations away from the page (links, goto, back/forward) are then held back until
you confirm or cancel them;
see Nav::blocked_navigation. Shallow routing and invalidation are not affected.
Closing the browser tab or reloading it can’t be blocked this way.
The navigation being held back, to ask the user what to do.
Lets the blocked navigation happen.
Drops the blocked navigation.
Trait Implementations§
Auto Trait Implementations§
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more