pub struct MockNetwork { /* private fields */ }Expand description
Shared network state for multiple mock adapters
Allows multiple MockBleAdapter instances to “see” each other and
simulate BLE discovery and connections.
Implementations§
Source§impl MockNetwork
impl MockNetwork
Sourcepub fn start_advertising(
&self,
node_id: NodeId,
address: &str,
name: Option<&str>,
)
pub fn start_advertising( &self, node_id: NodeId, address: &str, name: Option<&str>, )
Register a node as advertising
Sourcepub fn stop_advertising(&self, node_id: &NodeId)
pub fn stop_advertising(&self, node_id: &NodeId)
Stop advertising for a node
Sourcepub fn discover_nodes(&self, observer: &NodeId) -> Vec<DiscoveredDevice>
pub fn discover_nodes(&self, observer: &NodeId) -> Vec<DiscoveredDevice>
Get all advertising nodes visible to a given node
Sourcepub fn connect(&self, from: &NodeId, to: &NodeId) -> Result<()>
pub fn connect(&self, from: &NodeId, to: &NodeId) -> Result<()>
Establish a connection between two nodes
Sourcepub fn disconnect(&self, from: &NodeId, to: &NodeId)
pub fn disconnect(&self, from: &NodeId, to: &NodeId)
Disconnect two nodes
Sourcepub fn is_connected(&self, from: &NodeId, to: &NodeId) -> bool
pub fn is_connected(&self, from: &NodeId, to: &NodeId) -> bool
Check if two nodes are connected
Sourcepub fn send_data(&self, from: &NodeId, to: &NodeId, data: Vec<u8>) -> Result<()>
pub fn send_data(&self, from: &NodeId, to: &NodeId, data: Vec<u8>) -> Result<()>
Send data from one node to another
Sourcepub fn receive_data(&self, node_id: &NodeId) -> Vec<DataPacket>
pub fn receive_data(&self, node_id: &NodeId) -> Vec<DataPacket>
Receive pending data for a node
Sourcepub fn connected_peers(&self, node_id: &NodeId) -> Vec<NodeId>
pub fn connected_peers(&self, node_id: &NodeId) -> Vec<NodeId>
Get all connected peers for a node
Trait Implementations§
Source§impl Clone for MockNetwork
impl Clone for MockNetwork
Source§fn clone(&self) -> MockNetwork
fn clone(&self) -> MockNetwork
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for MockNetwork
impl Default for MockNetwork
Source§fn default() -> MockNetwork
fn default() -> MockNetwork
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MockNetwork
impl RefUnwindSafe for MockNetwork
impl Send for MockNetwork
impl Sync for MockNetwork
impl Unpin for MockNetwork
impl UnwindSafe for MockNetwork
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more