Trait FactoryLayer

Source
pub trait FactoryLayer<C, F> {
    type Factory;

    // Required method
    fn layer(&self, config: &C, inner: F) -> Self::Factory;
}
Expand description

A trait for creating layered factory wrappers, enabling complex service compositions.

FactoryLayer defines how to wrap one factory with another, creating a new composite factory. This allows for the creation of reusable, modular pieces of functionality that can be easily combined.

Unlike Tower’s Layer which creates a Service wrapping an inner Service, FactoryLayer creates a Factory wrapping an inner Factory, which can then be used to create the entire Service chain.

Required Associated Types§

Source

type Factory

The type of factory this layer produces.

Required Methods§

Source

fn layer(&self, config: &C, inner: F) -> Self::Factory

Creates a new factory wrapper.

This method defines how the layer transforms the inner factory into a new factory.

Implementations on Foreign Types§

Source§

impl<C, F, T> FactoryLayer<C, F> for Option<T>
where T: FactoryLayer<C, F>,

Source§

type Factory = Either<<T as FactoryLayer<C, F>>::Factory, F>

Source§

fn layer(&self, config: &C, inner: F) -> Self::Factory

Implementors§

Source§

impl<C, F> FactoryLayer<C, F> for LayerAsync

Source§

impl<C, F, FLA, FLB> FactoryLayer<C, F> for Either<FLA, FLB>
where FLA: FactoryLayer<C, F>, FLB: FactoryLayer<C, F>,

Source§

type Factory = Either<<FLA as FactoryLayer<C, F>>::Factory, <FLB as FactoryLayer<C, F>>::Factory>

Source§

impl<C, F, FN, O> FactoryLayer<C, F> for LayerFn<C, FN>
where FN: Fn(&C, F) -> O,