pub trait Route:
Clone
+ PartialEq
+ 'static {
// Required methods
fn key(&self) -> String;
fn from_key(key: &str) -> Option<Self>;
// Provided method
fn title(&self) -> String { ... }
}Expand description
A typed route key, the compile-checked alternative to raw string keys.
Implement on an enum (one variant per destination) and use it everywhere a key goes:
nav(Signal<Option<Section>>) + .item(Section::Controls, …),
nav_stack(Signal<Vec<Drill>>, …) + .destination(|d: &Drill| …), navigate_to, route.
The string layer stays the wire format (deep links, dayscript, and current_route
still speak Route::key strings), but app code never assembles or splits them.
Variants can carry data (Item { id: u32 } ↔ "item-42"): encode it in Route::key,
parse it back in Route::from_key, and destination builders receive the typed value.
For plain data-free enums the routes! macro writes both sides.
Required Methods§
Sourcefn key(&self) -> String
fn key(&self) -> String
The path segment this value occupies in a route string. Must round-trip through
Route::from_key and must not be empty; "" means “no selection” (see the
Option<R> impl).
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<R: Route> Route for Option<R>
None ↔ "" (no selection): the key type for a sidebar nav, whose collapsed
mobile state is “nothing selected”. .item(Section::X, …) still takes the bare value
(Section: Into<Option<Section>>).
impl<R: Route> Route for Option<R>
None ↔ "" (no selection): the key type for a sidebar nav, whose collapsed
mobile state is “nothing selected”. .item(Section::X, …) still takes the bare value
(Section: Into<Option<Section>>).