pub trait ModuleComposition {
// Required methods
fn then<Other: Module + 'static>(
self,
other: Other,
) -> ComposedModule<Self, Other>
where Self: Sized + 'static;
fn parallel<Other: Module + 'static>(
self,
other: Other,
) -> ParallelModule<Self, Other>
where Self: Sized + 'static;
fn residual(self) -> ResidualModule<Self>
where Self: Sized + 'static;
fn conditional<F>(self, condition_fn: F) -> ConditionalModule<Self, F>
where Self: Sized + 'static,
F: Fn() -> bool + Send + Sync;
}Expand description
Trait for modules that support functional composition
Required Methods§
Sourcefn then<Other: Module + 'static>(
self,
other: Other,
) -> ComposedModule<Self, Other>where
Self: Sized + 'static,
fn then<Other: Module + 'static>(
self,
other: Other,
) -> ComposedModule<Self, Other>where
Self: Sized + 'static,
Compose this module with another module sequentially
Creates a new module that applies self then other.
Sourcefn parallel<Other: Module + 'static>(
self,
other: Other,
) -> ParallelModule<Self, Other>where
Self: Sized + 'static,
fn parallel<Other: Module + 'static>(
self,
other: Other,
) -> ParallelModule<Self, Other>where
Self: Sized + 'static,
Compose this module with another module in parallel
Creates a new module that applies both modules to the same input and combines results.
Sourcefn residual(self) -> ResidualModule<Self>where
Self: Sized + 'static,
fn residual(self) -> ResidualModule<Self>where
Self: Sized + 'static,
Add a residual connection
Creates a new module that adds the input to the output of this module.
Sourcefn conditional<F>(self, condition_fn: F) -> ConditionalModule<Self, F>
fn conditional<F>(self, condition_fn: F) -> ConditionalModule<Self, F>
Add conditional execution
Creates a new module that only applies this module when the condition is true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T: Module + 'static> ModuleComposition for T
Blanket implementation of ModuleComposition for all modules