Skip to main content

IndexSlot

Struct IndexSlot 

Source
pub struct IndexSlot { /* private fields */ }
Expand description

The package index of a store, built when first asked for and kept exact by the store’s own revision.

No borrow is held across a call that could come back in: a question asked while another is being answered (a reader that calls another reader) finds the index it is already holding and uses it.

Implementations§

Source§

impl IndexSlot

Source

pub fn set_partial(&self, partial: bool)

Say that the store is not the whole package: an ETP connection holds what was fetched and nothing else.

The index is then marked incomplete (PackageIndex::is_complete is false: the index of a connection is never complete) - it answers for what was taken, and a caller that needs more asks the server. It does not change what is indexed: the store’s inventory is what it is. Sticky: it describes the store, so a rebuild keeps it, until set_partial(false) is said.

Source

pub fn forget(&self)

Drop the index and any pass in progress; the next question rebuilds.

Source

pub fn revision(&self) -> Option<u64>

The revision the index is exact for, or None when there is none yet.

Source

pub fn node_count(&self) -> Option<usize>

How many nodes the index holds; None when there is no index.

Source

pub fn is_complete(&self) -> Option<bool>

Whether the index covers the store’s whole inventory; None when there is no index.

Source

pub fn take_disturbed(&self, consumer: Consumer) -> Disturbed

What the updates of the index disturbed since this consumer last asked - and forget it. A cache of answers derived from the links asks this inside IndexSlot::with, once the index is exact for the store, and drops what it names (color_walks::ColourCache::disturb, attachments::Cache::disturb).

Source

pub fn with<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.

No index: build one, in one call. A pass started by IndexSlot::step and unfinished: finish it, then check (the store may have moved since the pass began; the check below re-reads exactly those objects). Otherwise ask the store what changed since the index’s revision: nothing, these uuids, or everything.

An ETP store is an EpcStore like another here; see IndexSlot::set_partial for what it must say about itself.

Source

pub fn step(&self, store: &EpcStore, n: usize) -> Progress

Advance the pass by n objects, and say how far it is - the worker loops, yielding between two slices, so a mesh or a click is answered in the middle of a long pass.

Begins a pass when there is no index, or when the store answers everything changed. When the index exists and only some objects changed, they are re-read at once (that is object-by-object and cheap) and the answer is done. The index is installed the moment the last slice is read; a question asked before then finishes the pass itself (IndexSlot::with), it never answers from half an index.

Trait Implementations§

Source§

impl Default for IndexSlot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, 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