Struct RepoPath

Source
pub struct RepoPath { /* private fields */ }
Expand description

Borrowed repository path.

Implementations§

Source§

impl RepoPath

Source

pub const fn root() -> &'static Self

Returns repository path pointing to the root.

Source

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.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn is_root(&self) -> bool

Source

pub fn starts_with(&self, base: &RepoPath) -> bool

Returns true if the base is a prefix of this path.

Source

pub fn strip_prefix(&self, base: &RepoPath) -> Option<&RepoPath>

Returns the remaining path with the base path removed.

Source

pub fn parent(&self) -> Option<&RepoPath>

Returns the parent path without the base name component.

Source

pub fn split(&self) -> Option<(&RepoPath, &RepoPathComponent)>

Splits this into the parent path and base name component.

Source

pub fn components(&self) -> RepoPathComponentsIter<'_>

Source

pub fn ancestors(&self) -> impl Iterator<Item = &RepoPath>

Source

pub fn join(&self, entry: &RepoPathComponent) -> RepoPathBuf

Trait Implementations§

Source§

impl AsRef<RepoPath> for RepoPath

Source§

fn as_ref(&self) -> &RepoPath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<RepoPath> for RepoPathBuf

Source§

fn as_ref(&self) -> &RepoPath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<RepoPath> for RepoPathBuf

Source§

fn borrow(&self) -> &RepoPath

Immutably borrows from an owned value. Read more
Source§

impl ContentHash for RepoPath

Source§

fn hash(&self, state: &mut impl Update)

Update the hasher state with this object’s content
Source§

impl Debug for RepoPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for RepoPath

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
Source§

impl Ord for RepoPath

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for RepoPath

Source§

fn eq(&self, other: &RepoPath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for RepoPath

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ToOwned for RepoPath

Source§

type Owned = RepoPathBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for RepoPath

Source§

impl StructuralPartialEq for RepoPath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more