Struct dbus_crossroads::Crossroads
source · [−]pub struct Crossroads { /* private fields */ }
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
sourceimpl Crossroads
impl Crossroads
sourcepub fn new() -> Crossroads
pub fn new() -> Crossroads
Create a new Crossroads instance.
sourcepub fn set_add_standard_ifaces(&mut self, enable: bool)
pub fn set_add_standard_ifaces(&mut self, enable: bool)
If set to true (the default), will make paths implement the standard “Introspectable” and, if the path has interfaces with properties, the “Properties” interfaces.
sourcepub 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.
sourcepub fn data_mut<D: Any + Send + 'static>(
&mut self,
name: &Path<'static>
) -> Option<&mut D>
pub fn data_mut<D: Any + Send + 'static>(
&mut self,
name: &Path<'static>
) -> Option<&mut D>
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.
sourcepub 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.
sourcepub fn add_interface<'z, D, N>(&mut self, name: N, iface: IfaceToken<D>) -> boolwhere
D: Any + Send + 'static,
N: Into<Path<'static>>,
pub fn add_interface<'z, D, N>(&mut self, name: N, iface: IfaceToken<D>) -> boolwhere
D: Any + Send + 'static,
N: Into<Path<'static>>,
Adds an interface to an existing object path.
Returns true if interface can be added to the object or already exists in the object. Returns false if the object does not exist or the interface cannot be added due to data type mismatch.
sourcepub fn remove_interface<'z, D, N>(&mut self, name: N, iface: IfaceToken<D>)where
D: Any + Send + 'static,
N: Into<Path<'static>>,
pub fn remove_interface<'z, D, N>(&mut self, name: N, iface: IfaceToken<D>)where
D: Any + Send + 'static,
N: Into<Path<'static>>,
Removes an interface from an object path.
sourcepub fn has_interface<D: Send>(
&self,
name: &Path<'static>,
token: IfaceToken<D>
) -> bool
pub fn has_interface<D: Send>(
&self,
name: &Path<'static>,
token: IfaceToken<D>
) -> bool
Returns true if the path exists and implements the interface
sourcepub fn remove<D>(&mut self, name: &Path<'static>) -> Option<D>where
D: Any + Send + 'static,
pub fn remove<D>(&mut self, name: &Path<'static>) -> Option<D>where
D: Any + Send + 'static,
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.
sourcepub fn handle_message<S: Sender>(
&mut self,
message: Message,
conn: &S
) -> Result<(), ()>
pub fn handle_message<S: Sender>(
&mut self,
message: Message,
conn: &S
) -> Result<(), ()>
Handles an incoming message call.
Returns Err if the message is not a method call.
sourcepub fn introspectable<T: Send + 'static>(&self) -> IfaceToken<T>
pub fn introspectable<T: Send + 'static>(&self) -> IfaceToken<T>
The token representing the built-in implementation of “org.freedesktop.DBus.Introspectable”.
sourcepub fn properties<T: Send + 'static>(&self) -> IfaceToken<T>
pub fn properties<T: Send + 'static>(&self) -> IfaceToken<T>
The token representing the built-in implementation of “org.freedesktop.DBus.Properties”.
sourcepub fn object_manager<T: Send + 'static>(&self) -> IfaceToken<T>
pub fn object_manager<T: Send + 'static>(&self) -> IfaceToken<T>
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.
sourcepub 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.
sourcepub fn set_object_manager_support(
&mut self,
x: Option<Arc<dyn Sender + Send + Sync + 'static>>
) -> Option<Arc<dyn Sender + Send + Sync + 'static>>
pub fn set_object_manager_support(
&mut self,
x: Option<Arc<dyn Sender + Send + Sync + 'static>>
) -> Option<Arc<dyn Sender + Send + Sync + 'static>>
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.