forked from katzen-cafe/iowo
Compare commits
No commits in common. "ecc466d01d4309ff505220ec9751b80282239442" and "4bc84451e0a4a2d0dc26e77cc41154e2fa2b3faa" have entirely different histories.
ecc466d01d
...
4bc84451e0
4 changed files with 39 additions and 34 deletions
|
@ -60,11 +60,38 @@ mod dev {
|
||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub(crate) enum DevCommands {}
|
pub(crate) enum DevCommands {
|
||||||
|
Enums { test_str: String },
|
||||||
|
Add { num0: i32, num1: i32 },
|
||||||
|
}
|
||||||
|
|
||||||
impl DevCommands {
|
impl DevCommands {
|
||||||
pub fn run(self) {
|
pub fn run(self) {
|
||||||
println!("There are currently no dev commands.");
|
match self {
|
||||||
|
DevCommands::Enums { test_str } => {
|
||||||
|
use prowocessing::experimental::enum_based::PipelineBuilder;
|
||||||
|
|
||||||
|
let upr = PipelineBuilder::new()
|
||||||
|
.insert(prowocessing::experimental::enum_based::Instruction::Uppercase)
|
||||||
|
.build();
|
||||||
|
let lwr = PipelineBuilder::new()
|
||||||
|
.insert(prowocessing::experimental::enum_based::Instruction::Lowercase)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
println!("Upr: {}", upr.run(test_str.clone()));
|
||||||
|
println!("Lwr: {}", lwr.run(test_str.clone()));
|
||||||
|
}
|
||||||
|
DevCommands::Add { num0, num1 } => {
|
||||||
|
use prowocessing::experimental::trait_based::pipeline::PipelineBuilder;
|
||||||
|
|
||||||
|
let pipe = PipelineBuilder::new().add(1).stringify().build();
|
||||||
|
println!(
|
||||||
|
"{:?}",
|
||||||
|
pipe.run(vec![&num0.into(), &num1.into()].into())
|
||||||
|
.into_inner()[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ use std::{borrow::ToOwned, convert::Into};
|
||||||
use super::raw::Data;
|
use super::raw::Data;
|
||||||
|
|
||||||
/// Newtype struct with borrowed types for pipeline/element inputs, so that doesn't force a move or clone
|
/// Newtype struct with borrowed types for pipeline/element inputs, so that doesn't force a move or clone
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
|
||||||
pub struct Inputs<'a>(pub Vec<&'a Data>);
|
pub struct Inputs<'a>(pub Vec<&'a Data>);
|
||||||
|
|
||||||
impl<'a> From<Vec<&'a Data>> for Inputs<'a> {
|
impl<'a> From<Vec<&'a Data>> for Inputs<'a> {
|
||||||
|
@ -27,8 +26,7 @@ impl<'a> From<&'a Outputs> for Inputs<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used for pipeline/element outputs
|
/// Used for pipeline/element outputs
|
||||||
#[derive(PartialEq, Eq, Debug)]
|
pub struct Outputs(Vec<Data>);
|
||||||
pub struct Outputs(pub Vec<Data>);
|
|
||||||
|
|
||||||
impl Outputs {
|
impl Outputs {
|
||||||
/// consume self and return inner value(s)
|
/// consume self and return inner value(s)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Dynamic data storage and transfer types for use in [`io`]
|
//! Dynamic data storage and transfer types for use in [`io`]
|
||||||
|
|
||||||
// Dynamic data type
|
// Dynamic data type
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Data {
|
pub enum Data {
|
||||||
String(String),
|
String(String),
|
||||||
Int(i32),
|
Int(i32),
|
||||||
|
|
|
@ -8,33 +8,13 @@
|
||||||
/// Gonna first try string processing...
|
/// Gonna first try string processing...
|
||||||
pub mod experimental;
|
pub mod experimental;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::experimental::{
|
|
||||||
enum_based,
|
|
||||||
trait_based::{self, data::io::Outputs},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_enums() {
|
fn test_enums() {
|
||||||
let builder = enum_based::PipelineBuilder::new().insert(enum_based::Instruction::Uppercase);
|
use crate::experimental::enum_based::{Instruction, PipelineBuilder};
|
||||||
|
let builder = PipelineBuilder::new().insert(Instruction::Uppercase);
|
||||||
let upr = builder.build();
|
let upr = builder.build();
|
||||||
let upr_lowr = builder.insert(enum_based::Instruction::Lowercase).build();
|
let upr_lowr = builder.insert(Instruction::Lowercase).build();
|
||||||
|
|
||||||
assert_eq!(upr.run(String::from("Test")), String::from("TEST"));
|
assert_eq!(upr.run(String::from("Test")), String::from("TEST"));
|
||||||
assert_eq!(upr_lowr.run(String::from("Test")), String::from("test"));
|
assert_eq!(upr_lowr.run(String::from("Test")), String::from("test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn add() {
|
|
||||||
let pipe = trait_based::pipeline::PipelineBuilder::new()
|
|
||||||
.add(0)
|
|
||||||
.stringify()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
pipe.run(vec![&2.into(), &3.into()].into()),
|
|
||||||
Outputs(vec![String::from("5").into()])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue