Skip to main content

ObjectCache

Struct ObjectCache 

Source
pub struct ObjectCache { /* private fields */ }
Expand description

A content-addressed store of fact sets on disk.

Implementations§

Source§

impl ObjectCache

Source

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.

Source

pub fn root(&self) -> &Path

The directory this cache stores objects under.

Source

pub fn contains(&self, blob_id: &str) -> bool

Whether a fact set is cached for blob_id.

Source

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.

Source

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§

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.