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 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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !Freeze for ResourceMap
impl !RefUnwindSafe for ResourceMap
impl !Send for ResourceMap
impl !Sync for ResourceMap
impl Unpin for ResourceMap
impl !UnwindSafe for ResourceMap
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)