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