Trait yew_router::Routable

source ·
pub trait Routable: Clone + PartialEq {
    // Required methods
    fn from_path(path: &str, params: &HashMap<&str, &str>) -> Option<Self>;
    fn to_path(&self) -> String;
    fn routes() -> Vec<&'static str>;
    fn not_found_route() -> Option<Self>;
    fn recognize(pathname: &str) -> Option<Self>;
}
Expand description

Marks an enum as routable.

Implementation

Use derive macro to implement it. Although it is possible to implement it manually, it is discouraged.

Usage

The functions exposed by this trait are not supposed to be consumed directly. Instead use the functions exposed at the crate’s root to perform operations with the router.

Required Methods§

source

fn from_path(path: &str, params: &HashMap<&str, &str>) -> Option<Self>

Converts path to an instance of the routes enum.

source

fn to_path(&self) -> String

Converts the route to a string that can passed to the history API.

source

fn routes() -> Vec<&'static str>

Lists all the available routes

source

fn not_found_route() -> Option<Self>

The route to redirect to on 404

source

fn recognize(pathname: &str) -> Option<Self>

Match a route based on the path

Object Safety§

This trait is not object safe.

Implementors§