pub struct Nav<R> { /* private fields */ }Expand description
A navigation stack the app holds in its Model. The core owns the stack
(single source of truth); the framework reads its route/depth to drive
the shell’s push/pop transitions and back button.
R is your screen-route type (typically a small enum). Hold it in the model,
mutate it in update (push/pop/reset), match current() in view, and
build the shell with nav_scaffold. Wire a Msg::Back (or similar) event to
pop so the back affordance works.
ⓘ
#[derive(Clone, Serialize)] enum Route { List, Detail(u32) }
// model.nav: Nav<Route> = Nav::new(Route::List);
// update: Msg::Open(id) => model.nav.push(Route::Detail(id)),
// Msg::Back => model.nav.pop(),
// view: nav_scaffold(title, dark, tabs, body, &model.nav, Msg::Back)Implementations§
Sourcepub fn reset(&mut self, root: R)
pub fn reset(&mut self, root: R)
Replace the whole stack with a fresh root (e.g. switching bottom-nav tabs).
Sourcepub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Whether there is a screen to pop back to.
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
Mutably borrows from an owned value. Read more