Skip to main content

InMemoryIndex

Struct InMemoryIndex 

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

A simple in-memory registry — for tests and ephemeral workspaces. No tombstones: an unregistered ID is forgotten entirely.

Implementations§

Source§

impl InMemoryIndex

Source

pub fn new() -> InMemoryIndex

An empty registry.

Source

pub fn len(&self) -> usize

The number of registered IDs.

Source

pub fn is_empty(&self) -> bool

Whether the registry is empty.

Trait Implementations§

Source§

impl Clone for InMemoryIndex

Source§

fn clone(&self) -> InMemoryIndex

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InMemoryIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for InMemoryIndex

Source§

fn default() -> InMemoryIndex

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

impl IdIndex for InMemoryIndex

Source§

fn resolve(&self, id: &Id) -> Option<PathBuf>

Resolve an ID to its current path. None for unknown and tombstoned IDs — use is_known to tell them apart.
Source§

fn id_for_path(&self, path: &Path) -> Option<Id>

The ID currently assigned to path, if any.
Source§

fn is_known(&self, id: &Id) -> bool

Whether id has ever been issued — live or tombstoned. This is the mint-with-rejection predicate: a fresh ID must be !is_known.
Source§

impl IndexStore for InMemoryIndex

Source§

fn register(&mut self, id: &Id, path: &Path)

Displacing an existing registration must not leave the other map pointing at the old counterpart — set_path delegates here for exactly this care. Without it a collision leaves the registry claiming two paths for one id (or two ids for one path), which nothing downstream can make sense of.

Eviction is the last line of defence, not the intended path: callers that register (or move, via set_path) an id they did not just mint should ask prov’s Workspace::registration_conflict or prov’s Workspace::move_conflict first and refuse, because the document being displaced still spells the id in its own frontmatter. What this guarantees is only that the index stays consistent when something slips through.

Source§

fn set_path(&mut self, id: &Id, new_path: &Path)

Moving an id onto a path is the same bijection-safe upsert as registering it there fresh — displacing in either direction must not leave the other map pointing at the old counterpart — so this is register, not a near-duplicate of it. Before this delegated, a displacement in the new-path direction went unevicted: new_path’s previous id kept a forward entry pointing at a path it no longer owned, the exact two-ids-one-path break register was fixed against in 11abd38.

Source§

fn committed(&mut self, _persisted: bool)

Nothing here is ever persisted, so persisted is irrelevant — but the checkpoint must still be dropped on every success.

Source§

fn unregister(&mut self, id: &Id)

Retire an ID (e.g. after a delete). A store with tombstones keeps the ID on record so it is never reissued; a plain store may forget it.
Source§

fn checkpoint(&mut self)

Snapshot the store, so a mutation that fails can put it back. Called before an op touches the index; paired with exactly one rollback or committed.
Source§

fn rollback(&mut self)

Restore the last checkpoint — the mutation failed and its writes were unwound, so the in-memory store must forget it too, or it would claim a move that never happened.
Source§

fn rebase(&mut self, cs: &dyn Rebase) -> Result<(), Error>

Follow the mutation’s change set to wherever it leaves this store’s home. Read more
Source§

fn pending_write(&mut self) -> Result<Option<(PathBuf, String)>, Error>

The write that would persist this store, as (path, full new text) — staged into the mutation’s change set and applied with it. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.