pub struct FsPath(/* private fields */);Expand description
Forward-slash separated literal filesystem path.
Always uses / regardless of host OS. std::fs::* accepts /-paths on
both Unix and Windows, so no boundary conversion is needed in the client
layer.
Implementations§
Source§impl FsPath
impl FsPath
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Returns the underlying String.
Sourcepub fn join(&self, segment: &str) -> Self
pub fn join(&self, segment: &str) -> Self
Returns a new path with segment appended after a /
separator.
If self is empty the result is segment alone (no leading
/). Trailing / in self is normalized.
Sourcepub fn push(&mut self, segment: &str)
pub fn push(&mut self, segment: &str)
Appends segment to this path in place, inserting a /
separator unless self is empty or already ends with one.
Sourcepub fn with_file_name(&self, name: &str) -> Self
pub fn with_file_name(&self, name: &str) -> Self
Replaces the final component of this path with name.
If self has no parent, the result is name alone.
Sourcepub fn strip_prefix(&self, prefix: &Self) -> Option<&str>
pub fn strip_prefix(&self, prefix: &Self) -> Option<&str>
If self is rooted at prefix, returns the relative remainder
(without leading /).
Sourcepub fn starts_with(&self, prefix: &Self) -> bool
pub fn starts_with(&self, prefix: &Self) -> bool
Returns true when this path begins with prefix.
Sourcepub fn components(&self) -> impl Iterator<Item = &str>
pub fn components(&self) -> impl Iterator<Item = &str>
Iterates over the non-empty components of this path.