Skip to main content

routes

Macro routes 

Source
macro_rules! routes {
    ($(#[$meta:meta])* $vis:vis enum $name:ident {
        $($(#[$vmeta:meta])* $variant:ident => $key:literal $(($title:expr))?),+ $(,)?
    }) => { ... };
}
Expand description

Define a plain routes enum and its Route impl in one shot:

ⓘ
day::routes! {
    pub enum Section { Controls => "controls", Text => "text" }
}
nav(section).item(Section::Controls, tr("controls"), controls_page)

A variant may add its display title after the key, anything a label takes (a string, or a localized tr(…) resolved when the page is pushed). It is what a nav_stack shows in the navigation bar for that route; a variant without one shows its key:

ⓘ
day::routes! {
    enum Demo { Basics => "basics" (tr("demo-basics")), Stress => "stress" }
}

Variants that carry data (Item { id: u32 } ↔ "item-42") implement Route by hand.

Day API ↩ Guides· daybrite.dev