pub struct RepoPath { /* private fields */ }
Expand description
Borrowed repository path.
Implementations§
Source§impl RepoPath
impl RepoPath
Sourcepub fn from_internal_string(value: &str) -> &Self
pub fn from_internal_string(value: &str) -> &Self
Wraps valid string representation as RepoPath
.
The input value
must not contain empty path components. 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.