File size: 1,000 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, Vc};
#[turbo_tasks::value]
#[derive(Debug, Clone)]
#[serde(untagged)]
pub enum Param {
Single(RcStr),
Multi(Vec<RcStr>),
}
#[turbo_tasks::value(transparent)]
#[derive(Debug, Clone)]
pub struct Params(pub Option<FxIndexMap<RcStr, Param>>);
/// Extracts parameters from a URL path.
pub trait RouteMatcherRef {
/// Returns whether the given path is a match for the route.
fn matches(&self, path: &str) -> bool;
/// Returns the parameters extracted from the given path.
fn params(&self, path: &str) -> Params;
}
/// Extracts parameters from a URL path (Vc version)
#[turbo_tasks::value_trait]
pub trait RouteMatcher {
/// Returns whether the given path is a match for the route.
#[turbo_tasks::function]
fn matches(self: Vc<Self>, path: RcStr) -> Vc<bool>;
/// Returns the parameters extracted from the given path.
#[turbo_tasks::function]
fn params(self: Vc<Self>, path: RcStr) -> Vc<Params>;
}
|