pub struct Cache { /* private fields */ }Expand description
What a package keeps of itself: one per open store, with the layers it was made with.
Methods take &self - a face’s methods do, and wasm is single-threaded -
and no borrow is held across a call that could come back in: a question
asked while another is being answered finds the slot held and answers from
one of its own, as IndexSlot::with does.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn ladders(
&self,
store: &EpcStore,
rows: &[Row<'_>],
) -> Result<Option<Vec<Ladder>>, Error>
pub fn ladders( &self, store: &EpcStore, rows: &[Row<'_>], ) -> Result<Option<Vec<Ladder>>, Error>
The ladders of rows, in order, from the walks the cache keeps: one
walker for all of them, the walk of an object done once, a target the
tiers already read does not answer resuming it. None when the package
holds no GraphicalInformationSet - the caller answers null per row.
Sourcepub fn file_colours_at(
&self,
store: &EpcStore,
names: &[String],
) -> Result<HashMap<String, Option<String>>, Error>
pub fn file_colours_at( &self, store: &EpcStore, names: &[String], ) -> Result<HashMap<String, Option<String>>, Error>
The colour the file gives each object names name, as the 3D view’s
ladder decides it (a constant colour, #rrggbbaa, or None when no
rung answers or the answer is a map), keyed by the object’s full uri
(the name itself for an object the package does not hold). One walker
for the lot, from the walks the cache keeps: what the section view asks
instead of walking again.
A name that fits two versions is refused by name. What each version answers is bounded by the walk beneath, which compares uuids: the answers are two, one per uri, and they agree until the domain’s walk is keyed by identity too.
Sourcepub fn file_colours(
&self,
store: &EpcStore,
uuids: &[String],
) -> Result<HashMap<String, Option<String>>, Error>
pub fn file_colours( &self, store: &EpcStore, uuids: &[String], ) -> Result<HashMap<String, Option<String>>, Error>
Cache::file_colours_at for the callers that hold a bare uuid: the
answer is keyed by the lowercase uuid asked. A uuid the package
holds in two versions is refused by name; ask by uri.
Sourcepub fn decision(
&self,
store: &EpcStore,
set: &GraphicalSet,
representation: &str,
property: Option<&str>,
chain: &[String],
options: &Options,
) -> Result<Option<Decision>, Error>
pub fn decision( &self, store: &EpcStore, set: &GraphicalSet, representation: &str, property: Option<&str>, chain: &[String], options: &Options, ) -> Result<Option<Decision>, Error>
The colour rule, once: what one object - or one property of it -
inherits, by the inheritance-resolution order: the object, its
collections, its parents and theirs, then the model; for a property, its
kind and the kind’s parents and nothing beyond. The answer carries its
level; the notes of the walk join the decision’s. None means no level
answered - an answer, not a failure: the standard defines no default
colour.
representation is a uuid - an entry’s target is one, and the walk
up to the interpretation and the feature yields them; passing the uri
(which the front end once did) meant a colour set on the
representation itself was never found. A caller that holds the uri asks
Cache::decision_at, which turns it into that key. chain is the property’s kind
chain (kind_chain). set is read by the caller, once, for many
questions (graphical_set).
Sourcepub fn decision_at(
&self,
store: &EpcStore,
set: &GraphicalSet,
name: &str,
property: Option<&str>,
chain: &[String],
options: &Options,
) -> Result<Option<Decision>, Error>
pub fn decision_at( &self, store: &EpcStore, set: &GraphicalSet, name: &str, property: Option<&str>, chain: &[String], options: &Options, ) -> Result<Option<Decision>, Error>
Cache::decision for the object name names: its full uri (a
short uri or a bare uuid are adapters, refused by name when they fit two
versions). The one place a uri becomes the walk’s key.
Sourcepub fn colour_walk_stats(&self) -> Stats
pub fn colour_walk_stats(&self) -> Stats
What the colour walks did so far - walks begun and dropped, tiers read, objects read. Work, not time: what a test asserts to say a walk was not done twice, and what an invalidation cost.
Source§impl Cache
impl Cache
Sourcepub fn off() -> Self
pub fn off() -> Self
A cache that keeps nothing: every lookup is a branch, every answer is computed from the store.
Sourcepub fn new(layers: Layers) -> Self
pub fn new(layers: Layers) -> Self
A cache with these layers on (see Layers::normalised).
Sourcepub fn with_index<R>(
&self,
store: &EpcStore,
f: impl FnOnce(&PackageIndex) -> R,
) -> R
pub fn with_index<R>( &self, store: &EpcStore, f: impl FnOnce(&PackageIndex) -> R, ) -> R
Run f on an index that is exact for store - the invalidation rule
of ADR-0010 (see index). With the index layer off, the index is
built for this call and dropped after it.
Sourcepub fn index_step(&self, store: &EpcStore, n: usize) -> Progress
pub fn index_step(&self, store: &EpcStore, n: usize) -> Progress
Advance the index’s build by n objects, and say how far it is. A cache
whose index layer is off builds nothing between questions and answers
nothing to do.
Sourcepub fn set_partial(&self, partial: bool)
pub fn set_partial(&self, partial: bool)
Say that the store is not the whole package - see
IndexSlot::set_partial.
Sourcepub fn attachments_of(&self, store: &EpcStore, uuids: &[&str]) -> Vec<Listing>
pub fn attachments_of(&self, store: &EpcStore, uuids: &[&str]) -> Vec<Listing>
The listing of what is attached to each of uuids, in order.
Why the listing cache is held from energyml-domain, not moved:
what a listing reads, and what drops it, is the domain’s algorithm
(attachments::Cache and its own tests); this crate decides only
whether a cache is kept between questions, and which account of the
index’s disturbances it reads. With the layer off the cache is a fresh
one, dropped after the call.
Sourcepub fn attachment_stats(&self) -> CacheStats
pub fn attachment_stats(&self) -> CacheStats
What the listing cache did so far - listings built and dropped, files read. Work, not time.