serialplugin-core 0.1.0

Serial port core of tauri-plugin-serialplugin without Tauri: RX hub, watch streams with native parsers, AT exchange, CMUX, TCP and BLE transports
Documentation
//! Serial port core of `tauri-plugin-serialplugin`, usable from plain Rust (no Tauri).
//!
//! [`SerialManager`] owns every open port: one RX hub thread per port, watch streams
//! with native framing ([`events::WatchOptions::parser`]), request/response
//! [`exchange`](SerialManager::exchange), queued AT commands, GSM 07.10 CMUX virtual
//! channels, `tcp://host:port` bridges and (feature `ble`) Bluetooth LE serial.
//! Events are delivered to an [`EventSink`] closure you pass to
//! [`SerialManager::watch`].
//!
//! ```no_run
//! use serialplugin_core::{events::{SerialEvent, WatchOptions}, EventSink, SerialManager};
//! use std::sync::Arc;
//!
//! let serial = SerialManager::new();
//! let path = serial.open("/dev/ttyUSB0".into(), 115_200, None, None, None, None, None)?;
//! let sink: EventSink = Arc::new(|event| {
//!     if let SerialEvent::Data { data, .. } = event {
//!         println!("{}", String::from_utf8_lossy(&data));
//!     }
//!     true // keep the subscription
//! });
//! let watch_id = serial.watch(path.clone(), WatchOptions::default(), sink)?;
//! let reply = serial.at(path.clone(), "AT+CSQ".into(), None)?;
//! println!("{:?}", reply.status);
//! serial.unwatch(watch_id)?;
//! serial.close(path)?;
//! # Ok::<(), serialplugin_core::error::Error>(())
//! ```

/// Logging macros that respect the global log level ([`state::set_log_level`]).
pub mod logger;

#[cfg(any(test, target_os = "android"))]
mod jni_ready;

#[cfg(target_os = "android")]
pub mod android;
pub mod api;
pub mod at;
pub mod cmux;
pub mod error;
pub mod events;
pub mod exchange;
pub mod hub;
pub mod port;
pub mod state;
pub mod sync_util;

#[cfg(target_os = "ios")]
#[path = "serialport_ios.rs"]
pub mod serialport;

#[cfg(any(not(target_os = "android"), debug_assertions))]
pub mod mock_serial;

pub use api::SerialManager;
pub use error::Error;
pub use events::{EventSink, PortListSink};