pub struct Cache {
pub root: PathBuf,
pub session: String,
pub st: State,
pub job: Option<usize>,
pub born: Instant,
/* private fields */
}Expand description
st is a snapshot; every change goes through alloc / save, which re-read state.json under the session
lock, so parallel agents in one session never overwrite each other’s ids.
Fields§
§root: PathBuf§session: String§st: State§job: Option<usize>This invocation’s job, created by the first page it stores: every page of one command shares it.
born: InstantWhen this command opened the cache (cli::run, one MCP call): its wait: deadline (cli::wait_for).
Implementations§
Source§impl Cache
impl Cache
pub fn open() -> Cache
pub fn at(root: PathBuf, session: String) -> Cache
Sourcepub fn meta(&self, dir: &str) -> Option<Meta>
pub fn meta(&self, dir: &str) -> Option<Meta>
The meta.json of the snapshot in dir (an entry’s, a lookup’s), read once a command: a snapshot’s never
changes once stored.
pub fn run_file(&self, n: usize, ext: &str) -> PathBuf
Sourcepub fn run(&self, n: usize) -> Option<(Detached, bool)>
pub fn run(&self, n: usize) -> Option<(Detached, bool)>
Detached run n and whether it lives (run_at).
pub fn run_put(&self, n: usize, r: &Detached) -> Result<(), String>
Sourcepub fn run_tell(&self, n: usize)
pub fn run_tell(&self, n: usize)
Run n’s end was shown (cli::footer): the file read again after the lock is probed, written when the lock
is free or the file holds done (the run’s last write: its lock outlives it while the process exits, on
Windows until its launcher reaps it); a busy lock and no done = it runs (or a reader probes): told next time.
Sourcepub fn run_claim(&self, n: usize) -> Option<File>
pub fn run_claim(&self, n: usize) -> Option<File>
Run n’s lock, taken by its launcher (cli::launch) and handed to the run (cli::detach: the process’s stdin,
so held until it ends; on Windows the launcher keeps it and the run takes it again; a reader’s probe only delays
it). Its log (run_file(n, "log")) takes the process’s stdout + stderr.
Sourcepub fn save(&mut self) -> Result<(), String>
pub fn save(&mut self) -> Result<(), String>
Persist the cursor if this command moved it (read-only commands write nothing).
Sourcepub fn read_mark(&mut self, n: usize, read: &[String]) -> Result<(), String>
pub fn read_mark(&mut self, n: usize, read: &[String]) -> Result<(), String>
Log a part of u<n> as read (Entry::read): its id tail (#2ft) and its text’s key (outline::part_key).
Sourcepub fn hit_mark(&mut self, n: usize, j: usize) -> Result<(), String>
pub fn hit_mark(&mut self, n: usize, j: usize) -> Result<(), String>
Job j read page n from the cache (cli::cached), logged once: a job naming the URL twice, or the job
that fetched it, adds nothing.
Sourcepub fn alloc(
&mut self,
es: Vec<Entry>,
slot: Option<usize>,
) -> Result<usize, String>
pub fn alloc( &mut self, es: Vec<Entry>, slot: Option<usize>, ) -> Result<usize, String>
Append entries (or fill slot, see place): the first one’s 1-based u number, unique even with parallel
writers.
Sourcepub fn serp_put(
&self,
job: usize,
meta: &Meta,
error: Option<&[u8]>,
) -> Result<(), String>
pub fn serp_put( &self, job: usize, meta: &Meta, error: Option<&[u8]>, ) -> Result<(), String>
Store search job‘s record (hits inside) and its providers’ error answers; health and stats read it
like a fetch’s.
Sourcepub fn serps(&self) -> Vec<(usize, Meta)>
pub fn serps(&self) -> Vec<(usize, Meta)>
This session’s searches, oldest first: (job, record).
Sourcepub fn lookup(&self, url: &str) -> Option<(String, f64)>
pub fn lookup(&self, url: &str) -> Option<(String, f64)>
Indexed snapshot of a URL (or a local file’s content key, blake3:): (dir, age in s), while it lives
(expired) and is the page asked for: its meta.json names that URL, never another page in a reused dir.
Sourcepub fn job_of(&mut self, cmd: &str) -> Result<usize, String>
pub fn job_of(&mut self, cmd: &str) -> Result<usize, String>
New global job id for a fetch-type command.
The invocation’s job number (j8), registered on first use.
Sourcepub fn job(&self, j: usize) -> Option<Job>
pub fn job(&self, j: usize) -> Option<Job>
Job j (1-based); None when unknown or its session name would leave the cache root.
pub fn job_count(&self) -> usize
Sourcepub fn dir(&self, e: &Entry) -> Option<PathBuf>
pub fn dir(&self, e: &Entry) -> Option<PathBuf>
THE read of a stored dir (page, lookup, serp, cli::seen, stats): an entry’s snapshot dir, under the
root (None when state.json, or a symlink in the cache, points outside it) and not expired.
Sourcepub fn page(&self, e: &Entry) -> (Meta, Result<Doc, NoDoc>)
pub fn page(&self, e: &Entry) -> (Meta, Result<Doc, NoDoc>)
meta + doc of an entry; doc.json is rebuilt from the body (raw_name of its kind) when missing or of another
schema version.
Sourcepub fn ingest(
&mut self,
snap: Snap<'_>,
job: usize,
t0: Instant,
) -> Result<usize, String>
pub fn ingest( &mut self, snap: Snap<'_>, job: usize, t0: Instant, ) -> Result<usize, String>
Store a fetched/local body as the next u of this session (or in Snap::slot). The snapshot is written to a
private temp dir first and renamed to u<N> under the session lock; an existing dir is never touched
(u<N>-2 instead). t0 = when the command started: a hop without ms gets the elapsed time. Storage
only: the caller builds the doc first, so every error from here is a cache write error.
Auto Trait Implementations§
impl !Freeze for Cache
impl !RefUnwindSafe for Cache
impl !Sync for Cache
impl Forget for Cache
impl Send for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.