Struct tokio_dbus::ObjectPath
source · pub struct ObjectPath(/* private fields */);
Expand description
A validated object path.
The following rules define a valid object path. Implementations must not send or accept messages with invalid object paths.
- The path may be of any length.
- The path must begin with an ASCII ‘/’ (integer 47) character, and must consist of elements separated by slash characters.
- Each element must only contain the ASCII characters “[A-Z][a-z][0-9]_”
- No element may be the empty string.
- Multiple ‘/’ characters cannot occur in sequence.
- A trailing ‘/’ character is not allowed unless the path is the root path (a single ‘/’ character).
Implementations§
source§impl ObjectPath
impl ObjectPath
sourcepub const ROOT: &'static Self = _
pub const ROOT: &'static Self = _
The special "/"
object path.
§Examples
use tokio_dbus::ObjectPath;
assert_eq!(ObjectPath::ROOT, ObjectPath::new(b"/")?);
sourcepub const fn new_const(path: &[u8]) -> &Self
pub const fn new_const(path: &[u8]) -> &Self
Construct a new object path.
§Panics
Panics if the argument is not a valid object.
See ObjectPath
for more information.
sourcepub fn new<P>(path: &P) -> Result<&Self, ObjectPathError>
pub fn new<P>(path: &P) -> Result<&Self, ObjectPathError>
Construct a new validated object path.
§Errors
Errors if the argument is not a valid object.
See ObjectPath
for more information.
sourcepub fn iter(&self) -> Iter<'_>
pub fn iter(&self) -> Iter<'_>
Construct an iterator over the object path.
§Examples
use tokio_dbus::ObjectPath;
let mut it = ObjectPath::new_const(b"/").iter();
assert!(it.next().is_none());
let mut it = ObjectPath::new_const(b"/foo").iter();
assert_eq!(it.next(), Some("foo"));
assert!(it.next().is_none());
let mut it = ObjectPath::new_const(b"/foo/bar").iter();
assert_eq!(it.next_back(), Some("bar"));
assert_eq!(it.next(), Some("foo"));
assert!(it.next().is_none());
sourcepub fn starts_with(&self, other: &ObjectPath) -> bool
pub fn starts_with(&self, other: &ObjectPath) -> bool
Test if one part starts with another.
§Examples
use tokio_dbus::ObjectPath;
const FOO: &ObjectPath = ObjectPath::new_const(b"/foo");
const FOO_BAR: &ObjectPath = ObjectPath::new_const(b"/foo/bar");
assert!(FOO_BAR.starts_with(FOO));
Trait Implementations§
source§impl AsRef<[u8]> for ObjectPath
impl AsRef<[u8]> for ObjectPath
source§impl AsRef<ObjectPath> for ObjectPath
impl AsRef<ObjectPath> for ObjectPath
source§fn as_ref(&self) -> &ObjectPath
fn as_ref(&self) -> &ObjectPath
Converts this type into a shared reference of the (usually inferred) input type.
source§impl AsRef<ObjectPath> for ObjectPathBuf
impl AsRef<ObjectPath> for ObjectPathBuf
source§fn as_ref(&self) -> &ObjectPath
fn as_ref(&self) -> &ObjectPath
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Borrow<ObjectPath> for ObjectPathBuf
impl Borrow<ObjectPath> for ObjectPathBuf
source§fn borrow(&self) -> &ObjectPath
fn borrow(&self) -> &ObjectPath
Immutably borrows from an owned value. Read more
source§impl Clone for Box<ObjectPath>
impl Clone for Box<ObjectPath>
source§impl Debug for ObjectPath
impl Debug for ObjectPath
source§impl Display for ObjectPath
impl Display for ObjectPath
source§impl From<&ObjectPath> for Box<ObjectPath>
impl From<&ObjectPath> for Box<ObjectPath>
source§fn from(object_path: &ObjectPath) -> Self
fn from(object_path: &ObjectPath) -> Self
Converts to this type from the input type.
source§impl<'a> IntoIterator for &'a ObjectPath
impl<'a> IntoIterator for &'a ObjectPath
The IntoIterator
implementation for ObjectPath
.
§Examples
use tokio_dbus::ObjectPath;
const PATH: &ObjectPath = ObjectPath::new_const(b"/foo/bar");
let mut values = Vec::new();
for s in PATH {
values.push(s);
}
assert_eq!(values, ["foo", "bar"]);
source§impl PartialEq for ObjectPath
impl PartialEq for ObjectPath
source§fn eq(&self, other: &ObjectPath) -> bool
fn eq(&self, other: &ObjectPath) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl ToOwned for ObjectPath
impl ToOwned for ObjectPath
§type Owned = ObjectPathBuf
type Owned = ObjectPathBuf
The resulting type after obtaining ownership.
source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
impl Arguments for ObjectPath
impl Eq for ObjectPath
impl Read for ObjectPath
impl Storable for &ObjectPath
Storable
implementation for &ObjectPath
.
§Examples
use tokio_dbus::BodyBuf;
use tokio_dbus::ObjectPath;
let mut body = BodyBuf::new();
body.store(10u16)?;
body.store(ObjectPath::new("/se/tedro/DBusExample")?)?;
assert_eq!(body.signature(), "qo");