tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.59k stars 2.45k forks source link

Making the Stream adaptor structures public in tokio-stream #6658

Closed sharpened-nacho closed 3 months ago

sharpened-nacho commented 3 months ago

Motivation

The StreamExt trait provides the helpful method take, map, and the like on Streams. But the structures themselves (Take, Map, etc.) are not visible outside the crate, as they are not pub use in stream_ext.rs.

Solution

Re-exported publicly all the structures in stream_ext.rs except for Collect, which is different and should not be exported as stated in its documentation. Re-exported them publicly again in lib.rs.

Added a function in a test with return type Chain to show that it can be part of an external function signature.

Closes: #6656

sharpened-nacho commented 3 months ago

My bad again, sorry for pushing bad commits like those, I'm not familiar enough with large projects to understand how to run all tests. I hope you can squash all that mess together...

sharpened-nacho commented 3 months ago

I just realized the equivalence between tokio_stream::StreamExt and futures_util::StreamExt. But in futures-util the structures are exported and accessible, so the functionality I needed is ultimately not needed here, I can get it from futures-util. Do you want to roll back to the beginning and drop this PR?

devanoneth commented 3 months ago

Any idea when a new version of tokio-stream will be rolled with this in it? Thanks!

Darksonn commented 2 months ago

I don't have concrete plans for a release right now.

djc commented 4 weeks ago

Releasing in #6825.