pub struct Path { /* private fields */ }
Implementations§
source§impl Path
impl Path
sourcepub fn dot() -> Path
pub fn dot() -> Path
Returns a path for dot, i.e. the current directory. The next
will return None for this
path.
pub fn is_dot(&self) -> bool
sourcepub fn validate_and_split<Source>(path: Source) -> Result<Path, Status>
pub fn validate_and_split<Source>(path: Source) -> Result<Path, Status>
Splits a path
string into components, also checking if it is in a canonical form,
disallowing any “..” components, as well as empty component names. A lone “/” is translated
to “.” (the canonical form).
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
when there are no more components left in this Path
.
sourcepub fn is_dir(&self) -> bool
pub fn is_dir(&self) -> bool
Returns true
if the canonical path contains ‘/’ as the last symbol. Note that is_dir is
false
for “.”, even though a directory is implied. The canonical form for “/” is “.”.
sourcepub fn is_single_component(&self) -> bool
pub fn is_single_component(&self) -> bool
Returns true
when the path contains only one component - that is, it is not empty and
contains no /
characters.
sourcepub fn next(&mut self) -> Option<&str>
pub fn next(&mut self) -> Option<&str>
Returns a reference to a portion of the string that names the next component, and move the
internal pointer to point to the next component. See also Path::peek()
.
Also see Path::next_with_ref()
if you want to use self
while holding a reference to
the returned name.
sourcepub fn next_with_ref(&mut self) -> (&Self, Option<&str>)
pub fn next_with_ref(&mut self) -> (&Self, Option<&str>)
Rust does not allow usage of self
while the returned reference is alive, even when the
reference is actually shared. See, for example,
https://internals.rust-lang.org/t/relaxing-the-borrow-checker-for-fn-mut-self-t/3256
for additional details. So if the caller wants to call any other methods on the path
after calling next()
while still holding a reference to the returned name they can use
this method as a workaround. When Rust is extended to cover this use case, next_with_ref
should be merged into Self::next()
.
sourcepub fn peek(&self) -> Option<&str>
pub fn peek(&self) -> Option<&str>
Returns a reference to a position of the string that names the next component, without
moving the internal pointer. So calling peek()
multiple times in a row would return the
same result. See also Self::next()
.
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Converts this Path
into a String
holding the rest of the path. Note that if there are
no more components, this will return an empty string, which is not a valid path for
fuchsia.io.
sourcepub fn with_prefix(&self, prefix: &Self) -> Self
pub fn with_prefix(&self, prefix: &Self) -> Self
Returns a path with prefix
as a prefix. This will preserve the result of is_dir().
Trait Implementations§
source§impl PartialEq for Path
impl PartialEq for Path
impl Eq for Path
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnwindSafe for Path
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)