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

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 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 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 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 copy of the value. Read more
1.0.0 · 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 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"]);
§

type Item = &'a str

The type of the elements being iterated over.
§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToOwned for ObjectPath

§

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

source§

impl Eq for ObjectPath

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 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§

default fn to_string(&self) -> String

Converts the given value to a String. Read more