Skip to main content

BuildCache

Struct BuildCache 

Source
pub struct BuildCache { /* private fields */ }

Implementations§

Source§

impl BuildCache

Source

pub fn new( cache_dir: PathBuf, max_size_mb: usize, expiration_hours: u64, config_fingerprint: &str, ) -> Result<Self>

Source

pub fn cache_dir(&self) -> &Path

The cache directory this cache was constructed with (post config- fingerprint validation/wipe). Callers that persist their own files alongside the document cache – e.g. BuildEnvironment::save’s env.bin – ride the same directory and are therefore covered by the same fingerprint-mismatch wipe.

Source

pub fn config_changed(&self) -> bool

Whether this cache directory’s stored fingerprint disagreed with the configuration it was opened with — the whole directory was then discarded, this build’s documents, doctrees and env.bin included.

A first build counts too (there is no stored fingerprint to agree with), and in that case the effect matches Sphinx’s CONFIG_NEW: nothing carried over from a previous build is usable, so every document is outdated.

The resemblance stops there, and deliberately so. Sphinx’s CONFIG_CHANGED (environment/__init__.py:366-369) fires only for config values whose rebuild class is 'env' and never deletes doctrees, the environment or the intersphinx cache; this crate compares one whole-configuration digest and wipes the directory. The digest is therefore taken over a filtered configuration — see builder::EXCLUDED_FROM_FINGERPRINT — so that operational flags (-W, -n), which Sphinx cannot invalidate on, cannot invalidate here either.

Source

pub fn get_document(&self, file_path: &Path) -> Result<Document>

Source

pub fn get_document_with<T>( &self, file_path: &Path, accept: impl FnOnce(&Document) -> Option<T>, ) -> Option<(Document, T)>

Look up a cached document, letting the caller have the final say.

accept runs only after the entry passed the cache’s own checks (content+mtime hash, expiry). Returning None from it means the caller cannot actually use the entry — because some companion state it needs is missing, say — and the lookup is then counted and reported as a miss, not a hit: a “hit” the build has to redo anyway is not a hit. Anything accept computes from the document (loading that companion state) comes back alongside it, so callers don’t have to do the work twice.

Source

pub fn store_document( &self, file_path: &Path, document: &Document, ) -> Result<()>

Source

pub fn invalidate(&self, file_path: &Path)

Source

pub fn clear(&self) -> Result<()>

Empty the cache, in memory and on disk (-E, --clean).

The fingerprint file is written back immediately: it records which configuration the directory belongs to, and leaving it missing would make the next build mistake this deliberate emptying for a configuration change and throw away everything the build that follows this one is about to cache.

Source

pub fn hit_count(&self) -> usize

Source

pub fn miss_count(&self) -> usize

Source

pub fn hit_ratio(&self) -> f64

Source

pub fn size_mb(&self) -> f64

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.