pub struct ElementFactory { /* private fields */ }Expand description
A registered element type: its autoplug metadata plus a constructor
producing a boxed transform/sink for the graph runner. The constructor
receives the output caps the search chose for this hop (see
ChainLink::output), so a format-flexible element configures itself to
produce the right format. It is a plain fn pointer, the common case
being a non-capturing closure |out| Box::new(MyTransform::new(out))
coerced at the call site; an element with a fixed output ignores the arg
(|_| Box::new(MyDecoder::new())).
Implementations§
Source§impl ElementFactory
impl ElementFactory
Sourcepub fn new(
name: &'static str,
templates: Vec<PadTemplate>,
build: fn(&Caps) -> Box<dyn DynAsyncElement>,
) -> Self
pub fn new( name: &'static str, templates: Vec<PadTemplate>, build: fn(&Caps) -> Box<dyn DynAsyncElement>, ) -> Self
Register an element type by name, pad templates, and constructor.
Sourcepub fn of<E: PadTemplates>(
name: &'static str,
build: fn(&Caps) -> Box<dyn DynAsyncElement>,
) -> Self
pub fn of<E: PadTemplates>( name: &'static str, build: fn(&Caps) -> Box<dyn DynAsyncElement>, ) -> Self
Build from a PadTemplates type, pulling its templates from the
trait so the registration site names only the type and constructor.
Sourcepub fn produces(self, kind: MemoryDomainKind) -> Self
pub fn produces(self, kind: MemoryDomainKind) -> Self
Tag the memory feature this factory’s element produces on its source
pad (see ElementDesc::output_memory); used by the domain-aware
auto-plug search to prefer e.g. a Cuda producer for a GPU consumer.
Builder form, defaulting to System.
Sourcepub fn hardware(self) -> Self
pub fn hardware(self) -> Self
Tag this factory’s element as a hardware-accelerated path, so a
hardware-preferring auto-plug search (SelectionContext::prefer_hardware)
favors it. Builder form.
Sourcepub fn rank(self, rank: i16) -> Self
pub fn rank(self, rank: i16) -> Self
Set the deterministic tiebreaker rank (higher wins among candidates of equal score); the explicit-override knob. Builder form, default 0.
Sourcepub fn build(&self, output: &Caps) -> Box<dyn DynAsyncElement>
pub fn build(&self, output: &Caps) -> Box<dyn DynAsyncElement>
Instantiate a fresh boxed element configured to produce output.
Sourcepub fn desc(&self) -> &ElementDesc
pub fn desc(&self) -> &ElementDesc
This factory’s autoplug descriptor.