pub struct RelPath { /* private fields */ }Expand description
A path below a tree root: /-separated, UTF-8, never absolute and never
leaving the root.
The authority is part of identity, equality and ordering. Its relative text
stays unchanged: RelPath::as_str alone does not identify a source.
Ordinary constructors select the first-party source; RelPath::in_source
explicitly selects another independently rooted authority.
The empty path is the root itself. Empty segments and . segments are
dropped. A .. segment is kept, because on a disk it means the parent of
the directory the earlier segments really reach, which differs from the
lexical parent when one of them is a symlink; it is refused only when the
segments before it do not leave a level to climb out of.
The text is shared, so a clone does not copy it.
Implementations§
Source§impl RelPath
impl RelPath
Sourcepub fn is_canonical(input: &str) -> bool
pub fn is_canonical(input: &str) -> bool
Whether input is already a valid, normalized relative spelling.
Uses the same path checks as Self::new without allocating text,
component storage or diagnostics. The empty spelling is the root;
otherwise empty and . components are noncanonical. A .. component
remains literal and may only spend depth supplied by preceding components.
This query does not inspect the filesystem or select a source authority.
Sourcepub fn join(&self, input: &str) -> Result<Self, PathError>
pub fn join(&self, input: &str) -> Result<Self, PathError>
Append input, which is read as a relative path.
. and empty segments are dropped; .. segments are kept so that the
disk, not the text, decides where they lead.
§Errors
Returns a PathError when the input is absolute, climbs above this
path’s root, or holds a backslash, a NUL or a drive-letter segment.
The independently rooted source of this path.
Sourcepub fn in_source(&self, authority: SourceAuthorityId) -> Self
pub fn in_source(&self, authority: SourceAuthorityId) -> Self
Explicitly select an authority for this same relative spelling.
A load-local handle selects a source; it does not authenticate its bytes. Module traversal never changes authority this way.
Sourcepub fn source_root(&self) -> Self
pub fn source_root(&self) -> Self
The root of this path’s own source authority.
Trait Implementations§
impl Eq for RelPath
Source§impl Ord for RelPath
impl Ord for RelPath
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for RelPath
impl PartialOrd for RelPath
impl StructuralPartialEq for RelPath
Auto Trait Implementations§
impl Forget for RelPath
impl Freeze for RelPath
impl Move for RelPath
impl RefUnwindSafe for RelPath
impl Send for RelPath
impl Sync for RelPath
impl Unpin for RelPath
impl UnsafeUnpin for RelPath
impl UnwindSafe for RelPath
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
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
key and return true if they are equal.impl<T> EvidenceLease for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more