Expand description
An asynchronous stream interface for downloading ERA1 files.
§Examples
use futures_util::StreamExt;
use reqwest::{Client, Url};
use reth_era_downloader::{EraClient, EraStream, EraStreamConfig};
use std::{path::PathBuf, str::FromStr};
// URL where the ERA1 files are hosted
let url = Url::from_str("file:///")?;
// Directory where the ERA1 files will be downloaded to
let folder = PathBuf::new().into_boxed_path();
let client = EraClient::new(Client::new(), url, folder);
let config = EraStreamConfig::default()
// Keep up to 2 ERA1 files in the `folder`.
// More downloads won't start until some of the files are removed.
.with_max_files(2)
// Do not download more than 2 files at the same time.
.with_max_concurrent_downloads(2);
let mut stream = EraStream::new(client, config);
while let Some(file) = stream.next().await {
let file = file?;
// Process `file: Box<Path>`
}
Structs§
- EraClient
- An HTTP client with features for downloading ERA files from an external HTTP accessible endpoint.
- EraStream
- An asynchronous stream of ERA1 files.
- EraStream
Config - Parameters that alter the behavior of
EraStream
.
Traits§
- EraMeta
- Contains information about an ERA file.
- Http
Client - Accesses the network over HTTP.
Functions§
- read_
dir - Creates a new ordered asynchronous [
Stream
] of ERA1 files read fromdir
.