kabu_core_node/
traits.rs

1//! Component builder trait
2
3use eyre::Result;
4use kabu_core_components::Component;
5
6/// Trait for building components from context
7pub trait ComponentBuilder<Ctx>: Sized + Send + Sync + 'static {
8    /// The component type that will be created
9    type Component: Component;
10
11    /// Build the component from the given context
12    fn build(self, ctx: &Ctx) -> Result<Self::Component>;
13}
14
15/// Marker struct for disabled components
16pub struct DisabledComponent;
17
18impl Component for DisabledComponent {
19    fn spawn(self, _executor: reth_tasks::TaskExecutor) -> Result<()> {
20        // No-op for disabled components
21        Ok(())
22    }
23
24    fn name(&self) -> &'static str {
25        "Disabled"
26    }
27}
28
29impl<Ctx> ComponentBuilder<Ctx> for DisabledComponent {
30    type Component = DisabledComponent;
31
32    fn build(self, _ctx: &Ctx) -> Result<Self::Component> {
33        Ok(DisabledComponent)
34    }
35}