1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fmt::Error;
use std::sync::mpsc::{Receiver, Sender};

#[allow(dead_code)]
pub const MIN_WORKER: i32 = 1;
#[allow(dead_code)]
pub const DEFAULT_WORKERS: i32 = 16;


pub type GenerateFunc<T> = fn(source: Receiver<T>);
pub type MapFunc<T> = fn(item: T, writer: Writer);
pub type VoidMapFunc<T> = fn(item: T);
pub type MapperFunc<T> = fn(item: T, writer: Writer, cancel: fn(Error));
pub type ReducerFunc<T> = fn(pipe: Sender<T>, writer: Writer, cancel: fn(Error));
pub type VoidReducerFunc<T> = fn(pipe: Sender<T>, cancel: fn(Error));
pub type Option = fn(opts: &mut MapReduceOption);

pub trait Writer {
    fn write<T>(&self, v: T);
}

#[derive(Debug)]
struct MapReduceOption {
    worker: i32
}

fn drain<T>(ch:Receiver<T>){

}