pub struct RxHubShared { /* private fields */ }Expand description
Shared hub state between the RX thread and API handlers.
Implementations§
pub fn new() -> Self
pub fn for_path(path: String) -> Self
pub fn attach_watch_with( &self, channel: EventSink, batch_timeout_ms: u64, read_size: usize, route_urc: bool, framer: Option<Box<dyn Framer>>, )
Sourcepub fn detach_watch(&self)
pub fn detach_watch(&self)
Stop the watch; its batch, its unfinished line and its parser’s remainder go out
last, after everything already decoded, before this returns (a sink that calls it
does not wait for another thread’s delivery). Call with no lock held (the sink runs
here); under locks use Self::detach_watch_queued + Self::deliver_queued.
Sourcepub fn detach_watch_queued(&self)
pub fn detach_watch_queued(&self)
Self::detach_watch without running the sink: its last events are queued.
pub fn has_core_watches(&self) -> bool
Sourcepub fn deliver_queued(&self)
pub fn deliver_queued(&self)
Deliver events queued by *_queued calls. Call with no lock held.
Sourcepub fn emit(&self, event: SerialEvent)
pub fn emit(&self, event: SerialEvent)
Queue event for the current watch (if any) and deliver.
pub fn attach_cmux(&self, session: Arc<CmuxSession>)
pub fn detach_cmux(&self)
Sourcepub fn set_exchange_waiter(&self, waiter: Arc<ExchangeWaiter>)
pub fn set_exchange_waiter(&self, waiter: Arc<ExchangeWaiter>)
Install the waiter. Bytes that arrived with no consumer (idle) are handed to it
first, under the idle lock, so they keep their order ahead of the reply.
pub fn clear_exchange_waiter(&self)
Sourcepub fn cancel_active_exchange(&self)
pub fn cancel_active_exchange(&self)
Wake an in-flight exchange waiter when SerialManager::cancel_exchange is invoked.
Sourcepub fn feed_bytes(&self, chunk: &[u8], state: &mut HubRoutingState)
pub fn feed_bytes(&self, chunk: &[u8], state: &mut HubRoutingState)
Push-model entry: route incoming bytes (Android JNI / tests).
Sourcepub fn tick(&self, path: &str, _state: &mut HubRoutingState)
pub fn tick(&self, path: &str, _state: &mut HubRoutingState)
Idle timers for push model: drain completion + watch batch flush + read deadlines.
Sourcepub fn fail_all_waiters(&self, reason: &str)
pub fn fail_all_waiters(&self, reason: &str)
Immediately fail exchange waiters, active drain, and pending read (USB error teardown).
pub fn buffered_len(&self) -> usize
Sourcepub fn purge_buffers(&self)
pub fn purge_buffers(&self)
Drop bytes the hub holds for no one yet (idle RX, a pending read’s partial fill).
Sourcepub fn take_idle_bytes(&self) -> Vec<u8> ⓘ
pub fn take_idle_bytes(&self) -> Vec<u8> ⓘ
Take any bytes buffered without an active consumer (e.g. early RX before exchange waiter).
pub fn cancel_pending_read(&self)
Sourcepub fn read_request(
&self,
max_bytes: usize,
timeout_ms: u64,
fill: bool,
) -> Result<Vec<u8>, String>
pub fn read_request( &self, max_bytes: usize, timeout_ms: u64, fill: bool, ) -> Result<Vec<u8>, String>
Blocking poll-read via the hub (raw bytes, bypasses LineRouter).
Sourcepub fn pending_watch_bytes(&self, _state: &HubRoutingState) -> usize
pub fn pending_watch_bytes(&self, _state: &HubRoutingState) -> usize
Batched bytes of the old watch.
Sourcepub fn flush_watch_now(&self, state: &mut HubRoutingState)
pub fn flush_watch_now(&self, state: &mut HubRoutingState)
Batches and unfinished lines out now (parser state kept).
Sourcepub fn emit_disconnect(&self, path: &str, reason: &str)
pub fn emit_disconnect(&self, path: &str, reason: &str)
Send Disconnect on the watches, after their batch and parser’s remainder: their
last event. CMUX channel watches get the same on their path, and what waits on a
channel fails before any sink runs.
Once per hub: a second call (Android reports a USB failure from the hub loop
and from fail_port) does nothing.
Sourcepub fn finish_watch_stream(&self, state: &mut HubRoutingState)
pub fn finish_watch_stream(&self, state: &mut HubRoutingState)
Port going away: the watches end, what they still hold is queued.
pub fn has_watch(&self) -> bool
Sourcepub fn dispatch_queued_events(&self, events: Vec<QueuedEvent>)
pub fn dispatch_queued_events(&self, events: Vec<QueuedEvent>)
Deliver the events the hub queued, then events. Each goes to the sink it was
produced for, even if the watch was detached since. Call with no lock held, after
every routing call.
Sourcepub fn drain(
&self,
idle_ms: u64,
max_ms: u64,
cancel: Arc<AtomicBool>,
solicited_prefixes: Vec<String>,
) -> Result<Vec<u8>, String>
pub fn drain( &self, idle_ms: u64, max_ms: u64, cancel: Arc<AtomicBool>, solicited_prefixes: Vec<String>, ) -> Result<Vec<u8>, String>
Soft-drain via the hub thread (single reader); URC lines are emitted on the watch channel. Bytes already in the idle buffer are dropped with the drained ones (a late reply to a timed-out exchange is exactly what a drain throws away).