MCPcopy Create free account
hub / github.com/csskit/csskit / fetch_and_cache

Function fetch_and_cache

crates/csskit_spec_generator/src/fetch_cached.rs:82–90  ·  view source on GitHub ↗

Fetches content from a URL and writes it to the cache

(client: &Client, url: &str, cache_path: &PathBuf)

Source from the content-addressed store, hash-verified

80
81/// Fetches content from a URL and writes it to the cache
82async fn fetch_and_cache(client: &Client, url: &str, cache_path: &PathBuf) -> Result<String> {
83 let res = client.get(url).send().await?;
84 if !res.status().is_success() {
85 anyhow::bail!("HTTP {} for {}", res.status(), url);
86 }
87 let contents = res.text().await?;
88 write(cache_path, &contents)?;
89 Ok(contents)
90}
91
92/// Fetches web features data from the web-features repository
93pub async fn get_web_features_data(client: &Client) -> Result<WebFeaturesData> {

Callers 1

fetch_cachedFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected