pub struct PeerManagerConfig {
pub peer_timeout_ms: u64,
pub cleanup_interval_ms: u64,
pub sync_interval_ms: u64,
pub sync_cooldown_ms: u64,
pub auto_connect: bool,
pub mesh_id: String,
pub max_peers: usize,
}Expand description
Configuration for the PeerManager
Provides configurable timeouts and behaviors for peer management. All time values are in milliseconds.
Fields§
§peer_timeout_ms: u64Time after which a peer is considered stale and removed (default: 45000ms)
cleanup_interval_ms: u64How often to run cleanup of stale peers (default: 10000ms)
sync_interval_ms: u64How often to sync documents with peers (default: 5000ms)
sync_cooldown_ms: u64Minimum time between syncs to the same peer (default: 30000ms) Prevents “thrashing” when peers keep reconnecting
auto_connect: boolWhether to automatically connect to discovered peers (default: true)
mesh_id: StringLocal mesh ID for filtering peers (e.g., “DEMO”)
max_peers: usizeMaximum number of tracked peers (for no_std/embedded, default: 8)
Implementations§
Source§impl PeerManagerConfig
impl PeerManagerConfig
Sourcepub fn with_mesh_id(mesh_id: impl Into<String>) -> Self
pub fn with_mesh_id(mesh_id: impl Into<String>) -> Self
Create a new config with the specified mesh ID
Sourcepub fn peer_timeout(self, timeout_ms: u64) -> Self
pub fn peer_timeout(self, timeout_ms: u64) -> Self
Set peer timeout
Sourcepub fn sync_interval(self, interval_ms: u64) -> Self
pub fn sync_interval(self, interval_ms: u64) -> Self
Set sync interval
Sourcepub fn auto_connect(self, enabled: bool) -> Self
pub fn auto_connect(self, enabled: bool) -> Self
Set auto-connect behavior
Sourcepub fn matches_mesh(&self, device_mesh_id: Option<&str>) -> bool
pub fn matches_mesh(&self, device_mesh_id: Option<&str>) -> bool
Check if a device mesh ID matches our mesh
Returns true if:
- Device mesh ID matches our mesh ID exactly, OR
- Device mesh ID is None (legacy device, matches any mesh)
Trait Implementations§
Source§impl Clone for PeerManagerConfig
impl Clone for PeerManagerConfig
Source§fn clone(&self) -> PeerManagerConfig
fn clone(&self) -> PeerManagerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more