delete tokio

This commit is contained in:
nora 2022-11-20 20:29:04 +01:00
parent 9d73254291
commit a572c048c9
No known key found for this signature in database
3 changed files with 26 additions and 1045 deletions

1031
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
reqwest = { version = "0.11", features = ["json", "brotli", "gzip", "native-tls", "deflate"] }
tokio = { version = "1", features = ["full"] }
futures = "0.3.25"

View file

@ -1,18 +1,32 @@
use futures::{stream, StreamExt};
use std::marker::PhantomData;
use futures::{stream, StreamExt, Future};
pub struct JoinHandle<T> {
raw: Option<()>,
id: u64,
_p: PhantomData<T>,
}
impl<T> Future for JoinHandle<T> {
type Output = Result<T, ()>;
fn poll(self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Output> {
loop {}
}
}
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
{
loop {}
}
fn main() {
let client = reqwest::Client::builder().build().unwrap();
// Concurrent Requests
let bodies = stream::iter([])
.map(|url: String| {
let req = client.get(&url);
tokio::spawn(async move {
let resp = req.send().await.unwrap();
let text = resp.text().await.unwrap();
Result::Ok((url, text))
})
})
.map(|url: String| spawn(async move { Result::Ok((url, "A".to_owned())) }))
.buffer_unordered(0);
bodies.for_each(|b| async {