| Crates.io | fast-pull |
| lib.rs | fast-pull |
| version | 3.2.2 |
| created_at | 2025-08-03 11:19:27.65898+00 |
| updated_at | 2025-08-30 08:29:02.401016+00 |
| description | Pull everything fast |
| homepage | https://github.com/fast-down/core |
| repository | https://github.com/fast-down/core |
| max_upload_size | |
| id | 1779626 |
| size | 55,501 |
fast-pull Fastest concurrent downloader!
Official Website (Simplified Chinese)
use core::{num::NonZeroUsize, time::Duration};
use fast_pull::{
Event, MergeProgress, ProgressEntry,
file::RandFilePusherMmap,
multi::{self, download_multi},
reqwest::{Prefetch, ReqwestPuller},
};
use reqwest::Client;
use tokio::fs::OpenOptions;
#[tokio::main]
async fn main() {
let url = "https://example.com/file.txt";
let client = Client::new();
let info = client.prefetch(url).await.unwrap();
let file = OpenOptions::new()
.read(true)
.write(true)
.create(true)
.truncate(false)
.open(info.name)
.await
.unwrap();
let puller = ReqwestPuller::new(url.parse().unwrap(), client);
let pusher = RandFilePusherMmap::new(file, info.size, 8 * 1024)
.await
.unwrap();
let download_chunks = vec![0..info.size as u64];
let result = download_multi(
puller,
pusher,
multi::DownloadOptions {
concurrent: NonZero::new(32).unwrap(),
retry_gap: Duration::from_secs(1),
push_queue_cap: 1024,
download_chunks: download_chunks.clone(),
},
)
.await;
let mut pull_progress: Vec<ProgressEntry> = Vec::new();
let mut push_progress: Vec<ProgressEntry> = Vec::new();
while let Ok(e) = result.event_chain.recv().await {
match e {
Event::PullProgress(_, p) => {
pull_progress.merge_progress(p);
}
Event::PushProgress(_, p) => {
push_progress.merge_progress(p);
}
_ => {}
}
}
result.join().await.unwrap();
}