Struct dbus_crossroads::Crossroads [−][src]
pub struct Crossroads { /* fields omitted */ }
Expand description
Crossroads is the “main” object, containing object paths, a registry of interfaces, and a crossreference of which object paths implement which interfaces.
You can store some arbitrary data with every object path if you like. This data can then be
accessed from within the method callbacks. If you do not want this, just pass ()
as your data.
Crossroads can contain callbacks and data which is Send, but Sync is not required. Hence Crossroads itself is Send but not Sync.
Implementations
Create a new Crossroads instance.
If set to true (the default), will make paths implement the standard “Introspectable” and, if the path has interfaces with properties, the “Properties” interfaces.
pub fn register<T, N, F>(&mut self, name: N, f: F) -> IfaceToken<T> where
T: Send + 'static,
N: Into<Interface<'static>>,
F: FnOnce(&mut IfaceBuilder<T>),
pub fn register<T, N, F>(&mut self, name: N, f: F) -> IfaceToken<T> where
T: Send + 'static,
N: Into<Interface<'static>>,
F: FnOnce(&mut IfaceBuilder<T>),
Registers a new interface into the interface registry. The closure receives an IfaceBuilder that you can add methods, signals and properties to.
Access the data of a certain path.
Will return none both if the path was not found, and if the found data was of another type.
pub fn insert<'z, D, I, N>(&mut self, name: N, ifaces: I, data: D) where
D: Any + Send + 'static,
N: Into<Path<'static>>,
I: IntoIterator<Item = &'z IfaceToken<D>>,
pub fn insert<'z, D, I, N>(&mut self, name: N, ifaces: I, data: D) where
D: Any + Send + 'static,
N: Into<Path<'static>>,
I: IntoIterator<Item = &'z IfaceToken<D>>,
Inserts a new path.
If the path already exists, it is overwritten.
Returns true if the path exists and implements the interface
Removes an existing path.
Returns None if the path was not found. In case of a type mismatch, the path will be removed, but None will be returned.
Handles an incoming message call.
Returns Err if the message is not a method call.
The token representing the built-in implementation of “org.freedesktop.DBus.Introspectable”.
The token representing the built-in implementation of “org.freedesktop.DBus.Properties”.
The token representing the built-in implementation of “org.freedesktop.DBus.ObjectManager”.
You can add this to a path without enabling “set_object_manager_support”, but no signals will be sent.
pub fn set_async_support(
&mut self,
x: Option<(Arc<dyn Sender + Send + Sync + 'static>, Box<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send + 'static>>) + Send + 'static>)>
) -> Option<(Arc<dyn Sender + Send + Sync + 'static>, Box<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send + 'static>>) + Send + 'static>)>
pub fn set_async_support(
&mut self,
x: Option<(Arc<dyn Sender + Send + Sync + 'static>, Box<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send + 'static>>) + Send + 'static>)>
) -> Option<(Arc<dyn Sender + Send + Sync + 'static>, Box<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send + 'static>>) + Send + 'static>)>
Enables this crossroads instance to run asynchronous methods (and setting properties).
Incoming method calls are spawned as separate tasks if necessary. This provides the necessary abstractions needed to spawn a new tasks, and to send the reply when the task has finished.
Enables this crossroads instance to send signals when paths are added and removed.
The added/removed path is a subpath of a path which implements an object manager instance.