Struct async_rustbus::rustbus_core::path::ObjectPath [−][src]
pub struct ObjectPath { /* fields omitted */ }Expand description
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
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();
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>
pub fn strip_prefix<P: AsRef<Path> + ?Sized>(
&self,
p: &P
) -> Result<&ObjectPath, StripPrefixError>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());
Get the parent of the ObjectPath by removing the last element.
If the ObjectPath is a root path then None is returned.
Retrieves the last element of the ObjectPath.
If the ObjectPath is a root path then None is returned.
Returns an Iterator over the elements of an ObjectPath.
Trait Implementations
Performs the conversion.
Performs the conversion.
Immutably borrows from an owned value. Read more
Performs the conversion.
Performs the conversion.
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
type Owned = ObjectPathBuf
type Owned = ObjectPathBufThe resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Auto Trait Implementations
impl RefUnwindSafe for ObjectPathimpl Send for ObjectPathimpl !Sized for ObjectPathimpl Sync for ObjectPathimpl Unpin for ObjectPathimpl UnwindSafe for ObjectPath