Rust library clone-stream
This Rust library allows you to convert non-cloneable streams into cloneable streams. The only requirement is that the item type of the base-stream is cloneable. The streams are supposed to be Rust types implementing the Stream
trait from the common futures
crate.
Installation
Make sure you have installed rustup
, which installs cargo
. Inside an existing cargo
project:
If you would like to install the latest git
version instead of the release on crates.io:
Usage
Import the trait ForkStream
from this crate and call fork
on your un-cloneable Stream
:
use ;
use ForkStream;
let uncloneable_stream = iter;
let cloneable_stream = uncloneable_stream.fork;
let mut cloned_stream = cloneable_stream.clone;
How does it work?
This small project was an exercise for me making streams implement Clone
without spawning tasks.
See the posts about functional async combinators on my blog for more technical information.