pub struct BundleCache {
cache_dir: PathBuf,
}Expand description
Fields§
§cache_dir: PathBufImplementations§
Source§impl BundleCache
impl BundleCache
Sourcepub fn new(cache_dir: impl Into<PathBuf>) -> Self
pub fn new(cache_dir: impl Into<PathBuf>) -> Self
Create a new cache backed by the given directory.
The directory will be created on first write if it does not exist.
Sourcepub fn get(&self, fingerprint: &[u8]) -> Option<AirBundle>
pub fn get(&self, fingerprint: &[u8]) -> Option<AirBundle>
Try to load a cached bundle for the given fingerprint.
Returns None if no cache entry exists or if deserialization fails.
Sourcepub fn put(&self, fingerprint: &[u8], bundle: &AirBundle) -> Result<(), Error>
pub fn put(&self, fingerprint: &[u8], bundle: &AirBundle) -> Result<(), Error>
Store a bundle under the given fingerprint.
Creates the cache directory if it does not exist.
§Errors
Returns an error if the cache directory cannot be created or the bundle cannot be serialized/written.
Auto Trait Implementations§
impl Freeze for BundleCache
impl RefUnwindSafe for BundleCache
impl Send for BundleCache
impl Sync for BundleCache
impl Unpin for BundleCache
impl UnsafeUnpin for BundleCache
impl UnwindSafe for BundleCache
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