Struct Cache

Source
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: PathBuf

Implementations§

Source§

impl Cache

Source

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.

Source

pub fn at(path: &Path) -> Cache

Creates a new cache specifically at a particular directory, useful in testing and such.

Source

pub fn join(&self, path: &Path) -> PathBuf

Joins a path to the destination of this cache, returning the result

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Cache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Cache

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnwindSafe for Cache

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,