Skip to main content

DocIndex

Struct DocIndex 

Source
pub struct DocIndex {
    built_from: Option<DocStamp>,
    pub blocks: HashMap<BlockId, BlockIndex>,
    pub routes: HashMap<RouteId, RouteIndex>,
    pub routes_by_endpoint: HashMap<PinId, HashSet<RouteId>>,
}
Expand description

The derived index over the whole document — never authoritative. A child whose owner has been deleted is indexed nowhere (its owner has no entry).

Owned, and stamp-gated through Self::view: the third instance of the pattern the app already runs for its spatial tree (CachedIndex) and its route-accent propagation (PinAccents) — kept across frames, rebuilt from the document value alone, so no mutation site has to remember to invalidate it.

Fields§

§built_from: Option<DocStamp>

None until the first build; the empty index describes no document, not the empty one.

§blocks: HashMap<BlockId, BlockIndex>

Every block’s scope, plus the document root under Id::NULL — whose children are the top-level blocks and whose other sets hold the entities owned by the root directly. A row here is a scope, which the root is and a block also is; Self::holds_block is the other question.

§routes: HashMap<RouteId, RouteIndex>§routes_by_endpoint: HashMap<PinId, HashSet<RouteId>>

Every route, keyed by both endpoint pins — the adjacency the delete cascade and pin drags ask for.

Implementations§

Source§

impl DocIndex

Source

pub fn of(doc: &Document) -> Self

One linear pass over every kind. The ad-hoc path, for a caller with nowhere to keep an index between document values; a caller that has somewhere keeps one and calls Self::view.

Source

pub fn scope(&self, id: BlockId) -> Option<&BlockIndex>

The contents of scope: a block’s interior, or the document root (Id::NULL). Every block has a row and so does the root, so a None here means the scope is gone, never that it is the root.

Source

pub fn holds_block(&self, id: BlockId) -> bool

Whether id names a block the document holds. The root’s row is a scope without an entity behind it — nothing can delete, move, or rename it — so it answers false here while still answering Self::scope.

Source

pub fn view<'a>(&'a mut self, doc: &'a Document) -> IndexedDocument<'a>

doc bundled with this index, rebuilt first unless it was already built from that very document value.

Source

pub fn view_of<'a>(&'a self, doc: &'a Document) -> Option<IndexedDocument<'a>>

The view over the document value this index was built from, and None for any other — the read-only door, for a caller holding a document and an index it built together and with no &mut to rebuild through. Refusing the mismatched pair is the whole point: it is the same check Self::view makes, minus the repair.

Trait Implementations§

Source§

impl Default for DocIndex

Source§

fn default() -> DocIndex

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.