Skip to main content

PlanIndex

Struct PlanIndex 

Source
pub struct PlanIndex<'d> { /* private fields */ }
Expand description

A plan document’s id lookups, built and validated once.

Transient by construction: it borrows the document, so it is built where it is used and dropped there. That is already what every hand-rolled copy of this map did — the difference is that the ids are checked on the way in, so every accessor below is total and none of them can panic.

Implementations§

Source§

impl<'d> PlanIndex<'d>

Source

pub fn build(doc: &'d PlanDocument) -> Result<Self, EngineError>

Build, validating every id the document refers to: hunk ids parse and are in range, class ids referenced by groups exist.

Before this existed the two renderers disagreed about a broken document — crates/stack panicked on an unresolvable class reference and the TUI silently dropped it, so a corrupt store showed a short group with no indication anything was missing.

Source

pub fn doc(&self) -> &'d PlanDocument

Source

pub fn groups(&self) -> &'d [Group]

The document’s groups, or an empty slice for a core-only document.

Source

pub fn class(&self, id: &str) -> &'d ClassEntry

Total: build proved every referenced class id resolves.

Source

pub fn hunk(&self, h: HunkId) -> &'d HunkEntry

Total: build proved every hunk id is in range.

Source

pub fn exemplar(&self, class_id: &str) -> HunkId

Source

pub fn class_hunks(&self, class_id: &str) -> Vec<HunkId>

Source

pub fn group_hunks(&self, group: &Group) -> Vec<HunkId>

Group members in class order — the order both renderers already emit.

Source

pub fn file_hunks(&self, file: &FileEntry) -> Vec<HunkId>

Auto Trait Implementations§

§

impl<'d> Freeze for PlanIndex<'d>

§

impl<'d> RefUnwindSafe for PlanIndex<'d>

§

impl<'d> Send for PlanIndex<'d>

§

impl<'d> Sync for PlanIndex<'d>

§

impl<'d> Unpin for PlanIndex<'d>

§

impl<'d> UnsafeUnpin for PlanIndex<'d>

§

impl<'d> UnwindSafe for PlanIndex<'d>

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> Same for T

Source§

type Output = T

Should always be Self
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.