pub struct ResourcePath(/* private fields */);Expand description
A hierarchical path to a resource, similar to Unix file paths.
The only reserved character is /, which separates path segments.
All other UTF-8 characters are allowed. Paths are normalized on creation:
- Leading and trailing slashes are removed
- Consecutive slashes are collapsed to a single slash
- Empty paths become the root path
§Examples
let path = ResourcePath::new("/some/path/to/resource");
assert_eq!(path.segments(), vec!["some", "path", "to", "resource"]);
let root = ResourcePath::new("/");
assert!(root.is_root());Implementations§
Source§impl ResourcePath
impl ResourcePath
pub fn new(path: &str) -> Self
pub fn new_from_segments(segments: &[&str]) -> Self
pub fn pop(&self) -> Self
pub fn is_root(&self) -> bool
pub fn segments(&self) -> Vec<&str>
pub fn is_within(&self, other: &Self) -> bool
pub fn remainder(&self, prefix: &Self) -> Self
pub fn prepend(&self, prefix: &Self) -> Self
Trait Implementations§
Source§impl Clone for ResourcePath
impl Clone for ResourcePath
Source§fn clone(&self) -> ResourcePath
fn clone(&self) -> ResourcePath
Returns a duplicate 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 moreSource§impl Debug for ResourcePath
impl Debug for ResourcePath
Source§impl Hash for ResourcePath
impl Hash for ResourcePath
Source§impl PartialEq for ResourcePath
impl PartialEq for ResourcePath
impl Eq for ResourcePath
impl StructuralPartialEq for ResourcePath
Auto Trait Implementations§
impl Freeze for ResourcePath
impl RefUnwindSafe for ResourcePath
impl Send for ResourcePath
impl Sync for ResourcePath
impl Unpin for ResourcePath
impl UnwindSafe for ResourcePath
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.