Skip to content

Commit

Permalink
More expressive Ping trait
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmarkov committed Oct 7, 2023
1 parent 928ac9d commit 2bed61d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
16 changes: 8 additions & 8 deletions src/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ pub trait Ping {

fn ping(&mut self, ip: ipv4::Ipv4Addr, conf: &Configuration) -> Result<Summary, Self::Error>;

fn ping_details<F: Fn(&Summary, &Reply)>(
fn ping_details<F: FnMut(&Summary, &Reply) + Send>(
&mut self,
ip: ipv4::Ipv4Addr,
conf: &Configuration,
reply_callback: &F,
reply_callback: F,
) -> Result<Summary, Self::Error>;
}

Expand All @@ -81,11 +81,11 @@ where
(*self).ping(ip, conf)
}

fn ping_details<F: Fn(&Summary, &Reply)>(
fn ping_details<F: FnMut(&Summary, &Reply) + Send>(
&mut self,
ip: ipv4::Ipv4Addr,
conf: &Configuration,
reply_callback: &F,
reply_callback: F,
) -> Result<Summary, Self::Error> {
(*self).ping_details(ip, conf, reply_callback)
}
Expand All @@ -107,11 +107,11 @@ pub mod asynch {
conf: &Configuration,
) -> Result<Summary, Self::Error>;

async fn ping_details<F: Fn(&Summary, &Reply)>(
async fn ping_details<F: FnMut(&Summary, &Reply) + Send>(
&mut self,
ip: ipv4::Ipv4Addr,
conf: &Configuration,
reply_callback: &F,
reply_callback: F,
) -> Result<Summary, Self::Error>;
}

Expand All @@ -129,11 +129,11 @@ pub mod asynch {
(*self).ping(ip, conf).await
}

async fn ping_details<F: Fn(&Summary, &Reply)>(
async fn ping_details<F: FnMut(&Summary, &Reply) + Send>(
&mut self,
ip: ipv4::Ipv4Addr,
conf: &Configuration,
reply_callback: &F,
reply_callback: F,
) -> Result<Summary, Self::Error> {
(*self).ping_details(ip, conf, reply_callback).await
}
Expand Down

0 comments on commit 2bed61d

Please sign in to comment.