Skip to main content

PeerManagerConfig

Struct PeerManagerConfig 

Source
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,
    pub rssi_degraded_threshold: i8,
    pub lost_timeout_ms: u64,
}
Expand description

Configuration for the PeerManager

Provides configurable timeouts and behaviors for peer management. All time values are in milliseconds.

Fields§

§peer_timeout_ms: u64

Time after which a peer is considered stale and removed (default: 45000ms)

§cleanup_interval_ms: u64

How often to run cleanup of stale peers (default: 10000ms)

§sync_interval_ms: u64

How often to sync documents with peers (default: 5000ms)

§sync_cooldown_ms: u64

Minimum time between syncs to the same peer (default: 30000ms) Prevents “thrashing” when peers keep reconnecting

§auto_connect: bool

Whether to automatically connect to discovered peers (default: true)

§mesh_id: String

Local mesh ID for filtering peers (e.g., “DEMO”)

§max_peers: usize

Maximum number of tracked peers (for no_std/embedded, default: 8)

§rssi_degraded_threshold: i8

RSSI threshold below which a connection is considered degraded (default: -80 dBm)

§lost_timeout_ms: u64

Time after disconnect before peer transitions to Lost state (default: 30000ms)

Implementations§

Source§

impl PeerManagerConfig

Source

pub fn with_mesh_id(mesh_id: impl Into<String>) -> Self

Create a new config with the specified mesh ID

Source

pub fn peer_timeout(self, timeout_ms: u64) -> Self

Set peer timeout

Source

pub fn sync_interval(self, interval_ms: u64) -> Self

Set sync interval

Source

pub fn auto_connect(self, enabled: bool) -> Self

Set auto-connect behavior

Source

pub fn max_peers(self, max: usize) -> Self

Set max peers (for embedded systems)

Source

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

Source§

fn clone(&self) -> PeerManagerConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeerManagerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PeerManagerConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.