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<Path, ParseError>
pub fn new(path: impl AsRef<str>) -> Result<Path, 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.
Sourcepub fn split(&self) -> Vec<BoundedName<cm_types::::Name::{constant#0}>>
pub fn split(&self) -> Vec<BoundedName<cm_types::::Name::{constant#0}>>
Splits the path according to “/”.
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) -> &BoundedName<cm_types::::Name::{constant#0}>
pub fn extend(&mut self, other: RelativePath)
pub fn push(&mut self, other: BoundedName<cm_types::::Name::{constant#0}>)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Path
impl<'de> Deserialize<'de> for Path
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Path, <D as Deserializer<'de>>::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§fn from(value: Path) -> NamespacePath
fn from(value: Path) -> NamespacePath
Converts to this type from the input type.
Source§impl IterablePath for Path
impl IterablePath for Path
Source§fn iter_segments(&self) -> impl DoubleEndedIterator + Send
fn iter_segments(&self) -> impl DoubleEndedIterator + Send
Returns a double-sided iterator over the segments in this path.
Source§impl NativeIntoFidl<String> for Path
impl NativeIntoFidl<String> for Path
fn native_into_fidl(self) -> String
Source§impl Ord for Path
impl Ord for Path
Source§impl PartialOrd for Path
impl PartialOrd for Path
Source§impl Serialize for Path
impl Serialize for Path
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
)Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.