pub struct Cache {
pub destination: PathBuf,
}Expand description
Global cache for wasm-pack, currently containing binaries downloaded from urls like wasm-bindgen and such.
Fields§
§destination: PathBufImplementations§
Source§impl Cache
impl Cache
Sourcepub fn new(name: &str) -> Result<Cache>
pub fn new(name: &str) -> Result<Cache>
Returns the global cache directory, as inferred from env vars and such.
This function may return an error if a cache directory cannot be determined.
Sourcepub fn at(path: &Path) -> Cache
pub fn at(path: &Path) -> Cache
Creates a new cache specifically at a particular directory, useful in testing and such.
Sourcepub fn join(&self, path: &Path) -> PathBuf
pub fn join(&self, path: &Path) -> PathBuf
Joins a path to the destination of this cache, returning the result
Sourcepub fn download_version(
&self,
install_permitted: bool,
name: &str,
binaries: &[&str],
url: &str,
version: &str,
) -> Result<Option<Download>>
pub fn download_version( &self, install_permitted: bool, name: &str, binaries: &[&str], url: &str, version: &str, ) -> Result<Option<Download>>
Downloads a tarball or zip file from the specified url, extracting it to a directory with the version number and returning the directory that the contents were extracted into.
Note that this function requries that the contents of url never change
as the contents of the url are globally cached on the system and never
invalidated.
The name is a human-readable name used to go into the folder name of
the destination, and binaries is a list of binaries expected to be at
the url. If the URL’s extraction doesn’t contain all the binaries this
function will return an error.
Sourcepub fn download(
&self,
install_permitted: bool,
name: &str,
binaries: &[&str],
url: &str,
) -> Result<Option<Download>>
pub fn download( &self, install_permitted: bool, name: &str, binaries: &[&str], url: &str, ) -> Result<Option<Download>>
Downloads a tarball or zip file from the specified url, extracting it locally and returning the directory that the contents were extracted into.
Note that this function requries that the contents of url never change
as the contents of the url are globally cached on the system and never
invalidated.
The name is a human-readable name used to go into the folder name of
the destination, and binaries is a list of binaries expected to be at
the url. If the URL’s extraction doesn’t contain all the binaries this
function will return an error.
Sourcepub fn download_artifact(
&self,
name: &str,
url: &str,
) -> Result<Option<Download>>
pub fn download_artifact( &self, name: &str, url: &str, ) -> Result<Option<Download>>
Downloads a tarball from the specified url, extracting it locally and returning the directory that the contents were extracted into.
Similar to download; use this function for languages that doesn’t emit a binary.
Sourcepub fn download_artifact_version(
&self,
name: &str,
url: &str,
version: &str,
) -> Result<Option<Download>>
pub fn download_artifact_version( &self, name: &str, url: &str, version: &str, ) -> Result<Option<Download>>
Downloads a tarball from the specified url, extracting it locally and returning the directory that the contents were extracted into.
Similar to download; use this function for languages that doesn’t emit a binary.