[][src]Function desync::pipe::pipe_in

pub fn pipe_in<Core, S, ProcessFn>(
    desync: Arc<Desync<Core>>,
    stream: S,
    process: ProcessFn
) where
    Core: 'static + Send + Unpin,
    S: 'static + Send + Unpin + Stream,
    S::Item: Send,
    ProcessFn: 'static + Send + for<'a> FnMut(&'a mut Core, S::Item) -> BoxFuture<'a, ()>, 

Pipes a stream into a desync object. Whenever an item becomes available on the stream, the processing function is called asynchronously with the item that was received.

This takes a weak reference to the passed in Desync object, so the pipe will stop if it's the only thing referencing this object.

Piping a stream to a Desync like this will cause it to start executing: ie, this is similar to calling executor::spawn(stream), except that the stream will immediately start draining into the Desync object.