pub struct Client { /* private fields */ }
Expand description
Client for watching the tray.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Creates and initializes the client.
The client will begin listening to items and menus and sending events immediately.
It is recommended that consumers immediately follow the call to new
with a subscribe
call,
then immediately follow that with a call to items
to get the state to not miss any events.
The value of service_name
must be unique on the session bus.
It is recommended to use something similar to the format of appid-numid
,
where numid
is a short-ish random integer.
§Errors
If the initialization fails for any reason, for example if unable to connect to the bus, this method will return an error.
§Panics
If the generated well-known name is invalid, the library will panic as this indicates a major bug.
Likewise, the spawned tasks may panic if they cannot get a Mutex
lock.
Sourcepub fn subscribe(&self) -> Receiver<Event>
pub fn subscribe(&self) -> Receiver<Event>
Subscribes to the events broadcast channel, returning a new receiver.
Once the client is dropped, the receiver will close.
Sourcepub fn items(&self) -> Arc<Mutex<BaseMap>>
pub fn items(&self) -> Arc<Mutex<BaseMap>>
Gets all current items, including their menus if present.
One should call this method with id=0 when opening the root menu.
ID refers to the menuitem id.
Returns needsUpdate
§Errors
Errors if the proxy cannot be created.