pub struct ResourceMap { /* private fields */ }Implementations§
Source§impl ResourceMap
impl ResourceMap
Sourcepub fn new(root: ResourceDef) -> Self
pub fn new(root: ResourceDef) -> Self
Creates a container node in the ResourceMap tree.
Sourcepub fn add(
&mut self,
pattern: &mut ResourceDef,
nested: Option<Rc<ResourceMap>>,
)
pub fn add( &mut self, pattern: &mut ResourceDef, nested: Option<Rc<ResourceMap>>, )
Adds a (possibly nested) resource.
To add a non-prefix pattern, nested must be None.
To add external resource, supply a pattern without a leading /.
The root pattern of nested, if present, should match pattern.
Sourcepub fn url_for<U, I>(
&self,
req: &HttpRequest,
name: &str,
elements: U,
) -> Result<Url, UrlGenerationError>
pub fn url_for<U, I>( &self, req: &HttpRequest, name: &str, elements: U, ) -> Result<Url, UrlGenerationError>
Generate URL for named resource.
Check HttpRequest::url_for for detailed information.
Sourcepub fn url_for_map<K, V, S>(
&self,
req: &HttpRequest,
name: &str,
elements: &HashMap<K, V, S>,
) -> Result<Url, UrlGenerationError>
pub fn url_for_map<K, V, S>( &self, req: &HttpRequest, name: &str, elements: &HashMap<K, V, S>, ) -> Result<Url, UrlGenerationError>
Generate URL for named resource using map of dynamic segment values.
Check HttpRequest::url_for_map for detailed information.
Sourcepub fn url_for_iter<K, V, I>(
&self,
req: &HttpRequest,
name: &str,
elements: I,
) -> Result<Url, UrlGenerationError>
pub fn url_for_iter<K, V, I>( &self, req: &HttpRequest, name: &str, elements: I, ) -> Result<Url, UrlGenerationError>
Generate URL for named resource using an iterator of key-value pairs.
Check HttpRequest::url_for_iter for detailed information.
Sourcepub fn has_resource(&self, path: &str) -> bool
pub fn has_resource(&self, path: &str) -> bool
Returns true if there is a resource that would match path.
Sourcepub fn match_name(&self, path: &str) -> Option<&str>
pub fn match_name(&self, path: &str) -> Option<&str>
Returns the name of the route that matches the given path or None if no full match is possible or the matching resource is not named.
Sourcepub fn match_pattern(&self, path: &str) -> Option<String>
pub fn match_pattern(&self, path: &str) -> Option<String>
Returns the full resource pattern matched against a path or None if no full match is possible.
Trait Implementations§
Source§impl Clone for ResourceMap
impl Clone for ResourceMap
Source§fn clone(&self) -> ResourceMap
fn clone(&self) -> ResourceMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more