Skip to main content

ElementFactory

Struct ElementFactory 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn build(&self, output: &Caps) -> Box<dyn DynAsyncElement>

Instantiate a fresh boxed element configured to produce output.

Source

pub fn desc(&self) -> &ElementDesc

This factory’s autoplug descriptor.

Trait Implementations§

Source§

impl Debug for ElementFactory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ElementBound for T
where T: Send,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.