pub struct RepoPath { /* private fields */ }
Expand description
Borrowed repository path.
Implementations§
Source§impl RepoPath
impl RepoPath
Sourcepub fn from_internal_string(
value: &str,
) -> Result<&Self, InvalidNewRepoPathError>
pub fn from_internal_string( value: &str, ) -> Result<&Self, InvalidNewRepoPathError>
Wraps valid string representation as RepoPath
.
Returns an error if the input value
contains empty path component. For
example, "/"
, "/foo"
, "foo/"
, "foo//bar"
are all invalid.
Sourcepub fn to_internal_dir_string(&self) -> String
pub fn to_internal_dir_string(&self) -> String
The full string form used internally, not for presenting to users (where we may want to use the platform’s separator). This format includes a trailing slash, unless this path represents the root directory. That way it can be concatenated with a basename and produce a valid path.
Sourcepub fn as_internal_file_string(&self) -> &str
pub fn as_internal_file_string(&self) -> &str
The full string form used internally, not for presenting to users (where we may want to use the platform’s separator).
Sourcepub fn to_fs_path(&self, base: &Path) -> Result<PathBuf, InvalidRepoPathError>
pub fn to_fs_path(&self, base: &Path) -> Result<PathBuf, InvalidRepoPathError>
Converts repository path to filesystem path relative to the base
.
The returned path should never contain ..
, C:
(on Windows), etc.
However, it may contain reserved working-copy directories such as .jj
.
Sourcepub fn to_fs_path_unchecked(&self, base: &Path) -> PathBuf
pub fn to_fs_path_unchecked(&self, base: &Path) -> PathBuf
Converts repository path to filesystem path relative to the base
,
without checking invalid path components.
The returned path may point outside of the base
directory. Use this
function only for displaying or testing purposes.
pub fn is_root(&self) -> bool
Sourcepub fn starts_with(&self, base: &RepoPath) -> bool
pub fn starts_with(&self, base: &RepoPath) -> bool
Returns true if the base
is a prefix of this path.
Sourcepub fn strip_prefix(&self, base: &RepoPath) -> Option<&RepoPath>
pub fn strip_prefix(&self, base: &RepoPath) -> Option<&RepoPath>
Returns the remaining path with the base
path removed.
Sourcepub fn parent(&self) -> Option<&RepoPath>
pub fn parent(&self) -> Option<&RepoPath>
Returns the parent path without the base name component.
Sourcepub fn split(&self) -> Option<(&RepoPath, &RepoPathComponent)>
pub fn split(&self) -> Option<(&RepoPath, &RepoPathComponent)>
Splits this into the parent path and base name component.
pub fn components(&self) -> RepoPathComponentsIter<'_> ⓘ
pub fn ancestors(&self) -> impl Iterator<Item = &RepoPath>
pub fn join(&self, entry: &RepoPathComponent) -> RepoPathBuf
Trait Implementations§
Source§impl AsRef<RepoPath> for RepoPathBuf
impl AsRef<RepoPath> for RepoPathBuf
Source§impl Borrow<RepoPath> for RepoPathBuf
impl Borrow<RepoPath> for RepoPathBuf
Source§impl ContentHash for RepoPath
impl ContentHash for RepoPath
Source§impl PartialOrd for RepoPath
impl PartialOrd for RepoPath
Source§impl ToOwned for RepoPath
impl ToOwned for RepoPath
Source§type Owned = RepoPathBuf
type Owned = RepoPathBuf
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
impl Eq for RepoPath
impl StructuralPartialEq for RepoPath
Auto Trait Implementations§
impl Freeze for RepoPath
impl RefUnwindSafe for RepoPath
impl Send for RepoPath
impl !Sized for RepoPath
impl Sync for RepoPath
impl Unpin for RepoPath
impl UnwindSafe for RepoPath
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<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§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.