Skip to main content

bus_own_name

Function bus_own_name 

Source
pub fn bus_own_name<BusAcquired, NameAcquired, NameLost>(
    bus_type: BusType,
    name: &str,
    flags: BusNameOwnerFlags,
    bus_acquired: BusAcquired,
    name_acquired: NameAcquired,
    name_lost: NameLost,
) -> OwnerId
where BusAcquired: Fn(DBusConnection, &str) + 'static, NameAcquired: Fn(DBusConnection, &str) + 'static, NameLost: Fn(Option<DBusConnection>, &str) + 'static,
Expand description

only the first call will work.

Another guarantee is that invocations of @name_acquired_handler and @name_lost_handler are guaranteed to alternate; that is, if @name_acquired_handler is invoked then you are guaranteed that the next time one of the handlers is invoked, it will be @name_lost_handler. The reverse is also true.

If you plan on exporting objects (using, for example, DBusConnection::register_object()), note that it is generally too late to export the objects in @name_acquired_handler. Instead, you can do this in @bus_acquired_handler since you are guaranteed that this will run before @name is requested from the bus.

This behavior makes it very simple to write applications that want to own names and export objects. Simply register objects to be exported in @bus_acquired_handler and unregister the objects (if any) in @name_lost_handler.

§bus_type

the type of bus to own a name on

§name

the well-known name to own

§flags

a set of flags with ownership options

§bus_acquired_handler

handler to invoke when connected to the bus of type @bus_type, or NULL to ignore

§name_acquired_handler

handler to invoke when @name is acquired, or NULL to ignore

§name_lost_handler

handler to invoke when @name is lost, or NULL to ignore

§Returns

an identifier (never 0) that can be used with bus_unown_name() to stop owning the name