mod checksum; mod error; mod extract; mod file; mod git; mod http; mod scheme; mod types; use std::path::{Path, PathBuf}; pub use error::FetchError; pub use scheme::Scheme; pub use types::FetchArgument; /// Fetch an external resource to a target directory. Returns the local path. /// /// - `git://repo@tag` → clone /// - `https://url` → download (+ checksum + extract) /// - `file:///path` → copy to target /// /// Note: `workspace://` must be converted to `file://` by the caller before passing. pub async fn fetch_resource( name: &str, url: &str, target: &Path, ) -> Result { let scheme = scheme::parse_url(url)?; match scheme { Scheme::Git { repo, git_ref } => { let full_url = if git_ref.is_empty() { repo.clone() } else { format!("{}@{}", repo, git_ref) }; git::fetch_git_plugin(&full_url, name, target, None).await?; Ok(target.join(name)) } Scheme::Http { url, checksum } => { http::fetch_http_plugin(&url, name, target, checksum.as_deref()).await?; Ok(target.join(name)) } Scheme::File { path } => file::fetch_file(&path, name, target).await, } }