use std::future::Future;
use futures::future::BoxFuture;
use crate::types::{Input, Output};
pub trait IComponentFunction<TMessage, TConfig>: Send {
fn call(
&self,
stream_input: Input<TMessage>,
stream_output: Output<TMessage>,
config: TConfig,
) -> BoxFuture<'static, ()>;
}
impl<T, F, TMessage, TConfig> IComponentFunction<TMessage, TConfig> for T
where
T: Fn(Input<TMessage>, Output<TMessage>, TConfig) -> F + Send,
F: Future<Output = ()> + 'static + Send,
{
fn call(
&self,
stream_input: Input<TMessage>,
stream_output: Output<TMessage>,
config: TConfig,
) -> BoxFuture<'static, ()> {
Box::pin(self(stream_input, stream_output, config))
}
}