lychee/examples/archive/archive.rs
Thomas Zahner 31b2525a8d
Move archive functionality to library (#1720)
* Bump flake 1.83.0 -> 1.87.0
* Move archive functionality into lychee-lib
* Create example, update name and docs
* Split function & update tests
* Remove trailing slashes in API calls & update tests
* Apply lint suggestions
* Rename function
* Move module
* Add cargo-nextest to devShell to support 'make test'
2025-06-06 22:24:10 +02:00

18 lines
487 B
Rust

use lychee_lib::archive::Archive;
use std::{error::Error, time::Duration};
use url::Url;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let archive = Archive::WaybackMachine;
let url = Url::parse("https://example.com")?;
let result = archive
.get_archive_snapshot(&url, Duration::from_secs(10))
.await?;
if let Some(replacement) = result {
println!("Good news! {} can be replaced with {}", url, replacement);
}
Ok(())
}