pub struct MeshCore { /* private fields */ }Expand description
MeshCore client for communicating with MeshCore devices
Implementations§
Source§impl MeshCore
impl MeshCore
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if connected
Sourcepub fn commands(&self) -> &Arc<Mutex<CommandHandler>>
pub fn commands(&self) -> &Arc<Mutex<CommandHandler>>
Get the command handler
Sourcepub async fn device_time(&self) -> Option<u32>
pub async fn device_time(&self) -> Option<u32>
Get cached device time
Sourcepub async fn contacts_dirty(&self) -> bool
pub async fn contacts_dirty(&self) -> bool
Check if the contact cache is dirty
Sourcepub async fn get_contact_by_name(&self, name: &str) -> Option<Contact>
pub async fn get_contact_by_name(&self, name: &str) -> Option<Contact>
Get contact by name
Sourcepub async fn get_contact_by_prefix(&self, prefix: &[u8]) -> Option<Contact>
pub async fn get_contact_by_prefix(&self, prefix: &[u8]) -> Option<Contact>
Get contact by public key prefix
Sourcepub async fn ensure_contacts(&self) -> Result<()>
pub async fn ensure_contacts(&self) -> Result<()>
Ensure contacts are loaded
Sourcepub async fn subscribe<F>(
&self,
event_type: EventType,
filters: HashMap<String, String>,
callback: F,
) -> Subscription
pub async fn subscribe<F>( &self, event_type: EventType, filters: HashMap<String, String>, callback: F, ) -> Subscription
Subscribe to events
Sourcepub async fn wait_for_event(
&self,
event_type: Option<EventType>,
filters: HashMap<String, String>,
timeout: Duration,
) -> Option<MeshCoreEvent>
pub async fn wait_for_event( &self, event_type: Option<EventType>, filters: HashMap<String, String>, timeout: Duration, ) -> Option<MeshCoreEvent>
Wait for an event, either matching a specific EventType or all
Sourcepub async fn start_auto_message_fetching(&self)
pub async fn start_auto_message_fetching(&self)
Start auto-fetching messages when MESSAGES_WAITING is received
Sourcepub async fn stop_auto_message_fetching(&self)
pub async fn stop_auto_message_fetching(&self)
Stop auto-fetching messages
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
Disconnect from the device
Sourcepub async fn set_default_timeout(&self, timeout: Duration)
pub async fn set_default_timeout(&self, timeout: Duration)
Set default timeout
Sourcepub fn dispatcher(&self) -> &Arc<EventDispatcher>
pub fn dispatcher(&self) -> &Arc<EventDispatcher>
Get the event dispatcher
Sourcepub fn reader(&self) -> &Arc<MessageReader>
pub fn reader(&self) -> &Arc<MessageReader>
Get the message reader
Sourcepub fn event_stream(&self) -> impl Stream<Item = MeshCoreEvent> + Unpin
pub fn event_stream(&self) -> impl Stream<Item = MeshCoreEvent> + Unpin
Create a stream of all events
Returns a stream that yields all events emitted by the device.
Use StreamExt methods to filter or process events.
§Example
use futures::StreamExt;
let mut stream = meshcore.event_stream();
while let Some(event) = stream.next().await {
println!("Received: {:?}", event.event_type);
}Sourcepub fn event_stream_filtered(
&self,
event_type: EventType,
) -> impl Stream<Item = MeshCoreEvent> + Unpin
pub fn event_stream_filtered( &self, event_type: EventType, ) -> impl Stream<Item = MeshCoreEvent> + Unpin
Create a filtered stream of events by type
Returns a stream that yields only events matching the specified type.
§Example
use futures::StreamExt;
use meshcore_rs::EventType;
let mut stream = meshcore.event_stream_filtered(EventType::ContactMsgRecv);
while let Some(event) = stream.next().await {
println!("Message received: {:?}", event.payload);
}Auto Trait Implementations§
impl Freeze for MeshCore
impl !RefUnwindSafe for MeshCore
impl Send for MeshCore
impl Sync for MeshCore
impl Unpin for MeshCore
impl UnsafeUnpin for MeshCore
impl !UnwindSafe for MeshCore
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