From 2bed61d0d67533d64c25c10ad9bfd0c1ed3f6ca2 Mon Sep 17 00:00:00 2001 From: ivmarkov Date: Sat, 7 Oct 2023 07:39:41 +0000 Subject: [PATCH] More expressive Ping trait --- CHANGELOG.md | 1 + src/ping.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1968f16..a3d521e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Breaking change: OTA: GAT `Ota::Update` now parametric over lifetime and no longer returned by `&mut` ref * Breaking change: OTA: `OtaUpdate::abort` and `OtaUpdate::complete` now take `self` instead of `&mut self` * Breaking change: MQTT: GAT `Connection::Message` now parametric over lifetime +* Breaking change: Ping: Callback function of `Ping::ping_details` can now be `FnMut` but does require `Send` * Breaking change: All pub structs in `utils::asyncify` that implement the `Future` trait are now private and wrapped with async methods * Breaking change: Removed structs `Blocking` and `TrivialAsync`, as well as all trait implementations on them, because their usefulness was questionable * Breaking change: Removed the deprecated module `httpd` and the dependency on `anyhow` diff --git a/src/ping.rs b/src/ping.rs index 70afbff..0caad5c 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -63,11 +63,11 @@ pub trait Ping { fn ping(&mut self, ip: ipv4::Ipv4Addr, conf: &Configuration) -> Result; - fn ping_details( + fn ping_details( &mut self, ip: ipv4::Ipv4Addr, conf: &Configuration, - reply_callback: &F, + reply_callback: F, ) -> Result; } @@ -81,11 +81,11 @@ where (*self).ping(ip, conf) } - fn ping_details( + fn ping_details( &mut self, ip: ipv4::Ipv4Addr, conf: &Configuration, - reply_callback: &F, + reply_callback: F, ) -> Result { (*self).ping_details(ip, conf, reply_callback) } @@ -107,11 +107,11 @@ pub mod asynch { conf: &Configuration, ) -> Result; - async fn ping_details( + async fn ping_details( &mut self, ip: ipv4::Ipv4Addr, conf: &Configuration, - reply_callback: &F, + reply_callback: F, ) -> Result; } @@ -129,11 +129,11 @@ pub mod asynch { (*self).ping(ip, conf).await } - async fn ping_details( + async fn ping_details( &mut self, ip: ipv4::Ipv4Addr, conf: &Configuration, - reply_callback: &F, + reply_callback: F, ) -> Result { (*self).ping_details(ip, conf, reply_callback).await }