HiveMeshConfig

Struct HiveMeshConfig 

Source
pub struct HiveMeshConfig {
    pub node_id: NodeId,
    pub callsign: String,
    pub mesh_id: String,
    pub peripheral_type: PeripheralType,
    pub peer_config: PeerManagerConfig,
    pub sync_interval_ms: u64,
    pub auto_broadcast_events: bool,
    pub encryption_secret: Option<[u8; 32]>,
    pub strict_encryption: bool,
}
Expand description

Configuration for HiveMesh

Fields§

§node_id: NodeId

Our node ID

§callsign: String

Our callsign (e.g., “ALPHA-1”)

§mesh_id: String

Mesh ID to filter peers (e.g., “DEMO”)

§peripheral_type: PeripheralType

Peripheral type for this device

§peer_config: PeerManagerConfig

Peer management configuration

§sync_interval_ms: u64

Sync interval in milliseconds (how often to broadcast state)

§auto_broadcast_events: bool

Whether to auto-broadcast on emergency/ack

§encryption_secret: Option<[u8; 32]>

Optional shared secret for mesh-wide encryption (32 bytes)

When set, all documents are encrypted using ChaCha20-Poly1305 before transmission and decrypted upon receipt. All nodes in the mesh must share the same secret to communicate.

§strict_encryption: bool

Strict encryption mode - reject unencrypted documents when encryption is enabled

When true and encryption is enabled, any unencrypted documents received will be rejected and trigger a SecurityViolation event. This prevents downgrade attacks where an adversary sends unencrypted malicious documents.

Default: false (backward compatible - accepts unencrypted for gradual rollout)

Implementations§

Source§

impl HiveMeshConfig

Source

pub fn new(node_id: NodeId, callsign: &str, mesh_id: &str) -> Self

Create a new configuration with required fields

Source

pub fn with_encryption(self, secret: [u8; 32]) -> Self

Enable mesh-wide encryption with a shared secret

All documents will be encrypted using ChaCha20-Poly1305 before transmission. All mesh participants must use the same secret.

Source

pub fn with_peripheral_type(self, ptype: PeripheralType) -> Self

Set peripheral type

Source

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

Set sync interval

Source

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

Set peer timeout

Source

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

Set max peers (for embedded systems)

Source

pub fn with_strict_encryption(self) -> Self

Enable strict encryption mode

When enabled (and encryption is also enabled), any unencrypted documents received will be rejected and trigger a SecurityViolation event. This prevents downgrade attacks.

Note: This only has effect when encryption is enabled via with_encryption().

Trait Implementations§

Source§

impl Clone for HiveMeshConfig

Source§

fn clone(&self) -> HiveMeshConfig

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 HiveMeshConfig

Source§

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

Formats the value using the given formatter. 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.