pub struct Path(/* private fields */);
Expand description
A path type used throughout Component Framework, along with its variants NamespacePath and RelativePath. Examples of use:
- NamespacePath: Namespace paths
- Path: Outgoing paths and namespace paths that can’t be “/”
- RelativePath: Dictionary paths
Path obeys the following constraints:
- Is a fuchsia.io.Path.
- Begins with
/
. - Is not
.
. - Contains at least one path segment (just
/
is disallowed). - Each path segment is a Name. (This is strictly more constrained than a fuchsia.io path segment.)
Implementations§
Source§impl Path
impl Path
Sourcepub fn new(path: impl AsRef<str>) -> Result<Self, ParseError>
pub fn new(path: impl AsRef<str>) -> Result<Self, ParseError>
Creates a Path
from a String
, returning an Err
if the string fails validation.
The string must be non-empty, no more than MAX_PATH_LENGTH
bytes in length, start with
a leading /
, not be exactly /
or .
, and each segment must be a valid Name
. As a
result, Path
s are always valid NamespacePath
s.
pub fn to_path_buf(&self) -> PathBuf
Sourcepub fn parent(&self) -> NamespacePath
pub fn parent(&self) -> NamespacePath
Returns a path that represents the parent directory of this one. Returns NamespacePath instead of Path because the parent could be the root dir.
pub fn basename(&self) -> &Name
pub fn extend(&mut self, other: RelativePath)
pub fn push(&mut self, other: Name)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
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
Source§impl From<Path> for NamespacePath
impl From<Path> for NamespacePath
Source§impl IterablePath for Path
impl IterablePath for Path
Source§fn iter_segments(&self) -> impl DoubleEndedIterator<Item = &Name> + Send
fn iter_segments(&self) -> impl DoubleEndedIterator<Item = &Name> + Send
Returns a double-sided iterator over the segments in this path.
Source§impl Ord for Path
impl Ord for Path
Source§impl PartialOrd for Path
impl PartialOrd for Path
Source§impl TryFrom<CString> for Path
impl TryFrom<CString> for Path
Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
impl Eq for Path
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)