pub struct RouterApp<S> { /* private fields */ }Expand description
A built router: owns the app state, the history and the page on screen.
Call RouterApp::ui every frame, e.g. from eframe::App::ui.
Implementations§
Source§impl<S: Clone + 'static> RouterApp<S>
impl<S: Clone + 'static> RouterApp<S>
Sourcepub fn preload_on_hover(self, enabled: bool) -> Self
pub fn preload_on_hover(self, enabled: bool) -> Self
Whether Nav::link preloads its target while hovered. On by default.
Calls callback after every navigation, once the new page is mounted, e.g. for
analytics or focus management. Not called for invalidations.
pub fn state(&self) -> &S
Sourcepub fn matches(&self, url: &str) -> Option<&str>
pub fn matches(&self, url: &str) -> Option<&str>
The pattern of the page route that url matches, e.g. /blog/{slug}, or None if it
matches none (a 404). Doesn’t navigate or run anything: e.g. to check in a test that
every address the app builds leads to a page.
A match can still fail to load, e.g. with a Path that doesn’t
parse.
let app = Router::<()>::new()
.page("/blog/{slug}", Page::new(|_: &mut egui::Ui| {}))
.with_state_and_history((), MemoryHistory::new("/"));
assert_eq!(app.matches("/blog/hello?draft"), Some("/blog/{slug}"));
assert_eq!(app.matches("/blog"), None);pub fn is_loading(&self) -> bool
Sourcepub fn goto(&mut self, url: &str)
pub fn goto(&mut self, url: &str)
Navigates to url, adding a history entry. Going to the current url does nothing, unless
GotoOptions::invalidate_all asks for a reload. See
Nav::goto.
Sourcepub fn goto_with(&mut self, url: &str, options: GotoOptions)
pub fn goto_with(&mut self, url: &str, options: GotoOptions)
See Nav::goto_with.
pub fn back(&mut self)
pub fn forward(&mut self)
Sourcepub fn invalidate(&mut self, key: impl Into<String>)
pub fn invalidate(&mut self, key: impl Into<String>)
See Nav::invalidate; e.g. after data changed in the background.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
See Nav::invalidate_all.
Sourcepub fn preload(&mut self, url: &str)
pub fn preload(&mut self, url: &str)
See Nav::preload.
Auto Trait Implementations§
impl<S> !Freeze for RouterApp<S>
impl<S> !RefUnwindSafe for RouterApp<S>
impl<S> !Send for RouterApp<S>
impl<S> !Sync for RouterApp<S>
impl<S> !UnwindSafe for RouterApp<S>
impl<S> Unpin for RouterApp<S>
impl<S> UnsafeUnpin for RouterApp<S>where
RouteTable<S>: UnsafeUnpin,
S: UnsafeUnpin,
Option<Mounted<S>>: UnsafeUnpin,
Option<Transition<S>>: UnsafeUnpin,
Option<Pending<S>>: UnsafeUnpin,
Vec<Job<S>>: UnsafeUnpin,
Vec<Box<dyn Fn(&Navigation, &S)>>: UnsafeUnpin,
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> 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