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 super::super::{ChannelWrapper, ReceiverChannelId, ReceiverName};
use super::wrap::sink_wrap;

pub trait Sink {
  type InputValue : Send;
  type InputError : Send;

  fn process(
    &mut self,
    input:  &mut ChannelWrapper<Self::InputValue, Self::InputError>,
    stop:   &mut bool);
}

pub fn new<InputValue: Send, InputError: Send>(
    name   : &str,
    sink   : Box<Sink<InputValue=InputValue, InputError=InputError>+Send>)
      -> Box<sink_wrap::SinkWrap<InputValue, InputError>>
{
  let name = String::from(name);
  Box::new(
    sink_wrap::new(
      name.clone(),
      sink,
      ChannelWrapper::ReceiverNotConnected(
        ReceiverChannelId(0),
        ReceiverName (name)
      )
    )
  )
}