pub struct RelPath(/* private fields */);Expand description
A normalised, /-separated path relative to the workspace root.
Guaranteed to be non-empty, to contain no ., .. or empty segments, and to
be relative.
Implementations§
Source§impl RelPath
impl RelPath
Sourcepub fn new(raw: &str) -> Result<Self, PathError>
pub fn new(raw: &str) -> Result<Self, PathError>
Parses and normalises a workspace-relative path.
Accepts either separator, collapses redundant ones, and drops .
segments. Rejects anything that could point outside the workspace.
Sourcepub fn parent(&self) -> Option<RelPath>
pub fn parent(&self) -> Option<RelPath>
The containing directory, or None when this path sits at the workspace
root.
Sourcepub fn join(&self, segment: &str) -> Result<Self, PathError>
pub fn join(&self, segment: &str) -> Result<Self, PathError>
Appends a segment, normalising it in the process.
Sourcepub fn relative_to_dir(&self, dir: Option<&RelPath>) -> String
pub fn relative_to_dir(&self, dir: Option<&RelPath>) -> String
Renders self as a path relative to dir, where None means the
workspace root.
This is what a portable symlink stores: linking .claude/skills to
.agents/skills should record ../.agents/skills, not an absolute path,
so the workspace stays movable.
Sourcepub fn starts_with(&self, other: &RelPath) -> bool
pub fn starts_with(&self, other: &RelPath) -> bool
Whether self is other or lives underneath it.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RelPath
impl<'de> Deserialize<'de> for RelPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for RelPath
impl PartialOrd for RelPath
impl StructuralPartialEq for RelPath
Auto Trait Implementations§
impl Freeze 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
Mutably borrows from an owned value. Read more