prowocessing: add documentation of trait experiment

This commit is contained in:
Schrottkatze 2024-02-21 14:24:57 +01:00
commit 0ebfed66ed
No known key found for this signature in database
9 changed files with 93 additions and 37 deletions

View file

@ -1,29 +1,38 @@
use super::raw::{Data, OwnedData};
/// Newtype struct with borrowed types for pipeline/element inputs, so that doesn't force a move or clone
pub struct Inputs<'a>(Vec<Data<'a>>);
impl<'a> Inputs<'a> {
/// get inner value(s)
pub(crate) fn inner(&self) -> Vec<Data<'a>> {
self.0.clone()
}
}
impl<'a> From<Vec<Data<'a>>> for Inputs<'a> {
fn from(value: Vec<Data<'a>>) -> Self {
Self(value)
}
}
impl<'a, T: Into<Data<'a>>> From<T> 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(std::convert::Into::into).collect())
}
}
/// Newtype struct around `OwnedData` for pipeline/element outputs
pub struct Outputs(Vec<OwnedData>);
impl Outputs {
/// consume self and return inner value(s)
pub fn into_inner(self) -> Vec<OwnedData> {
self.0
}