Struct async_rustbus::rustbus_core::path::ObjectPath[][src]

pub struct ObjectPath { /* fields omitted */ }

A slice of a Dbus object path akin to a str or std::path::Path.

Contains some methods for manipulating Dbus object paths, similiar to std::path::Path with some minor differences.

Implementations

impl ObjectPath[src]

pub fn from_path<P: AsRef<Path> + ?Sized>(
    p: &P
) -> Result<&ObjectPath, InvalidObjectPath>
[src]

Validate and make a ObjectPath from a normal path.

See module root for the rules of a valid ObjectPath.

Examples

use async_rustbus::rustbus_core::path::ObjectPath;
let path = ObjectPath::from_str("/example/path").unwrap();
ObjectPath::from_str("invalid/because/not/absolute").unwrap_err();
ObjectPath::from_str("/invalid/because//double/sep").unwrap_err();

pub fn from_str(s: &str) -> Result<&ObjectPath, InvalidObjectPath>[src]

pub fn as_bytes(&self) -> &[u8][src]

Get the bytes that make up an ObjectPath.

pub fn as_str(&self) -> &str[src]

Get the ObjectPath as a &str.

Unlike ordinary std::path::Path, ObjectPaths are always valid Rust strs making this possible.

pub fn strip_prefix<P: AsRef<Path> + ?Sized>(
    &self,
    p: &P
) -> Result<&ObjectPath, StripPrefixError>
[src]

Strip the prefix of the ObjectPath.

Unlike Path::strip_prefix this method will always leave the path will always remain absolute.

Examples

use async_rustbus::rustbus_core::path::ObjectPath;
let original  = ObjectPath::from_str("/example/path/to_strip").unwrap();
let target = ObjectPath::from_str("/path/to_strip").unwrap();
/* These two lines are equivelent because paths must always remain absolute,
   so the root '/' is readded in the second example.
   Note the second line is not a valid ObjectPath */
let stripped0 = original.strip_prefix("/example").unwrap();
let stripped1 = original.strip_prefix("/example/").unwrap();
assert_eq!(stripped0, target);
assert_eq!(stripped1, target);

original.strip_prefix("/example/other").unwrap_err();
original.strip_prefix("/example/pa").unwrap_err();

// Because the only thing stripped is the root sep this does nothing as it gets readded.
let stripped2 = original.strip_prefix("/").unwrap();
assert_eq!(stripped2, original);
let stripped3 = original.strip_prefix(original).unwrap();
assert_eq!(stripped3, ObjectPath::root_path());

pub fn parent(&self) -> Option<&ObjectPath>[src]

Get the parent of the ObjectPath by removing the last element. If the ObjectPath is a root path then None is returned.

pub fn file_name(&self) -> Option<&str>[src]

Retrieves the last element of the ObjectPath. If the ObjectPath is a root path then None is returned.

pub fn root_path() -> &'static Self[src]

Return a ObjectPath consisting of a single / seperator.

pub fn components(&self) -> impl Iterator<Item = &str>[src]

Returns an Iterator over the elements of an ObjectPath.

pub fn to_object_path_buf(&self) -> ObjectPathBuf[src]

Trait Implementations

impl AsRef<ObjectPath> for ObjectPath[src]

impl AsRef<ObjectPath> for ObjectPathBuf[src]

impl AsRef<OsStr> for ObjectPath[src]

impl AsRef<Path> for ObjectPath[src]

impl AsRef<str> for ObjectPath[src]

impl Borrow<ObjectPath> for ObjectPathBuf[src]

impl Borrow<Path> for ObjectPath[src]

impl Debug for ObjectPath[src]

impl Deref for ObjectPath[src]

type Target = Path

The resulting type after dereferencing.

impl Display for ObjectPath[src]

impl From<&'_ ObjectPath> for ObjectPathBuf[src]

impl<'a> From<&'a ObjectPath> for &'a str[src]

impl Hash for ObjectPath[src]

impl Marshal for &ObjectPath[src]

impl Ord for ObjectPath[src]

impl PartialEq<ObjectPath> for ObjectPath[src]

impl PartialEq<ObjectPath> for ObjectPathBuf[src]

impl PartialOrd<ObjectPath> for ObjectPath[src]

impl Signature for &ObjectPath[src]

impl ToOwned for ObjectPath[src]

type Owned = ObjectPathBuf

The resulting type after obtaining ownership.

impl<'a> TryFrom<&'a Path> for &'a ObjectPath[src]

type Error = InvalidObjectPath

The type returned in the event of a conversion error.

impl<'a> TryFrom<&'a str> for &'a ObjectPath[src]

type Error = InvalidObjectPath

The type returned in the event of a conversion error.

impl<'buf, 'fds> Unmarshal<'buf, 'fds> for &'buf ObjectPath[src]

impl Eq for ObjectPath[src]

impl StructuralEq for ObjectPath[src]

impl StructuralPartialEq for ObjectPath[src]

Auto Trait Implementations

impl RefUnwindSafe for ObjectPath

impl Send for ObjectPath

impl !Sized for ObjectPath

impl Sync for ObjectPath

impl Unpin for ObjectPath

impl UnwindSafe for ObjectPath

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]