Skip to main content

ObjectPath

Struct 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

Source

pub const ROOT: &'static Self

The special "/" object path.

§Examples
use tokio_dbus::ObjectPath;

assert_eq!(ObjectPath::ROOT, ObjectPath::new(b"/")?);
Source

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.

Source

pub fn new<P>(path: &P) -> Result<&Self, ObjectPathError>
where P: ?Sized + AsRef<[u8]>,

Construct a new validated object path.

§Errors

Errors if the argument is not a valid object.

See ObjectPath for more information.

Source

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());
Source

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 Arguments for ObjectPath

Source§

impl AsRef<ObjectPath> for ObjectPath

Source§

fn as_ref(&self) -> &ObjectPath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<ObjectPath> for ObjectPathBuf

Source§

fn as_ref(&self) -> &ObjectPath

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for ObjectPath

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<ObjectPath> for ObjectPathBuf

Source§

fn borrow(&self) -> &ObjectPath

Immutably borrows from an owned value. Read more
Source§

impl Clone for Box<ObjectPath>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ObjectPath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ObjectPath

Source§

impl From<&ObjectPath> for Box<ObjectPath>

Source§

fn from(object_path: &ObjectPath) -> Self

Converts to this type from the input type.
Source§

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§

type Item = &'a str

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ObjectPath

Source§

fn eq(&self, other: &ObjectPath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Read for ObjectPath

Source§

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");
Source§

impl StructuralPartialEq for ObjectPath

Source§

impl ToOwned for ObjectPath

Source§

type Owned = ObjectPathBuf

The resulting type after obtaining ownership.
Source§

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)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Write for ObjectPath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more