pub struct SerialportInfo {
pub serialport: Box<dyn SerialPort>,
pub sender: Option<Sender<usize>>,
pub thread_handle: Option<JoinHandle<()>>,
}
Expand description
Information structure for a single serial port
This structure holds all the information needed to manage a single serial port, including the port itself, communication channels, and background threads.
§Example
use tauri_plugin_serialplugin::state::SerialportInfo;
use serialport::SerialPort;
// This is typically created internally by the plugin
// let info = SerialportInfo::new(port);
Fields§
§serialport: Box<dyn SerialPort>
The actual serial port implementation
This is a boxed trait object that implements the SerialPort
trait,
providing the actual serial communication functionality.
sender: Option<Sender<usize>>
Optional sender for communication with background threads
This sender is used to communicate with background threads that handle
asynchronous reading operations. It’s None
when no background reading
is active.
thread_handle: Option<JoinHandle<()>>
Optional handle to background thread
This handle allows the plugin to manage background threads that perform
continuous reading operations. It’s None
when no background thread
is running.
Implementations§
Source§impl SerialportInfo
impl SerialportInfo
Sourcepub fn new(serialport: Box<dyn SerialPort>) -> Self
pub fn new(serialport: Box<dyn SerialPort>) -> Self
Creates a new SerialportInfo
instance
This constructor creates a new serial port information structure
with the provided serial port implementation. The sender and thread
handle are initialized to None
and should be set later if needed.
§Arguments
serialport
- A boxed serial port implementation
§Example
use tauri_plugin_serialplugin::state::SerialportInfo;
use serialport::SerialPort;
// This is typically used internally by the plugin
// let info = SerialportInfo::new(port);