Skip to main content

serialplugin_core/hub/
handle.rs

1//! Shared RX hub facade (poll hub on desktop and Android).
2
3use crate::cmux::CmuxSession;
4use crate::events::EventSink;
5use crate::hub::shared::{ExchangeWaiter, RxHubShared};
6use serial_codec::framing::Framer;
7use std::sync::Arc;
8
9/// Platform-neutral RX hub API used by exchange and watch paths.
10pub trait RxHubHandle: Send + Sync {
11    fn shared(&self) -> Arc<RxHubShared>;
12    fn set_exchange_waiter(&self, waiter: Arc<ExchangeWaiter>);
13    fn clear_exchange_waiter(&self);
14    fn cancel_active_exchange(&self);
15    fn attach_watch_with(
16        &self,
17        channel: EventSink,
18        batch_timeout_ms: u64,
19        read_size: usize,
20        route_urc: bool,
21        framer: Option<Box<dyn Framer>>,
22    );
23    /// 4.0.0 API (feature `tauri`): [`Self::attach_watch_with`] for a Tauri channel.
24    #[cfg(feature = "tauri")]
25    fn attach_watch(
26        &self,
27        channel: tauri::ipc::Channel<crate::events::SerialEvent>,
28        batch_timeout_ms: u64,
29        read_size: usize,
30        route_urc: bool,
31    ) {
32        let sink = crate::events::channel_sink(channel);
33        self.attach_watch_with(sink, batch_timeout_ms, read_size, route_urc, None);
34    }
35    fn detach_watch(&self);
36    fn attach_cmux(&self, session: Arc<CmuxSession>);
37    fn detach_cmux(&self);
38    /// Stop background RX processing.
39    fn shutdown_hub(&self) {}
40}