Skip to main content

Route

Trait Route 

Source
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: selector(Signal<Option<Section>>) + .item(Section::Controls, …), 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§

Source

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).

Source

fn from_key(key: &str) -> Option<Self>

Parse a path segment back into the typed value; None = not one of this type’s routes.

Provided Methods§

Source

fn title(&self) -> String

The human-readable title shown in the native navigation bar when this route is the top of a stack. Defaults to key; override it to show a display name (e.g. an app’s name) instead of the wire key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Route for String

Raw string keys — the untyped baseline. Every segment parses.

Source§

impl<R> Route for Option<R>
where R: Route,

None"" (no selection) — the key type for a sidebar selector, whose collapsed mobile state IS “nothing selected”. .item(Section::X, …) still takes the bare value (Section: Into<Option<Section>>).

Source§

fn key(&self) -> String

Source§

fn from_key(key: &str) -> Option<Option<R>>

Implementors§

Day API ↩ Guides· daybrite.dev