Expand description
Peer lifetime management with stale peer cleanup
Tracks peer activity and identifies stale peers that should be removed. This prevents memory leaks from accumulated discovered devices that are no longer in range.
§Example
ⓘ
use peat_btle::peer_lifetime::{PeerLifetimeManager, PeerLifetimeConfig};
let config = PeerLifetimeConfig::default();
let mut manager = PeerLifetimeManager::new(config);
// When a peer is discovered or connects
manager.on_peer_activity("00:11:22:33:44:55", true); // connected = true
// When peer disconnects
manager.on_peer_disconnected("00:11:22:33:44:55");
// Periodically check for stale peers
for address in manager.get_stale_peers() {
// Remove peer from your data structures
manager.remove_peer(&address);
}Structs§
- Peer
Info - Detailed information about a peer
- Peer
Lifetime Config - Configuration for peer lifetime management
- Peer
Lifetime Manager - Manager for peer lifetime and stale peer cleanup
- Peer
Lifetime Stats - Statistics about tracked peers
- Stale
Peer Info - Information about a stale peer
Enums§
- Stale
Reason - Reason a peer is considered stale