WIP: image processing library (or libraries?) #12

Draft
schrottkatze wants to merge 15 commits from schrottkatze/iowo:proc-libs into main
4 changed files with 21 additions and 33 deletions
Showing only changes of commit 4bc84451e0 - Show all commits

View file

@ -5,6 +5,7 @@
//! - [Builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html)
pub mod data;
#[macro_use]
pub mod element;
pub mod ops;
pub mod pipeline;

View file

@ -1,5 +1,7 @@
//! The trait and type representations
use std::any::TypeId;
use crate::experimental::trait_based::data::io::Inputs;
use super::data::io::Outputs;
@ -13,13 +15,15 @@ pub(crate) trait PipelineElement {
/// Type signature for an element used for static checking
pub(crate) struct ElementSignature {
pub inputs: Vec<DataType>,
pub outputs: Vec<DataType>,
pub inputs: Vec<TypeId>,
pub outputs: Vec<TypeId>,
}
/// Data type enum
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum DataType {
String,
Int,
macro_rules! signature {
($($inputs:ty),+ => $($outputs:ty),+) => (
ElementSignature {
inputs: vec![$(std::any::TypeId::of::<$inputs>(), )+],
outputs: vec![$(std::any::TypeId::of::<$outputs>(), )+]
}
)
}

View file

@ -1,12 +1,13 @@
//! Operations on numeric data
use core::panic;
use std::any::TypeId;
use crate::experimental::trait_based::{
data::{
io::{Inputs, Outputs},
raw::Data,
},
element::{DataType, ElementSignature, PipelineElement},
element::{ElementSignature, PipelineElement},
};
/// Addition

Why do Add, Subtract, Concatenate hold a pub i32 if it's never used?

Why do `Add`, `Subtract`, `Concatenate` hold a `pub i32` if it's never used?

because i wanted to do second params like that originally, then realizing it doesn't work that "easily". so basically, still WIP

because i wanted to do second params like that originally, then realizing it doesn't work that "easily". so basically, still WIP
@ -22,10 +23,7 @@ impl PipelineElement for Add {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::Int, DataType::Int],
outputs: vec![DataType::Int],
}
signature!(i32, i32 => i32)
}
}
@ -42,10 +40,7 @@ impl PipelineElement for Subtract {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::Int, DataType::Int],
outputs: vec![DataType::Int],
}
signature!(i32, i32 => i32)
}
}
@ -62,9 +57,6 @@ impl PipelineElement for Stringify {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::Int],
outputs: vec![DataType::String],
}
signature!(i32 => String)
}
}

View file

@ -4,7 +4,7 @@ use crate::experimental::trait_based::{
io::{Inputs, Outputs},
raw::Data,
},
element::{DataType, ElementSignature, PipelineElement},
element::{ElementSignature, PipelineElement},
};
/// Concatenate the inputs
@ -20,10 +20,7 @@ impl PipelineElement for Concatenate {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::String, DataType::String],
outputs: vec![DataType::String],
}
signature!(String, String => String)
}
}
@ -40,10 +37,7 @@ impl PipelineElement for Upper {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::String],
outputs: vec![DataType::String],
}
signature!(String => String)
}
}
@ -60,9 +54,6 @@ impl PipelineElement for Lower {
}
fn signature(&self) -> ElementSignature {
ElementSignature {
inputs: vec![DataType::String],
outputs: vec![DataType::String],
}
signature!(String => String)
}
}