mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-27 23:20:54 +03:00
simplify enumerate
This commit is contained in:
@@ -189,11 +189,11 @@ impl ClientManager {
|
||||
self.clients.get_mut(client as usize)?.as_mut()
|
||||
}
|
||||
|
||||
pub fn enumerate(&self) -> Vec<(Client, bool)> {
|
||||
self.clients
|
||||
.iter()
|
||||
.filter_map(|s| s.as_ref())
|
||||
.map(|s| (s.client.clone(), s.active))
|
||||
.collect()
|
||||
pub fn get_client_states(&self) -> impl Iterator<Item = &ClientState> {
|
||||
self.clients.iter().filter_map(|x| x.as_ref())
|
||||
}
|
||||
|
||||
pub fn get_client_states_mut(&mut self) -> impl Iterator<Item = &mut ClientState> {
|
||||
self.clients.iter_mut().filter_map(|x| x.as_mut())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,7 +502,10 @@ impl Server {
|
||||
}
|
||||
|
||||
async fn enumerate(&mut self) {
|
||||
let clients = self.client_manager.enumerate();
|
||||
let clients = self.client_manager
|
||||
.get_client_states()
|
||||
.map(|s| (s.client.clone(), s.active))
|
||||
.collect();
|
||||
if let Err(e) = self
|
||||
.frontend
|
||||
.notify_all(FrontendNotify::Enumerate(clients))
|
||||
|
||||
Reference in New Issue
Block a user