1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-16 11:46:58 +02:00

refactor: networkmanager rewritten to utilise fallible_client

This commit is contained in:
Reinout Meliesie 2024-04-22 15:50:31 +02:00
commit 6478dd62fb
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
3 changed files with 63 additions and 90 deletions

View file

@ -101,10 +101,15 @@ impl Clients {
}
#[cfg(feature = "networkmanager")]
pub fn networkmanager(&mut self) -> Arc<networkmanager::Client> {
self.networkmanager
.get_or_insert_with(networkmanager::create_client)
.clone()
pub fn networkmanager(&mut self) -> ClientResult<networkmanager::Client> {
match &self.networkmanager {
Some(client) => Ok(client.clone()),
None => {
let client = networkmanager::create_client()?;
self.networkmanager = Some(client.clone());
Ok(client)
}
}
}
#[cfg(feature = "notifications")]