From b2318c6225d3d13b2cb6a294ae9d22f3a58be6b0 Mon Sep 17 00:00:00 2001 From: Sebastian Urban Date: Wed, 26 Jun 2024 20:45:23 +0200 Subject: [PATCH] monitor: MonitorHandle must be used State that events of MonitorHandle must be used, otherwise a memory leak will occur. Fixes #145 --- bluer/src/monitor.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bluer/src/monitor.rs b/bluer/src/monitor.rs index c60e2a6..f684a12 100644 --- a/bluer/src/monitor.rs +++ b/bluer/src/monitor.rs @@ -333,7 +333,11 @@ impl RegisteredMonitor { /// Use this to receive a stream of [advertisement monitor events](MonitorEvent) /// for the registered monitor. /// +/// While a [`MonitorHandle`] is being held, its events *must* be consumed regularly. +/// Otherwise it will use an unbounded amount of memory for buffering the unconsumed events. +/// /// Drop to unregister the advertisement monitor target. +#[must_use = "the MonitorHandle must be held for the monitor to be active and its events must be consumed regularly"] pub struct MonitorHandle { name: dbus::Path<'static>, event_rx: ReceiverStream,