pub struct Path<State: PathState> { /* private fields */ }Available on
Linux only.Implementations§
Source§impl Path<Abs>
impl Path<Abs>
pub fn root() -> &'static Path<Abs>
pub fn read_all_links(&self) -> Result<OwnedPath<Abs>, RawOsError>
pub fn normalize_lexically(&self) -> OwnedPath<Abs>
pub fn make_relative<P: AsRef<Path<Abs>>>(&self, from: P) -> OwnedPath<Rel>
pub fn metadata(&self) -> Result<Metadata, PathOrMetadataError>
pub fn metadata_no_follow(&self) -> Result<Metadata, PathOrMetadataError>
Source§impl<S: PathState> Path<S>
impl<S: PathState> Path<S>
pub fn new<'a, O: AsRef<OsStr> + ?Sized>(value: &'a O) -> Cow<'a, Path<S>>
pub fn from_checked<O: AsRef<OsStr> + ?Sized>(value: &O) -> Option<&Path<S>>
pub unsafe fn from_unchecked<O: AsRef<OsStr> + ?Sized>(value: &O) -> &Self
pub unsafe fn from_unchecked_mut<O: AsMut<OsStr> + ?Sized>( value: &mut O, ) -> &mut Self
pub const fn display<'a>(&'a self) -> DisplayPath<'a, S>
pub fn len(&self) -> NonZero<usize>
pub const fn as_os_str(&self) -> &OsStr
pub fn as_os_str_no_lead(&self) -> &OsStr
pub fn as_bytes(&self) -> &[u8] ⓘ
Sourcepub fn basename(&self) -> &OsStr
pub fn basename(&self) -> &OsStr
Returns the basename of this path (the OsStr following the last / in the path). This OsStr
won’t contain any instances of /.
See parent() for more info.
Sourcepub fn parent(&self) -> &Self
pub fn parent(&self) -> &Self
Returns the parent directory of this path (lexically speaking). The result is a Path with
basename and the preceding slash removed, such that the following holds for any path.
let owned = OwnedPath::<Abs>::from("/my/path");
let path: &Path<Abs> = &owned;
let new_path = path.parent().join(Path::new(path.basename()));
assert_eq!(path, new_path);Because this method is the counterpart of basename and basename won’t
contain any /, the behavior when calling these methods on "/" is as follows:
assert_eq!(Path::root().basename(), "");
assert_eq!(Path::root().parent(), Path::root());This behavior is also consistent with Unix defaults: the .. entry in the root directory
refers to the root itself.
pub fn join<P: AsRef<Path<Rel>>>(&self, other: P) -> OwnedPath<S>
pub fn relative_to(&self, other: &Self) -> Option<&Path<Rel>>
Sourcepub fn components<'a>(&'a self) -> Components<'a, S> ⓘ
pub fn components<'a>(&'a self) -> Components<'a, S> ⓘ
Creates an Iterator over the components of a Path. This iterator produces Path<Rel>s
representing each /-separated string in the Path, from left to right.