Skip to main content

Cache

Struct Cache 

Source
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: Instant

When this command opened the cache (cli::run, one MCP call): its wait: deadline (cli::wait_for).

Implementations§

Source§

impl Cache

Source

pub fn open() -> Cache

Source

pub fn at(root: PathBuf, session: String) -> Cache

Source

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.

Source

pub fn reload(&mut self)

Re-read state.json: a detached fetch filled an id.

Source

pub fn run_file(&self, n: usize, ext: &str) -> PathBuf

Source

pub fn run(&self, n: usize) -> Option<(Detached, bool)>

Detached run n and whether it lives (run_at).

Source

pub fn run_put(&self, n: usize, r: &Detached) -> Result<(), String>

Source

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.

Source

pub fn runs(&self) -> Vec<(usize, Detached, bool)>

This session’s runs: (n, run, alive).

Source

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.

Source

pub fn save(&mut self) -> Result<(), String>

Persist the cursor if this command moved it (read-only commands write nothing).

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn serp(&self, job: usize) -> Option<Meta>

Search job’s record in this session.

Source

pub fn serps(&self) -> Vec<(usize, Meta)>

This session’s searches, oldest first: (job, record).

Source

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.

Source

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.

Source

pub fn job(&self, j: usize) -> Option<Job>

Job j (1-based); None when unknown or its session name would leave the cache root.

Source

pub fn job_count(&self) -> usize

Source

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.

Source

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.

Source

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more