fn spawn_fetch<S, F, Fut, T>(
clients: &HashMap<String, Arc<dyn SashikoApi>, S>,
active_remote: &str,
msg_tx: &UnboundedSender<Message>,
fetch: F,
on_missing: fn(&str) -> Message,
)where
S: BuildHasher,
F: FnOnce(Arc<dyn SashikoApi>) -> Fut + Send + 'static,
Fut: Future<Output = T> + Send,
T: Into<Message> + Send + 'static,Expand description
Spawn an async fetch task if the client exists, or send an error message.
This helper eliminates the repeated if let Some(client) = clients.get(...) { clone + spawn } else { send error } pattern across all fetch commands.