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]
impl ObjectPath
[src]pub fn from_path<P: AsRef<Path> + ?Sized>(
p: &P
) -> Result<&ObjectPath, InvalidObjectPath>
[src]
p: &P
) -> Result<&ObjectPath, InvalidObjectPath>
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
, ObjectPath
s are always valid Rust str
s making this possible.
pub fn strip_prefix<P: AsRef<Path> + ?Sized>(
&self,
p: &P
) -> Result<&ObjectPath, StripPrefixError>
[src]
&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());
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 ObjectPath
[src]fn as_ref(&self) -> &ObjectPath
[src]
impl AsRef<ObjectPath> for ObjectPathBuf
[src]
impl AsRef<ObjectPath> for ObjectPathBuf
[src]fn as_ref(&self) -> &ObjectPath
[src]
impl Borrow<ObjectPath> for ObjectPathBuf
[src]
impl Borrow<ObjectPath> for ObjectPathBuf
[src]fn borrow(&self) -> &ObjectPath
[src]
impl Deref for ObjectPath
[src]
impl Deref for ObjectPath
[src]impl From<&'_ ObjectPath> for ObjectPathBuf
[src]
impl From<&'_ ObjectPath> for ObjectPathBuf
[src]fn from(path: &ObjectPath) -> Self
[src]
impl<'a> From<&'a ObjectPath> for &'a str
[src]
impl<'a> From<&'a ObjectPath> for &'a str
[src]fn from(path: &'a ObjectPath) -> Self
[src]
impl Hash for ObjectPath
[src]
impl Hash for ObjectPath
[src]impl Marshal for &ObjectPath
[src]
impl Marshal for &ObjectPath
[src]fn marshal(&self, ctx: &mut MarshalContext<'_, '_>) -> Result<(), Error>
[src]
pub fn marshal_as_variant(
&self,
ctx: &mut MarshalContext<'_, '_>
) -> Result<(), Error>
[src]
&self,
ctx: &mut MarshalContext<'_, '_>
) -> Result<(), Error>
impl Ord for ObjectPath
[src]
impl Ord for ObjectPath
[src]impl PartialEq<ObjectPath> for ObjectPath
[src]
impl PartialEq<ObjectPath> for ObjectPath
[src]fn eq(&self, other: &ObjectPath) -> bool
[src]
fn ne(&self, other: &ObjectPath) -> bool
[src]
impl PartialEq<ObjectPath> for ObjectPathBuf
[src]
impl PartialEq<ObjectPath> for ObjectPathBuf
[src]impl PartialOrd<ObjectPath> for ObjectPath
[src]
impl PartialOrd<ObjectPath> for ObjectPath
[src]impl Signature for &ObjectPath
[src]
impl Signature for &ObjectPath
[src]impl ToOwned for ObjectPath
[src]
impl ToOwned for ObjectPath
[src]type Owned = ObjectPathBuf
The resulting type after obtaining ownership.
fn to_owned(&self) -> Self::Owned
[src]
pub fn clone_into(&self, target: &mut Self::Owned)
[src]
impl<'a> TryFrom<&'a Path> for &'a ObjectPath
[src]
impl<'a> TryFrom<&'a Path> for &'a ObjectPath
[src]impl<'a> TryFrom<&'a str> for &'a ObjectPath
[src]
impl<'a> TryFrom<&'a str> for &'a ObjectPath
[src]impl<'buf, 'fds> Unmarshal<'buf, 'fds> for &'buf ObjectPath
[src]
impl<'buf, 'fds> Unmarshal<'buf, 'fds> for &'buf ObjectPath
[src]