pub struct NamespacePath(/* private fields */);
Expand description
NamespacePath is the same as Path but accepts "/"
(which is also a valid namespace
path).
Note that while "/"
is accepted, "."
(which is synonymous in fuchsia.io) is rejected.
Implementations§
Source§impl NamespacePath
impl NamespacePath
Sourcepub fn new(path: impl AsRef<str>) -> Result<NamespacePath, ParseError>
pub fn new(path: impl AsRef<str>) -> Result<NamespacePath, ParseError>
Like Path::new but path
may be /
.
Sourcepub fn root() -> NamespacePath
pub fn root() -> NamespacePath
Returns the NamespacePath for "/"
.
pub fn is_root(&self) -> bool
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) -> Option<NamespacePath>
pub fn parent(&self) -> Option<NamespacePath>
Returns a path that represents the parent directory of this one, or None if this is a root dir.
Sourcepub fn has_prefix(&self, prefix: &NamespacePath) -> bool
pub fn has_prefix(&self, prefix: &NamespacePath) -> bool
Returns whether prefix
is a prefix of self
in terms of path segments.
For example:
Path("/pkg/data").has_prefix("/pkg") == true
Path("/pkg_data").has_prefix("/pkg") == false
Sourcepub fn basename(&self) -> Option<&BoundedName<cm_types::::Name::{constant#0}>>
pub fn basename(&self) -> Option<&BoundedName<cm_types::::Name::{constant#0}>>
The last path segment, or None.
pub fn pop_front( &mut self, ) -> Option<BoundedName<cm_types::::Name::{constant#0}>>
Trait Implementations§
Source§impl Clone for NamespacePath
impl Clone for NamespacePath
Source§fn clone(&self) -> NamespacePath
fn clone(&self) -> NamespacePath
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NamespacePath
impl Debug for NamespacePath
Source§impl Display for NamespacePath
impl Display for NamespacePath
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 FromStr for NamespacePath
impl FromStr for NamespacePath
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
Source§fn from_str(
path: &str,
) -> Result<NamespacePath, <NamespacePath as FromStr>::Err>
fn from_str( path: &str, ) -> Result<NamespacePath, <NamespacePath as FromStr>::Err>
Parses a string
s
to return a value of this type. Read moreSource§impl Hash for NamespacePath
impl Hash for NamespacePath
Source§impl IterablePath for NamespacePath
impl IterablePath for NamespacePath
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 Ord for NamespacePath
impl Ord for NamespacePath
Source§fn cmp(&self, other: &NamespacePath) -> Ordering
fn cmp(&self, other: &NamespacePath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for NamespacePath
impl PartialEq for NamespacePath
Source§impl PartialOrd for NamespacePath
impl PartialOrd for NamespacePath
Source§impl Serialize for NamespacePath
impl Serialize for NamespacePath
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
Source§impl TryFrom<CString> for NamespacePath
impl TryFrom<CString> for NamespacePath
Source§type Error = ParseError
type Error = ParseError
The type returned in the event of a conversion error.
Source§fn try_from(path: CString) -> Result<NamespacePath, ParseError>
fn try_from(path: CString) -> Result<NamespacePath, ParseError>
Performs the conversion.
impl Eq for NamespacePath
impl StructuralPartialEq for NamespacePath
Auto Trait Implementations§
impl Freeze for NamespacePath
impl RefUnwindSafe for NamespacePath
impl Send for NamespacePath
impl Sync for NamespacePath
impl Unpin for NamespacePath
impl UnwindSafe for NamespacePath
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.