pub struct RepoPathBuf { /* private fields */ }
Expand description
Owned repository path.
Implementations§
Source§impl RepoPathBuf
impl RepoPathBuf
Sourcepub fn from_internal_string(
value: impl Into<String>,
) -> Result<Self, InvalidNewRepoPathError>
pub fn from_internal_string( value: impl Into<String>, ) -> Result<Self, InvalidNewRepoPathError>
Creates RepoPathBuf
from valid string representation.
Sourcepub fn from_relative_path(
relative_path: impl AsRef<Path>,
) -> Result<Self, RelativePathParseError>
pub fn from_relative_path( relative_path: impl AsRef<Path>, ) -> Result<Self, RelativePathParseError>
Converts repo-relative Path
to RepoPathBuf
.
The input path should not contain redundant .
or ..
.
Sourcepub fn parse_fs_path(
cwd: &Path,
base: &Path,
input: impl AsRef<Path>,
) -> Result<Self, FsPathParseError>
pub fn parse_fs_path( cwd: &Path, base: &Path, input: impl AsRef<Path>, ) -> Result<Self, FsPathParseError>
Parses an input
path into a RepoPathBuf
relative to base
.
The cwd
and base
paths are supposed to be absolute and normalized in
the same manner. The input
path may be either relative to cwd
or
absolute.
Sourcepub fn into_internal_string(self) -> String
pub fn into_internal_string(self) -> String
Consumes this and returns the underlying string representation.
Methods from Deref<Target = RepoPath>§
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 Clone for RepoPathBuf
impl Clone for RepoPathBuf
Source§fn clone(&self) -> RepoPathBuf
fn clone(&self) -> RepoPathBuf
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl ContentHash for RepoPathBuf
impl ContentHash for RepoPathBuf
Source§impl Debug for RepoPathBuf
impl Debug for RepoPathBuf
Source§impl Deref for RepoPathBuf
impl Deref for RepoPathBuf
Source§impl<P: AsRef<RepoPathComponent>> Extend<P> for RepoPathBuf
impl<P: AsRef<RepoPathComponent>> Extend<P> for RepoPathBuf
Source§fn extend<T: IntoIterator<Item = P>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = P>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl Hash for RepoPathBuf
impl Hash for RepoPathBuf
Source§impl Ord for RepoPathBuf
impl Ord for RepoPathBuf
Source§impl PartialEq for RepoPathBuf
impl PartialEq for RepoPathBuf
Source§impl PartialOrd for RepoPathBuf
impl PartialOrd for RepoPathBuf
Source§impl Serialize for RepoPathBuf
impl Serialize for RepoPathBuf
impl Eq for RepoPathBuf
impl StructuralPartialEq for RepoPathBuf
Auto Trait Implementations§
impl Freeze for RepoPathBuf
impl RefUnwindSafe for RepoPathBuf
impl Send for RepoPathBuf
impl Sync for RepoPathBuf
impl Unpin for RepoPathBuf
impl UnwindSafe for RepoPathBuf
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§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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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