pub struct Cache { /* private fields */ }Expand description
Where compiled files are kept, or nowhere (off).
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn at(dir: impl Into<PathBuf>) -> Cache
pub fn at(dir: impl Into<PathBuf>) -> Cache
A cache in a directory of one’s choosing (created when an entry is first written).
Sourcepub fn for_app(app_id: &str) -> Cache
pub fn for_app(app_id: &str) -> Cache
The cache of an application, in the platform’s cache directory
under its id (platform_dir); off when the platform gives none.
Sourcepub fn entry_path(
&self,
compiler: &Compiler<'_>,
source: &Path,
) -> Option<PathBuf>
pub fn entry_path( &self, compiler: &Compiler<'_>, source: &Path, ) -> Option<PathBuf>
The file holding a compiler’s entry for a source (none when the cache is off). A relative source path is taken from the current directory.
Sourcepub fn get(
&self,
compiler: &Compiler<'_>,
source: &Path,
contents: &[u8],
) -> Option<Vec<u8>>
pub fn get( &self, compiler: &Compiler<'_>, source: &Path, contents: &[u8], ) -> Option<Vec<u8>>
The compiled form of a source, if the cache holds one made from these contents by this version of the compiler. Anything else (no entry, an unreadable one, a stale one) is none.
Sourcepub fn put(
&self,
compiler: &Compiler<'_>,
source: &Path,
contents: &[u8],
compiled: &[u8],
) -> Result<(), CacheError>
pub fn put( &self, compiler: &Compiler<'_>, source: &Path, contents: &[u8], compiled: &[u8], ) -> Result<(), CacheError>
Keeps the compiled form of a source, replacing what the cache held for it. Written to a temporary file then renamed, so a reader never sees half an entry. Off, it does nothing.
Trait Implementations§
impl Eq for Cache
impl StructuralPartialEq for Cache
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.