[][src]Struct dbus_crossroads::Crossroads

pub struct Crossroads { /* fields omitted */ }

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

impl Crossroads[src]

pub fn new() -> Crossroads[src]

Create a new Crossroads instance.

pub fn set_add_standard_ifaces(&mut self, enable: bool)[src]

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>), 
[src]

Registers a new interface into the interface registry. The closure receives an IfaceBuilder that you can add methods, signals and properties to.

pub fn data_mut<D: Any + Send + 'static>(
    &mut self,
    name: &Path<'static>
) -> Option<&mut D>
[src]

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>>, 
[src]

Inserts a new path.

If the path already exists, it is overwritten.

pub fn has_interface<D: Send>(
    &self,
    name: &Path<'static>,
    token: IfaceToken<D>
) -> bool
[src]

Returns true if the path exists and implements the interface

pub fn remove<D>(&mut self, name: &Path<'static>) -> Option<D> where
    D: Any + Send + 'static, 
[src]

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.

pub fn handle_message<S: Sender>(
    &mut self,
    message: Message,
    conn: &S
) -> Result<(), ()>
[src]

Handles an incoming message call.

Returns Err if the message is not a method call.

pub fn introspectable<T: Send + 'static>(&self) -> IfaceToken<T>[src]

The token representing the built-in implementation of "org.freedesktop.DBus.Introspectable".

pub fn properties<T: Send + 'static>(&self) -> IfaceToken<T>[src]

The token representing the built-in implementation of "org.freedesktop.DBus.Properties".

pub fn object_manager<T: Send + 'static>(&self) -> IfaceToken<T>[src]

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>)>
[src]

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.

pub fn set_object_manager_support(
    &mut self,
    x: Option<Arc<dyn Sender + Send + Sync + 'static>>
) -> Option<Arc<dyn Sender + Send + Sync + 'static>>
[src]

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.

pub fn serve(self, connection: &Connection) -> Result<(), Error>[src]

Serve clients forever on a blocking Connection.

This is a quick one-liner for the simplest case. In more advanced scenarios, you probably have to write similar code yourself.

Trait Implementations

impl Debug for Crossroads[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.