reth_era_downloader/
lib.rs

1//! An asynchronous stream interface for downloading ERA1 files.
2//!
3//! # Examples
4//! ```
5//! use futures_util::StreamExt;
6//! use reqwest::{Client, Url};
7//! use reth_era_downloader::{EraClient, EraStream, EraStreamConfig};
8//! use std::{path::PathBuf, str::FromStr};
9//!
10//! # async fn f() -> Result<(), Box<dyn std::error::Error + 'static>> {
11//! // URL where the ERA1 files are hosted
12//! let url = Url::from_str("file:///")?;
13//!
14//! // Directory where the ERA1 files will be downloaded to
15//! let folder = PathBuf::new().into_boxed_path();
16//!
17//! let client = EraClient::new(Client::new(), url, folder);
18//!
19//! let config = EraStreamConfig::default()
20//!     // Keep up to 2 ERA1 files in the `folder`.
21//!     // More downloads won't start until some of the files are removed.
22//!     .with_max_files(2)
23//!     // Do not download more than 2 files at the same time.
24//!     .with_max_concurrent_downloads(2);
25//!
26//! let mut stream = EraStream::new(client, config);
27//!
28//! # return Ok(());
29//! while let Some(file) = stream.next().await {
30//!     let file = file?;
31//!     // Process `file: Box<Path>`
32//! }
33//! # Ok(())
34//! # }
35//! ```
36
37mod client;
38mod fs;
39mod stream;
40
41pub use client::{EraClient, HttpClient};
42pub use fs::read_dir;
43pub use stream::{EraMeta, EraStream, EraStreamConfig};