pub struct ResourceMap { /* private fields */ }Expand description
Map of registered resources, used for URL generation.
The map is built from the application’s resource definitions and is used
by HttpRequest::url_for() to resolve
named and external resources.
Implementations§
Source§impl ResourceMap
impl ResourceMap
Sourcepub fn new(root: ResourceDef) -> Self
pub fn new(root: ResourceDef) -> Self
Create an empty resource map for the root resource.
Sourcepub fn add(
&mut self,
pattern: &mut ResourceDef,
nested: Option<Rc<ResourceMap>>,
)
pub fn add( &mut self, pattern: &mut ResourceDef, nested: Option<Rc<ResourceMap>>, )
Add a resource pattern, optionally with the resource map of a nested scope.
Assigns the pattern its id within this map. Named patterns can be used for URL generation.
Source§impl ResourceMap
impl ResourceMap
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.
Trait Implementations§
Source§impl Clone for ResourceMap
impl Clone for ResourceMap
Source§fn clone(&self) -> ResourceMap
fn clone(&self) -> ResourceMap
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 !UnwindSafe for ResourceMap
impl Unpin for ResourceMap
impl UnsafeUnpin 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