pub struct ScanCache { /* private fields */ }Expand description
A persistent agenda-result cache for one source.
Implementations§
Source§impl ScanCache
impl ScanCache
Sourcepub fn open(dir: &Path, source_id: u64) -> Self
pub fn open(dir: &Path, source_id: u64) -> Self
Open (or start) the cache for source_id under dir.
Never fails: an unreadable, corrupt or stale file yields an empty cache
with a debug log. dir is the host’s per-plugin data directory, so
two plugins cannot collide and uninstalling one removes its cache.
Sourcepub fn begin(&mut self, generation: u64)
pub fn begin(&mut self, generation: u64)
Start a scan under generation (the guest’s begin return value).
A changed generation means every cached row was computed against something that no longer holds — for org, a different day or a different keyword set — so the whole cache is dropped rather than partially trusted.
Sourcepub fn get(
&mut self,
path: &str,
text: &str,
) -> Option<(Vec<Entry>, Vec<ClockSpan>)>
pub fn get( &mut self, path: &str, text: &str, ) -> Option<(Vec<Entry>, Vec<ClockSpan>)>
Cached rows + clock spans for path, if the text still hashes the same.
Sourcepub fn put(
&mut self,
path: &str,
text: &str,
rows: &[Entry],
clock: &[ClockSpan],
)
pub fn put( &mut self, path: &str, text: &str, rows: &[Entry], clock: &[ClockSpan], )
Remember what the guest returned for path.
Sourcepub fn flush(&mut self)
pub fn flush(&mut self)
Write the cache out. Best-effort: a failure is logged and dropped, because a cache that cannot be written is only a slower next scan.
Written to a temporary file and renamed, so a kill mid-write leaves the previous cache intact rather than a truncated file the next boot has to recognise as corrupt.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScanCache
impl RefUnwindSafe for ScanCache
impl Send for ScanCache
impl Sync for ScanCache
impl Unpin for ScanCache
impl UnsafeUnpin for ScanCache
impl UnwindSafe for ScanCache
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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