pub struct Inbound { /* private fields */ }Expand description
The receive surface of a stage: a preempting system lane and the data lane.
Within a lane, frames keep FIFO order. Across lanes, sys always wins, so a
system frame is taken even when data is backed up.
Constructed only by link; the lanes are private so every
receive goes through recv, which maintains the flush floor
flush_data relies on.
Implementations§
Source§impl Inbound
impl Inbound
Sourcepub async fn recv(&mut self) -> Option<Received>
pub async fn recv(&mut self) -> Option<Received>
Receive the next frame, draining the system lane before the data lane.
Returns Received::Sys or Received::Data, or None once both
lanes are closed — the run-loop’s shutdown signal.
futures::select_biased polls sys first, so a system frame preempts
any data backlog deterministically. When a lane closes, its receiver
(a FusedStream) yields None; the loop swallows that first None
so the next iteration just skips the dead lane instead of treating it as
shutdown. This is so the sys lane can keep draining even after the data
lane shuts down — None is returned only once both lanes have closed.
Sourcepub fn flush_data(&mut self) -> Vec<DataFrame>
pub fn flush_data(&mut self) -> Vec<DataFrame>
Drain everything currently queued on the data lane. A frame queued
before the most recently received system frame is kept only if
survives_flush(); a frame queued at or after it is always kept.
Keepers are returned in arrival order, for the caller to re-process.
Does not block and does not touch the sys lane.
Only meaningful straight after receiving the system frame to flush against — receiving another system frame moves the floor.
Sourcepub async fn recv_sys(&mut self) -> Option<(Direction, SystemFrame)>
pub async fn recv_sys(&mut self) -> Option<(Direction, SystemFrame)>
Await the next system frame, ignoring the data lane and maintaining the
flush floor exactly as recv does.
None once the system lane closes, and immediately so from then on — a
caller racing this against other work must stop polling it at that
point. Cancellation-safe: a dropped future takes nothing off the lane.
This is what keeps an application’s output pump preemptible while it is
busy with a data frame. A stage gets sys priority from the run loop’s
own race; the tail lane belongs to the application, so its pump must run
the same race itself (see the e2e examples’ pump_out).