This is unreleased documentation for Yew Next version.
For up-to-date documentation, see the latest version on docs.rs.
yew_router

Trait 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

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.

Implementors§