Skip to main content

Module peer_lifetime

Module peer_lifetime 

Source
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§

PeerInfo
Detailed information about a peer
PeerLifetimeConfig
Configuration for peer lifetime management
PeerLifetimeManager
Manager for peer lifetime and stale peer cleanup
PeerLifetimeStats
Statistics about tracked peers
StalePeerInfo
Information about a stale peer

Enums§

StaleReason
Reason a peer is considered stale