pub struct ChainBuilder { /* private fields */ }Expand description
Builds one chain segment (a run of elements that all execute on the same
thread). Call ChainBuilder::queue to close the current segment behind
a Queue and start a new one on its own worker thread.
Because each element needs a handle to its downstream to be
constructed, the chain is assembled back-to-front: elements are
collected in call order, then folded right-to-left starting from the
terminal Sink at ChainBuilder::to time.
Implementations§
Source§impl ChainBuilder
impl ChainBuilder
Sourcepub fn new(context: Arc<Context>) -> Self
pub fn new(context: Arc<Context>) -> Self
Starts a detached branch plan. Prefer Context::branch at call
sites; it makes the owning pipeline explicit without cloning the
context manually.
Sourcepub fn pipe<T: Filter + 'static>(self, element: T) -> Self
pub fn pipe<T: Filter + 'static>(self, element: T) -> Self
Adds a single-output Filter (decoder, encoder, filter, …) that
receives via Sink and produces through its own (single) src pad.
It runs on the same thread as whatever is upstream of it — direct
function call, no queue.
Sourcepub fn queue(self, name: impl Into<String>, capacity: usize) -> Self
pub fn queue(self, name: impl Into<String>, capacity: usize) -> Self
Introduces a thread boundary (blocking when full — see
OverflowPolicy::Block): everything added after this runs on its
own worker thread instead of the thread that feeds this queue.
Sourcepub fn queue_with_policy(
self,
name: impl Into<String>,
capacity: usize,
policy: OverflowPolicy,
) -> Self
pub fn queue_with_policy( self, name: impl Into<String>, capacity: usize, policy: OverflowPolicy, ) -> Self
Same as ChainBuilder::queue, but lets you choose what happens
when the queue is full (e.g. OverflowPolicy::DropNewest for a
live source that shouldn’t stall upstream).
Sourcepub fn to(self, terminal: Box<dyn Sink>) -> Result<DetachedBranch>
pub fn to(self, terminal: Box<dyn Sink>) -> Result<DetachedBranch>
Terminates the chain with a Sink (muxer, file sink, …) and
assembles everything into a single Box<dyn Sink> ready to be
linked into a source’s src pad. The terminal’s own Element::name()
is what shows up on the bus when it reports EOS.