refact: Discovery callback takes a closure and fix git dependency hash

This commit is contained in:
2025-08-30 16:48:13 -04:00
parent 269f13ae9b
commit 1eca2cc1a9
3 changed files with 12 additions and 9 deletions

View File

@@ -4,7 +4,8 @@ use crate::local_presence::SERVICE_NAME;
pub type DiscoveryEvent = ServiceEvent;
pub fn discover_agents(timeout: Option<u64>, on_event: fn(&DiscoveryEvent)) {
pub fn discover_agents(timeout: Option<u64>, on_event: impl Fn(DiscoveryEvent) + Send + 'static)
{
// Create a new mDNS daemon.
let mdns = ServiceDaemon::new().expect("Failed to create mDNS daemon");
@@ -14,7 +15,7 @@ pub fn discover_agents(timeout: Option<u64>, on_event: fn(&DiscoveryEvent)) {
std::thread::spawn(move || {
while let Ok(event) = receiver.recv() {
on_event(&event);
on_event(event.clone());
match event {
ServiceEvent::ServiceResolved(resolved) => {
println!("Resolved a new service: {}", resolved.fullname);