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§
Sourcefn from_path(path: &str, params: &HashMap<&str, &str>) -> Option<Self>
fn from_path(path: &str, params: &HashMap<&str, &str>) -> Option<Self>
Converts path to an instance of the routes enum.
Sourcefn not_found_route() -> Option<Self>
fn not_found_route() -> Option<Self>
The route to redirect to on 404
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.