//! The trait and type representations

use std::any::TypeId;

use crate::experimental::trait_based::data::io::Inputs;

use super::data::io::Outputs;

pub(crate) trait PipelineElement {
    /// return a static runner function pointer to avoid dynamic dispatch during pipeline execution - Types MUST match the signature
    fn runner(&self) -> fn(&Inputs) -> Outputs;
    /// return the signature of the element
    fn signature(&self) -> ElementSignature;
}

/// Type signature for an element used for static checking
pub(crate) struct ElementSignature {
    pub inputs: Vec<TypeId>,
    pub outputs: Vec<TypeId>,
}

macro_rules! signature {
    ($($inputs:ty),+ => $($outputs:ty),+) => (
        ElementSignature {
            inputs: vec![$(std::any::TypeId::of::<$inputs>(), )+],
            outputs: vec![$(std::any::TypeId::of::<$outputs>(), )+]
        }
    )
}
