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" 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();