Julio Biason
1 year ago
4 changed files with 299 additions and 0 deletions
@ -0,0 +1,250 @@ |
|||||||
|
# This file is automatically @generated by Cargo. |
||||||
|
# It is not intended for manual editing. |
||||||
|
version = 3 |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "addr2line" |
||||||
|
version = "0.21.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" |
||||||
|
dependencies = [ |
||||||
|
"gimli", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "adler" |
||||||
|
version = "1.0.2" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "async-stream" |
||||||
|
version = "0.3.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" |
||||||
|
dependencies = [ |
||||||
|
"async-stream-impl", |
||||||
|
"futures-core", |
||||||
|
"pin-project-lite", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "async-stream-impl" |
||||||
|
version = "0.3.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"syn", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "autocfg" |
||||||
|
version = "1.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "backtrace" |
||||||
|
version = "0.3.69" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" |
||||||
|
dependencies = [ |
||||||
|
"addr2line", |
||||||
|
"cc", |
||||||
|
"cfg-if", |
||||||
|
"libc", |
||||||
|
"miniz_oxide", |
||||||
|
"object", |
||||||
|
"rustc-demangle", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "bytes" |
||||||
|
version = "1.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "cc" |
||||||
|
version = "1.0.83" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" |
||||||
|
dependencies = [ |
||||||
|
"libc", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "cfg-if" |
||||||
|
version = "1.0.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "futures-core" |
||||||
|
version = "0.3.28" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "futures-macro" |
||||||
|
version = "0.3.28" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"syn", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "futures-task" |
||||||
|
version = "0.3.28" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "futures-util" |
||||||
|
version = "0.3.28" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" |
||||||
|
dependencies = [ |
||||||
|
"futures-core", |
||||||
|
"futures-macro", |
||||||
|
"futures-task", |
||||||
|
"pin-project-lite", |
||||||
|
"pin-utils", |
||||||
|
"slab", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "gimli" |
||||||
|
version = "0.28.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "libc" |
||||||
|
version = "0.2.147" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "memchr" |
||||||
|
version = "2.6.3" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "miniz_oxide" |
||||||
|
version = "0.7.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" |
||||||
|
dependencies = [ |
||||||
|
"adler", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "object" |
||||||
|
version = "0.32.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" |
||||||
|
dependencies = [ |
||||||
|
"memchr", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "pin-project-lite" |
||||||
|
version = "0.2.13" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "pin-utils" |
||||||
|
version = "0.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "proc-macro2" |
||||||
|
version = "1.0.66" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" |
||||||
|
dependencies = [ |
||||||
|
"unicode-ident", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "quote" |
||||||
|
version = "1.0.33" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "rustc-demangle" |
||||||
|
version = "0.1.23" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "slab" |
||||||
|
version = "0.4.9" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" |
||||||
|
dependencies = [ |
||||||
|
"autocfg", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "syn" |
||||||
|
version = "2.0.32" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"unicode-ident", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tokio" |
||||||
|
version = "1.32.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" |
||||||
|
dependencies = [ |
||||||
|
"backtrace", |
||||||
|
"bytes", |
||||||
|
"pin-project-lite", |
||||||
|
"tokio-macros", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tokio-macros" |
||||||
|
version = "2.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"syn", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tokiostreamtest" |
||||||
|
version = "0.1.0" |
||||||
|
dependencies = [ |
||||||
|
"async-stream", |
||||||
|
"futures-core", |
||||||
|
"futures-util", |
||||||
|
"tokio", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "unicode-ident" |
||||||
|
version = "1.0.11" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" |
@ -0,0 +1,12 @@ |
|||||||
|
[package] |
||||||
|
name = "tokiostreamtest" |
||||||
|
version = "0.1.0" |
||||||
|
edition = "2021" |
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
async-stream = "0.3.5" |
||||||
|
futures-core = "0.3.28" |
||||||
|
futures-util = "0.3.28" |
||||||
|
tokio = { version = "1.32.0", features = ["rt", "macros", "fs", "io-util"] } |
@ -0,0 +1,7 @@ |
|||||||
|
# TokioStreamTest |
||||||
|
|
||||||
|
Checking how to work with tokio-stream, and if it works fine using async code |
||||||
|
inside its macros. |
||||||
|
|
||||||
|
In the end, this turned to be an async-stream, futures-core and futures-util |
||||||
|
test. |
@ -0,0 +1,30 @@ |
|||||||
|
use std::path::{Path, PathBuf}; |
||||||
|
|
||||||
|
use async_stream::stream; |
||||||
|
use futures_core::Stream; |
||||||
|
use futures_util::{StreamExt, pin_mut}; |
||||||
|
|
||||||
|
fn filenames(start: &Path) -> impl Stream<Item = PathBuf> + '_ { |
||||||
|
stream! { |
||||||
|
let contents = tokio::fs::read_dir(start).await; |
||||||
|
if let Ok(mut reader) = contents { |
||||||
|
while let Ok(Some(entry)) = reader.next_entry().await { |
||||||
|
let entry = entry.path(); |
||||||
|
if entry.is_file() { |
||||||
|
yield entry; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#[tokio::main(flavor = "current_thread")] |
||||||
|
async fn main() { |
||||||
|
let name_stream = filenames(Path::new("src")); |
||||||
|
pin_mut!(name_stream); |
||||||
|
|
||||||
|
while let Some(name) = name_stream.next().await { |
||||||
|
println!("Found {:?}", name); |
||||||
|
} |
||||||
|
println!("Hello, world!"); |
||||||
|
} |
Loading…
Reference in new issue