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);Sourcepub fn title(&self) -> Option<&str>
pub fn title(&self) -> Option<&str>
The title the views set with Nav::set_title, as
applied to the browser tab or window.
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> Forget for RouterApp<S>
impl<S> Move for RouterApp<S>
impl<S> Unpin for RouterApp<S>where
S: Unpin,
*const u8 is !null: Unpin,
Rc<RouteEntry<S>>: Unpin,
Rc<dyn Fn(&str) -> bool>: Unpin,
Box<dyn History>: Unpin,
Rc<dyn Any>: Unpin,
Rc<ViewStore>: Unpin,
Rc<Cell<Deps>>: Unpin,
Rc<RefCell<Vec<Slot>>>: Unpin,
Rc<Level<S>>: Unpin,
Rc<RefCell<Box<dyn Any>>>: Unpin,
Rc<Page<S>>: Unpin,
Rc<dyn Fn(&mut Ui, &ViewContext<'_, S>)>: Unpin,
Box<dyn Future<Output = Outcome>>: Unpin,
Box<dyn Fn(&Navigation, &S)>: Unpin,
impl<S> UnsafeUnpin for RouterApp<S>where
*const u8 is !null: UnsafeUnpin,
PhantomData<Rc<RouteEntry<S>>>: UnsafeUnpin,
PhantomData<(String, Rc<dyn Fn(&str) -> bool>)>: UnsafeUnpin,
S: UnsafeUnpin,
*const dyn History is !null: UnsafeUnpin,
PhantomData<dyn History>: UnsafeUnpin,
PhantomData<(EntryKey, EntryMeta)>: UnsafeUnpin,
PhantomData<(u64, Visit)>: UnsafeUnpin,
PhantomData<NavAction>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Param>: UnsafeUnpin,
*const RcInner<Cell<Deps>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<Deps>>>: UnsafeUnpin,
*const RcInner<RefCell<Vec<Slot>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<Vec<Slot>>>>: UnsafeUnpin,
*const RcInner<dyn Any> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Any>>: UnsafeUnpin,
PhantomData<Rc<Level<S>>>: UnsafeUnpin,
PhantomData<Option<Loaded>>: UnsafeUnpin,
PhantomData<Option<Rc<ViewStore>>>: UnsafeUnpin,
*const RcInner<ViewStore> is !null: UnsafeUnpin,
PhantomData<RcInner<ViewStore>>: UnsafeUnpin,
*const RcInner<Page<S>> is !null: UnsafeUnpin,
PhantomData<RcInner<Page<S>>>: UnsafeUnpin,
*const RcInner<RefCell<Box<dyn Any>>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<Box<dyn Any>>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut Ui, &ViewContext<'_, S>)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut Ui, &ViewContext<'_, S>)>>: UnsafeUnpin,
*const RcInner<RouteEntry<S>> is !null: UnsafeUnpin,
PhantomData<RcInner<RouteEntry<S>>>: UnsafeUnpin,
*const dyn Future<Output = Outcome> is !null: UnsafeUnpin,
PhantomData<dyn Future<Output = Outcome>>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<Job<S>>: UnsafeUnpin,
PhantomData<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
impl<T> ErasedDestructor for Twhere
T: 'static,
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