From 9d05c619e83fcbdfffaf51780f67e4bd59ee5ab8 Mon Sep 17 00:00:00 2001 From: DrHuangMHT Date: Tue, 14 Mar 2023 01:17:03 +0800 Subject: [PATCH] feat: derive `Clone` for `mdns::Event` Derive trait `Clone` for `mdns::Event`. This makes cloning its contents without destroying type information possible. Related #3593. Pull-Request: #3606. --- protocols/mdns/CHANGELOG.md | 5 +++++ protocols/mdns/src/behaviour.rs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index c2b548e3389..0c3b88c018c 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.43.1 [unreleased] + +- Derive `Clone` for `mdns::Event`. See [PR 3606]. + +[PR 3606]: https://github.com/libp2p/rust-libp2p/pull/3606 # 0.43.0 - Update to `libp2p-core` `v0.39.0`. diff --git a/protocols/mdns/src/behaviour.rs b/protocols/mdns/src/behaviour.rs index b34a1a73629..f2709e90bdf 100644 --- a/protocols/mdns/src/behaviour.rs +++ b/protocols/mdns/src/behaviour.rs @@ -339,7 +339,7 @@ where } /// Event that can be produced by the `Mdns` behaviour. -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum Event { /// Discovered nodes through mDNS. Discovered(DiscoveredAddrsIter), @@ -352,6 +352,7 @@ pub enum Event { } /// Iterator that produces the list of addresses that have been discovered. +#[derive(Clone)] pub struct DiscoveredAddrsIter { inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>, } @@ -379,6 +380,7 @@ impl fmt::Debug for DiscoveredAddrsIter { } /// Iterator that produces the list of addresses that have expired. +#[derive(Clone)] pub struct ExpiredAddrsIter { inner: smallvec::IntoIter<[(PeerId, Multiaddr); 4]>, }