pub struct PcscMonitor { /* private fields */ }Expand description
Represents a PC/SC monitor that tracks reader and card state changes.
PcscMonitor is a singleton interface for monitoring smart card readers
using PC/SC. It supports hotplug detection, card insertion/removal events,
and thread-safe callback registration.
The monitor runs in a background thread once started.
Implementations§
Source§impl PcscMonitor
impl PcscMonitor
Sourcepub fn instance() -> MutexGuard<'static, PcscMonitor>
pub fn instance() -> MutexGuard<'static, PcscMonitor>
Gets a global instance of the PcscMonitor to register callbacks.
This method returns a locked [MutexGuard] to the global monitor instance.
Use this to attach listeners and start monitoring.
§Example
let mut monitor = pcsc_mon::PcscMonitor::instance();
monitor.on_reader_added(|reader| {
println!("Reader added: {}", reader);
});
monitor.start();Sourcepub fn on_reader_added<F>(&mut self, f: F)
pub fn on_reader_added<F>(&mut self, f: F)
Registers a callback for reader addition events.
The callback is called with the name of the reader when a new reader is connected.
Sourcepub fn on_reader_removed<F>(&mut self, f: F)
pub fn on_reader_removed<F>(&mut self, f: F)
Registers a callback for reader removal events.
The callback is called with the name of the reader when a reader is disconnected.
Note: Internally sets the reader state to State::IGNORE. When the same
reader is reconnected, a card must be inserted and removed again to re-trigger
on_card_inserted.
Sourcepub fn on_card_inserted<F>(&mut self, f: F)
pub fn on_card_inserted<F>(&mut self, f: F)
Sourcepub fn on_card_removed<F>(&mut self, f: F)
pub fn on_card_removed<F>(&mut self, f: F)
Registers a callback for card removal events.
The callback is called with the name of the reader when the card is removed.