pub struct MockBleAdapter { /* private fields */ }Expand description
Mock BLE adapter for testing
Provides a fully simulated BLE adapter that can be used in unit tests without requiring actual BLE hardware.
Implementations§
Source§impl MockBleAdapter
impl MockBleAdapter
Sourcepub fn new(node_id: NodeId, network: MockNetwork) -> Self
pub fn new(node_id: NodeId, network: MockNetwork) -> Self
Create a new mock adapter with default configuration
Sourcepub fn with_config(
node_id: NodeId,
network: MockNetwork,
config: MockAdapterConfig,
) -> Self
pub fn with_config( node_id: NodeId, network: MockNetwork, config: MockAdapterConfig, ) -> Self
Create a new mock adapter with custom configuration
Sourcepub fn clear_events(&self)
pub fn clear_events(&self)
Clear recorded events
Sourcepub fn trigger_discovery(&self)
pub fn trigger_discovery(&self)
Trigger discovery of nearby nodes
Call this in tests to simulate device discovery.
Sourcepub fn inject_data(&self, from: &NodeId, data: Vec<u8>)
pub fn inject_data(&self, from: &NodeId, data: Vec<u8>)
Simulate receiving data from a peer
Call this in tests to inject data as if received over BLE.
Sourcepub fn simulate_disconnect(&self, peer_id: &NodeId, reason: DisconnectReason)
pub fn simulate_disconnect(&self, peer_id: &NodeId, reason: DisconnectReason)
Simulate a peer disconnecting
Sourcepub fn is_scanning(&self) -> bool
pub fn is_scanning(&self) -> bool
Check if scanning
Sourcepub fn is_advertising(&self) -> bool
pub fn is_advertising(&self) -> bool
Check if advertising
Trait Implementations§
Source§impl BleAdapter for MockBleAdapter
impl BleAdapter for MockBleAdapter
Source§fn init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_config: &'life1 BleConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_config: &'life1 BleConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize the adapter with the given configuration
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the adapter (begin advertising and/or scanning)
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop the adapter
Source§fn is_powered(&self) -> bool
fn is_powered(&self) -> bool
Check if the adapter is powered on
Source§fn start_scan<'life0, 'life1, 'async_trait>(
&'life0 self,
_config: &'life1 DiscoveryConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start_scan<'life0, 'life1, 'async_trait>(
&'life0 self,
_config: &'life1 DiscoveryConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Start scanning for devices
Source§fn stop_scan<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_scan<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop scanning
Source§fn start_advertising<'life0, 'life1, 'async_trait>(
&'life0 self,
_config: &'life1 DiscoveryConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start_advertising<'life0, 'life1, 'async_trait>(
&'life0 self,
_config: &'life1 DiscoveryConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Start advertising
Source§fn stop_advertising<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_advertising<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop advertising
Source§fn set_discovery_callback(&mut self, callback: Option<DiscoveryCallback>)
fn set_discovery_callback(&mut self, callback: Option<DiscoveryCallback>)
Set callback for discovered devices
Source§fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn BleConnection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn BleConnection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Connect to a peer by node ID
Source§fn disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_id: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Disconnect from a peer
Source§fn get_connection(&self, peer_id: &NodeId) -> Option<Box<dyn BleConnection>>
fn get_connection(&self, peer_id: &NodeId) -> Option<Box<dyn BleConnection>>
Get an existing connection
Source§fn peer_count(&self) -> usize
fn peer_count(&self) -> usize
Get the number of connected peers
Source§fn connected_peers(&self) -> Vec<NodeId>
fn connected_peers(&self) -> Vec<NodeId>
Get list of connected peer IDs
Source§fn set_connection_callback(&mut self, callback: Option<ConnectionCallback>)
fn set_connection_callback(&mut self, callback: Option<ConnectionCallback>)
Set callback for connection events
Source§fn register_gatt_service<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register_gatt_service<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Register the HIVE GATT service
Source§fn unregister_gatt_service<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn unregister_gatt_service<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Unregister the HIVE GATT service
Source§fn supports_coded_phy(&self) -> bool
fn supports_coded_phy(&self) -> bool
Check if Coded PHY is supported
Source§fn supports_extended_advertising(&self) -> bool
fn supports_extended_advertising(&self) -> bool
Check if extended advertising is supported
Source§fn max_connections(&self) -> u8
fn max_connections(&self) -> u8
Get maximum number of connections
Auto Trait Implementations§
impl !Freeze for MockBleAdapter
impl RefUnwindSafe for MockBleAdapter
impl Send for MockBleAdapter
impl Sync for MockBleAdapter
impl Unpin for MockBleAdapter
impl UnwindSafe for MockBleAdapter
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