mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2026-01-16 08:33:06 +01:00
prowocessing: refactor trait based experiment to individual files
This commit is contained in:
parent
2d537cc4ee
commit
98f6af78be
10 changed files with 362 additions and 341 deletions
51
crates/prowocessing/src/experimental/trait_based/data/io.rs
Normal file
51
crates/prowocessing/src/experimental/trait_based/data/io.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use super::raw::{Data, OwnedData};
|
||||
|
||||
pub struct Inputs<'a>(Vec<Data<'a>>);
|
||||
impl<'a> Inputs<'a> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Outputs(Vec<OwnedData>);
|
||||
impl Outputs {
|
||||
pub fn into_inner(self) -> Vec<OwnedData> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
impl From<Vec<OwnedData>> for Outputs {
|
||||
fn from(value: Vec<OwnedData>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
impl<T: Into<OwnedData>> From<T> for Outputs {
|
||||
fn from(value: T) -> Self {
|
||||
Self(vec![value.into()])
|
||||
}
|
||||
}
|
||||
impl From<Inputs<'_>> for Outputs {
|
||||
fn from(value: Inputs) -> Self {
|
||||
Self(
|
||||
value
|
||||
.0
|
||||
.into_iter()
|
||||
.map(|i: Data<'_>| Data::to_owned_data(&i))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue