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 bytes that make up an ObjectPath.

Get the ObjectPath as a &str.

Unlike ordinary std::path::Path, ObjectPaths are always valid Rust strs making this possible.

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.

Return a ObjectPath consisting of a single / seperator.

Returns an Iterator over the elements of an ObjectPath.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Appends the signature of the type to the SignatureBuffer. Read more

If this returns true, it indicates that for implementing type T, Rust’s [T] is identical to DBus’s array format and can be copied into a message after aligning the first element. Read more

Check if this type fulfills this signature. This may expect to only be called with valid signatures. But it might be called with the wrong signature. This means for example you must check the length before indexing. Read more

The 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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts the given value to a String. Read more