//! Types for element and pipeline IO use std::convert::Into; use super::raw::{Data, DataRef}; /// Newtype struct with borrowed types for pipeline/element inputs, so that doesn't force a move or clone pub struct Inputs<'a>(Vec>); impl<'a> Inputs<'a> { /// get inner value(s) pub(crate) fn inner(&self) -> Vec> { self.0.clone() } } impl<'a> From>> for Inputs<'a> { fn from(value: Vec>) -> Self { Self(value) } } impl<'a, T: Into>> From for Inputs<'a> { fn from(value: T) -> Self { Self(vec![value.into()]) } } impl<'a> From<&'a Outputs> for Inputs<'a> { fn from(value: &'a Outputs) -> Self { Self(value.0.iter().map(Into::into).collect()) } } /// Used for pipeline/element outputs pub struct Outputs(Vec); impl Outputs { /// consume self and return inner value(s) pub fn into_inner(self) -> Vec { self.0 } } impl From> for Outputs { fn from(value: Vec) -> Self { Self(value) } } impl> From for Outputs { fn from(value: T) -> Self { Self(vec![value.into()]) } } impl From> for Outputs { fn from(value: Inputs) -> Self { Self( value .0 .into_iter() .map(|i: DataRef<'_>| DataRef::to_owned_data(&i)) .collect(), ) } }