pub trait Intake<In> {
// Required methods
fn park(&mut self, sweep: Duration) -> Option<Wake<ItemId, In>>;
fn park_async(&mut self) -> impl Future<Output = Option<Wake<ItemId, In>>>;
fn drain(&mut self, into: &mut Vec<Wake<ItemId, In>>);
}runtime only.Expand description
WHERE a node’s input comes from — the capability its intake implements.
Three calls, and they are the three the resident’s loop makes: park (each engine’s own), and drain, which is what lets one wake serve a whole burst.
§The futures promise no Send
park_async is bounded exactly as
AsyncOperator::accept is, and for the same reason: Send
belongs to the ENGINES. A body that holds a !Send intake across an await is an ordinary citizen on the thread
engine and is E0277 at the async door, which is where the question is asked — see
Ignition::spawn. Sink::deliver does promise
it, and the asymmetry is deliberate: a dispatch is awaited from inside a spawned body, while a
park is the loop’s own wait.
Required Methods§
Sourcefn park(&mut self, sweep: Duration) -> Option<Wake<ItemId, In>>
fn park(&mut self, sweep: Duration) -> Option<Wake<ItemId, In>>
Park until something arrives or sweep elapses — the THREAD engine’s door.
None is shutdown: every upstream is gone, so nothing can arrive again. A timeout answers
Wake::Sweep, which is the liveness floor rather than an absence.
Sourcefn park_async(&mut self) -> impl Future<Output = Option<Wake<ItemId, In>>>
fn park_async(&mut self) -> impl Future<Output = Option<Wake<ItemId, In>>>
Park until something arrives — the ASYNC engine’s door.
No timeout, because there is nothing runtime-neutral to time with; the sweep arrives as
Wake::Sweep from a Sweeper instead. None is shutdown, as above.
Sourcefn drain(&mut self, into: &mut Vec<Wake<ItemId, In>>)
fn drain(&mut self, into: &mut Vec<Wake<ItemId, In>>)
Everything already queued, without waiting, appended to into.
What a woken resident takes before doing anything else, so one wake serves a whole burst. It appends rather than answering an iterator because a multi-upstream intake has several queues to walk and a join to run over them, and neither is a borrow of one channel.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T> Intake<T> for Inbox<ItemId, T>
The ONE-SOURCE intake: a node’s own inbox, however many producers send into it.
The shape every node in this crate carries unless its declaration says otherwise, and the
Resident’s default — so this impl is what makes the seam free for the
single-upstream world. Fan-in by Outbox clones is unchanged and is a different
thing from a keyed group: several producers of ONE message type meeting on one edge, rather than
several message types joined into a sum.