pub struct ResourceDef { /* private fields */ }Expand description
ResourceDef describes an entry in resources table
A resource definition can have several path patterns, a path matches the
resource if it matches any of them. The first pattern is the primary one,
it is used by pattern() and for building resource paths.
Implementations§
Source§impl ResourceDef
impl ResourceDef
Sourcepub fn new<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
pub fn new<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
Parse path patterns and create new ResourceDef instance.
Path segments are separated by /, a leading / is optional. Static
segments could be case insensitive.
Panics if path pattern is malformed.
Sourcepub fn prefix<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
pub fn prefix<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
Parse path patterns and create new prefix ResourceDef instance.
A prefix resource matches paths that start with one of its patterns.
Panics if path pattern is malformed.
Sourcepub fn root_prefix<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
pub fn root_prefix<T>(path: T) -> ResourceDefwhere
T: IntoPattern,
Parse path patterns and create new prefix ResourceDef instance.
Same as prefix(), but inserts / to the start of
the patterns that do not have it.
Panics if path pattern is malformed.
Sourcepub fn id(&self) -> u16
pub fn id(&self) -> u16
Resource id, 0 by default
A matched resource is reported with this id, see
ResourceId.
Sourcepub fn build_path<U, I>(&self, path: &mut String, elements: U) -> bool
pub fn build_path<U, I>(&self, path: &mut String, elements: U) -> bool
Build resource path from elements, using the primary pattern.
Elements are used for dynamic segments in pattern order, an iterator
can be passed by &mut to continue using it afterwards. The path is
appended to path. Returns false if there are not enough elements,
path is left unchanged then.
Sourcepub fn build_path_named<K, V, S>(
&self,
path: &mut String,
elements: &HashMap<K, V, S>,
) -> bool
pub fn build_path_named<K, V, S>( &self, path: &mut String, elements: &HashMap<K, V, S>, ) -> bool
Build resource path from named elements, using the primary pattern.
The path is appended to path. Returns false if an element is
missing, path is left unchanged then.
Trait Implementations§
Source§impl Clone for ResourceDef
impl Clone for ResourceDef
Source§fn clone(&self) -> ResourceDef
fn clone(&self) -> ResourceDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceDef
impl Debug for ResourceDef
impl Eq for ResourceDef
Source§impl<'a> From<&'a str> for ResourceDef
impl<'a> From<&'a str> for ResourceDef
Source§fn from(path: &'a str) -> ResourceDef
fn from(path: &'a str) -> ResourceDef
Source§impl From<&String> for ResourceDef
impl From<&String> for ResourceDef
Source§fn from(path: &String) -> ResourceDef
fn from(path: &String) -> ResourceDef
Source§impl From<String> for ResourceDef
impl From<String> for ResourceDef
Source§fn from(path: String) -> ResourceDef
fn from(path: String) -> ResourceDef
Source§impl<T> From<Vec<T>> for ResourceDef
impl<T> From<Vec<T>> for ResourceDef
Source§fn from(paths: Vec<T>) -> ResourceDef
fn from(paths: Vec<T>) -> ResourceDef
Source§impl<T, const N: usize> From<[T; N]> for ResourceDef
impl<T, const N: usize> From<[T; N]> for ResourceDef
Source§fn from(paths: [T; N]) -> ResourceDef
fn from(paths: [T; N]) -> ResourceDef
Source§impl Hash for ResourceDef
impl Hash for ResourceDef
Auto Trait Implementations§
impl Freeze for ResourceDef
impl RefUnwindSafe for ResourceDef
impl Send for ResourceDef
impl Sync for ResourceDef
impl Unpin for ResourceDef
impl UnsafeUnpin for ResourceDef
impl UnwindSafe for ResourceDef
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.