pub struct ObjectCache { /* private fields */ }Expand description
A content-addressed store of fact sets on disk.
Implementations§
Source§impl ObjectCache
impl ObjectCache
Sourcepub fn open(root: impl Into<PathBuf>) -> Result<Self, CacheError>
pub fn open(root: impl Into<PathBuf>) -> Result<Self, CacheError>
Open (creating if absent) a cache rooted at root.
§Errors
Returns CacheError::Io if the root directory cannot be created.
Sourcepub fn get(&self, blob_id: &str) -> Result<Option<FactSet>, CacheError>
pub fn get(&self, blob_id: &str) -> Result<Option<FactSet>, CacheError>
Load the cached fact set for blob_id, if present.
§Errors
Returns CacheError::Io on read failure or CacheError::Json if the
entry cannot be decoded.
Sourcepub fn put(&self, blob_id: &str, facts: &FactSet) -> Result<(), CacheError>
pub fn put(&self, blob_id: &str, facts: &FactSet) -> Result<(), CacheError>
Store facts under blob_id, replacing any existing entry. The write is
atomic (write-to-temp then rename) so a crash never leaves a torn entry.
§Errors
Returns CacheError::Io on write failure or CacheError::Json if
facts cannot be encoded.
Auto Trait Implementations§
impl Freeze for ObjectCache
impl RefUnwindSafe for ObjectCache
impl Send for ObjectCache
impl Sync for ObjectCache
impl Unpin for ObjectCache
impl UnsafeUnpin for ObjectCache
impl UnwindSafe for ObjectCache
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