From 311860050daa5c65a24a94d4c7baa82f3e5e818b Mon Sep 17 00:00:00 2001 From: csicar Date: Wed, 2 Aug 2023 00:18:57 +0200 Subject: [PATCH 1/2] setup fork --- Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cdaf664..f2f6689 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] -name = "mdns" -version = "3.0.0" -authors = ["Dylan McKay "] +name = "mdns2" +version = "3.1.0" +authors = ["Dylan McKay ", "Carsten Csiky "] edition = "2018" description = """ @@ -11,11 +11,11 @@ Supports discovery of any mDNS device on a LAN. """ license = "MIT" -documentation = "https://docs.rs/mdns" -repository = "https://github.com/dylanmckay/mdns" +documentation = "https://docs.rs/mdns2" +repository = "https://github.com/csicar/mdns2" categories = ["network-programming"] -keywords = ["mdns", "dns", "multicast", "chromecast", "discovery"] +keywords = ["mdns", "dns", "multicast", "chromecast", "discovery", "dns-sd"] [dependencies] dns-parser = "0.8.0" From 583770572d6afd2c9c4947552295d1f947347aef Mon Sep 17 00:00:00 2001 From: csicar Date: Wed, 2 Aug 2023 00:19:52 +0200 Subject: [PATCH 2/2] `async_std`'s interval delays at the start. Fix that --- src/discover.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/discover.rs b/src/discover.rs index d390e80..fdc2382 100644 --- a/src/discover.rs +++ b/src/discover.rs @@ -78,6 +78,12 @@ where }) } +/// Returns a stream that produces an Item with a delay of `duration`. +/// In contrast to async_std's internal, the first item is created **instantly**. +fn instant_interval(duration: Duration) -> impl Stream { + async_std::stream::once(()).chain(async_std::stream::interval(duration)) +} + impl Discovery { /// Sets whether or not we should ignore empty responses. /// @@ -93,7 +99,8 @@ impl Discovery { let response_stream = self.mdns_listener.listen().map(StreamResult::Response); let sender = self.mdns_sender.clone(); - let interval_stream = async_std::stream::interval(self.send_request_interval) + + let interval_stream = instant_interval(self.send_request_interval) // I don't like the double clone, I can't find a prettier way to do this .map(move |_| { let mut sender = sender.clone();