1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
// SPDX-License-Identifier: MIT OR Apache-2.0 //! Download with indicatif progress bars. //! //! Run: `cargo run --example progress --features indicatif` use hf_fetch_model::FetchConfig; use hf_fetch_model::progress::IndicatifProgress; #[tokio::main] async fn main() -> Result<(), hf_fetch_model::FetchError> { let progress = IndicatifProgress::new(); let config = FetchConfig::builder() .on_progress(move |e| progress.handle(e)) .build()?; let outcome = hf_fetch_model::download_with_config("julien-c/dummy-unknown".to_owned(), &config).await?; if outcome.is_cached() { println!("Cached at: {}", outcome.inner().display()); } else { println!("Downloaded to: {}", outcome.inner().display()); } Ok(()) }