diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index b91e866305d..13147908721 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -64,6 +64,8 @@ - Remove deprecated items. See [PR 3956]. +- Add ability to `downcast_ref` ConnectionDenied errors. See [PR 4020]. + [PR 3292]: https://github.com/libp2p/rust-libp2p/pull/3292 [PR 3605]: https://github.com/libp2p/rust-libp2p/pull/3605 [PR 3651]: https://github.com/libp2p/rust-libp2p/pull/3651 @@ -80,6 +82,7 @@ [PR 3927]: https://github.com/libp2p/rust-libp2p/pull/3927 [PR 3955]: https://github.com/libp2p/rust-libp2p/pull/3955 [PR 3956]: https://github.com/libp2p/rust-libp2p/pull/3956 +[PR 4020]: https://github.com/libp2p/rust-libp2p/pull/4020 [PR 4037]: https://github.com/libp2p/rust-libp2p/pull/4037 ## 0.42.2 diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 9ea010ec61e..9b739f33780 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1730,6 +1730,14 @@ impl ConnectionDenied { Ok(*inner) } + + /// Attempt to downcast to a particular reason for why the connection was denied. + pub fn downcast_ref(&self) -> Option<&E> + where + E: error::Error + Send + Sync + 'static, + { + self.inner.downcast_ref::() + } } impl fmt::Display for ConnectionDenied {