8 releases
Uses new Rust 2024
new 0.2.1 | May 3, 2025 |
---|---|
0.2.0 | May 3, 2025 |
0.1.8 | Apr 30, 2025 |
#1014 in Asynchronous
552 downloads per month
36KB
828 lines
Lazily clone streams with clone-stream
This module provides a way to fork a stream into multiple streams that can be cloned and used independently.
The CloneStream
struct implements the
Stream
trait and allows for cloning of the stream, while the Fork
struct manages the underlying "base" (or input) stream and the other sibling
stream clones.
The ForkStream
trait is implemented for any stream that yields items
that implement the Clone
trait. This allows for easy conversion of a
stream into a CloneStream
. Just import this trait if you want to use the
functionality in this library.
Clone-stream
Convert any stream into a stream that is Clone
. The only requirement is that the item type of the base-stream implements Clone
.
Remark: A stream is an implementor of the Stream
trait from the futures
crate (also called an async iterator).
Installation
In an existing cargo
project:
cargo add clone-stream futures
If you would like to install the latest git
version instead of the release on crates.io:
cargo add --git https://github.com/wvhulle/clone-stream
Usage
See the docs for the API documentation.
How does it work?
The Rust integration tests in tests show some examples.
See my blog for more technical information.
Dependencies
~0.7–1MB
~20K SLoC