[−][src]Struct netidx::path::Path
A path in the namespace. Paths are immutable and reference counted. Path components are seperated by /, which may be escaped with . / and \ are the only special characters in path, any other unicode character may be used. Path lengths are not limited on the local machine, but may be restricted by maximum message size on the wire.
Implementations
impl Path
[src]
pub fn as_chars(self) -> Chars
[src]
pub fn root() -> Path
[src]
returns /
pub fn is_absolute<T: AsRef<str>>(p: T) -> bool
[src]
returns true if the path starts with /, false otherwise
pub fn append<T: AsRef<str>>(&self, other: T) -> Self
[src]
return a new path with the specified string appended as a new part separated by the pathsep char.
Examples
use netidx::path::Path; let p = Path::root().append("bar").append("baz"); assert_eq!(&*p, "/bar/baz"); let p = Path::root().append("/bar").append("//baz//////foo/"); assert_eq!(&*p, "/bar/baz/foo");
pub fn parts(s: &str) -> impl Iterator<Item = &str>
[src]
return an iterator over the parts of the path. The path separator may be escaped with . and a literal \ may be represented as \.
Examples
use netidx::path::Path; let p = Path::from("/foo/bar/baz"); assert_eq!(Path::parts(&p).collect::<Vec<_>>(), vec!["foo", "bar", "baz"]); let p = Path::from(r"/foo\/bar/baz"); assert_eq!(Path::parts(&p).collect::<Vec<_>>(), vec![r"foo\/bar", "baz"]); let p = Path::from(r"/foo\\/bar/baz"); assert_eq!(Path::parts(&p).collect::<Vec<_>>(), vec![r"foo\\", "bar", "baz"]); let p = Path::from(r"/foo\\\/bar/baz"); assert_eq!(Path::parts(&p).collect::<Vec<_>>(), vec![r"foo\\\/bar", "baz"]);
pub fn basenames(s: &str) -> impl Iterator<Item = &str>
[src]
Return an iterator over all the basenames in the path starting from the root and ending with the entire path.
Examples
use netidx::path::Path; let p = Path::from("/some/path/ending/in/foo"); let mut bn = Path::basenames(&p); assert_eq!(bn.next(), Some("/")); assert_eq!(bn.next(), Some("/some")); assert_eq!(bn.next(), Some("/some/path")); assert_eq!(bn.next(), Some("/some/path/ending")); assert_eq!(bn.next(), Some("/some/path/ending/in")); assert_eq!(bn.next(), Some("/some/path/ending/in/foo")); assert_eq!(bn.next(), None);
pub fn levels(s: &str) -> usize
[src]
Return the number of levels in the path.
Examples
use netidx::path::Path; let p = Path::from("/foo/bar/baz"); assert_eq!(Path::levels(&p), 3);
pub fn dirname(s: &str) -> Option<&str>
[src]
return the path without the last part, or return None if the path is empty or /.
Examples
use netidx::path::Path; let p = Path::from("/foo/bar/baz"); assert_eq!(Path::dirname(&p), Some("/foo/bar")); let p = Path::root(); assert_eq!(Path::dirname(&p), None); let p = Path::from("/foo"); assert_eq!(Path::dirname(&p), None);
pub fn basename(s: &str) -> Option<&str>
[src]
return the last part of the path, or return None if the path is empty.
Examples
use netidx::path::Path; let p = Path::from("/foo/bar/baz"); assert_eq!(Path::basename(&p), Some("baz")); let p = Path::from("foo"); assert_eq!(Path::basename(&p), Some("foo")); let p = Path::from("foo/bar"); assert_eq!(Path::basename(&p), Some("bar")); let p = Path::from(""); assert_eq!(Path::basename(&p), None); let p = Path::from("/"); assert_eq!(Path::basename(&p), None);
pub fn rfind_sep(s: &str) -> Option<usize>
[src]
return the position of the last path separator in the path, or None if there isn't one.
Examples
use netidx::path::Path; let p = Path::from("/foo/bar/baz"); assert_eq!(Path::rfind_sep(&p), Some(8)); let p = Path::from(""); assert_eq!(Path::rfind_sep(&p), None);
pub fn find_sep(s: &str) -> Option<usize>
[src]
return the position of the first path separator in the path, or None if there isn't one.
Examples
use netidx::path::Path; let p = Path::from("foo/bar/baz"); assert_eq!(Path::find_sep(&p), Some(3)); let p = Path::from(""); assert_eq!(Path::find_sep(&p), None);
Trait Implementations
impl AsRef<str> for Path
[src]
impl Borrow<str> for Path
[src]
impl Clone for Path
[src]
impl Debug for Path
[src]
impl Deref for Path
[src]
impl Display for Path
[src]
impl Eq for Path
[src]
impl<'a> From<&'a String> for Path
[src]
impl From<&'static str> for Path
[src]
impl From<Chars> for Path
[src]
impl From<String> for Path
[src]
impl FromStr for Path
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Path
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Path
[src]
fn cmp(&self, other: &Path) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Path> for Path
[src]
impl PartialOrd<Path> for Path
[src]
fn partial_cmp(&self, other: &Path) -> Option<Ordering>
[src]
fn lt(&self, other: &Path) -> bool
[src]
fn le(&self, other: &Path) -> bool
[src]
fn gt(&self, other: &Path) -> bool
[src]
fn ge(&self, other: &Path) -> bool
[src]
impl StructuralEq for Path
[src]
impl StructuralPartialEq for Path
[src]
Auto Trait Implementations
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnwindSafe for Path
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,