diff --git a/CHANGELOG.md b/CHANGELOG.md index c9aadb5..28bc61b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Upgraded `strum` and `strum-macros` to 0.25 * OTA: New method: `Ota::finish` that allows to postpone/avoid setting the updated partition as a boot one * TimerService: `TimerService::timer` now takes `&self` instead of `&mut self` -* Breaking change: TimerService: scoped handler: the timer handler now only needs to live as long as the `TimerService::Timer` associated type. Therefore, `TimerService::Timer` is now lifetimed: `TimerService::Timer<'a>` +* Breaking change: TimerService: scoped handler: the timer callback now only needs to live as long as the `TimerService::Timer` associated type. Therefore, `TimerService::Timer` is now lifetimed: `TimerService::Timer<'a>` +* Breaking change: EventBus: scoped handler: the subscription callback now only needs to live as long as the `EventBus::Subscription` associated type. Therefore, `EventBus::Subscription` is now lifetimed: `EventBus::Subscription<'a>` * 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 diff --git a/src/event_bus.rs b/src/event_bus.rs index 6a1fc2c..7ecdba7 100644 --- a/src/event_bus.rs +++ b/src/event_bus.rs @@ -47,39 +47,38 @@ where } pub trait EventBus
: ErrorType {
- type Subscription;
+ type Subscription<'a>;
- fn subscribe(
- &self,
- callback: impl for<'a> FnMut(&'a P) + Send + 'static,
- ) -> Result for &'a mut E
+impl<'e, P, E> EventBus for &'e E
where
E: EventBus ,
{
- type Subscription = E::Subscription;
+ type Subscription<'a> = E::Subscription<'a>;
- fn subscribe(
- &self,
- callback: impl for<'b> FnMut(&'b P) + Send + 'static,
- ) -> Result for &'a E
+impl<'e, P, E> EventBus for &'e mut E
where
E: EventBus ,
{
- type Subscription = E::Subscription;
+ type Subscription<'a> = E::Subscription<'a>;
- fn subscribe(
- &self,
- callback: impl for<'b> FnMut(&'b P) + Send + 'static,
- ) -> Result (&self) -> Result (
+ &self,
+ ) -> Result ,
- E::Subscription: Send + 'static,
+ E::Subscription<'static>: Send + 'static,
{
let state = Arc::new((
Mutex::new(SubscriptionState {
@@ -317,9 +319,9 @@ mod async_traits_impl {
CV::RawMutex: Send + Sync + 'static,
P: Clone + Send + 'static,
E: crate::event_bus::EventBus ,
- E::Subscription: Send + 'static,
+ for<'a> E::Subscription<'a>: Send + 'static,
{
- type Subscription = AsyncSubscription TimerService for &S
@@ -80,10 +81,10 @@ where
{
type Timer<'a> = S::Timer<'a>;
- fn timer<'a>(
- &self,
- callback: impl FnMut() + Send + 'a,
- ) -> Result