Skip to main content

KnowledgeBaseIndex

Struct KnowledgeBaseIndex 

Source
pub struct KnowledgeBaseIndex {
    pub pages: HashMap<PageId, PageMeta>,
    pub sorted_ids: Vec<PageId>,
    pub index_issues: Vec<ParseIssue>,
    /* private fields */
}
Expand description

Indexed knowledge base metadata with lazy page loading.

Fields§

§pages: HashMap<PageId, PageMeta>

Metadata map keyed by canonical page id.

§sorted_ids: Vec<PageId>

Page ids in case-insensitive title sort order, computed once at open time.

§index_issues: Vec<ParseIssue>

Non-fatal issues encountered while scanning metadata.

Implementations§

Source§

impl KnowledgeBaseIndex

Source

pub fn register_page(&mut self, meta: PageMeta)

Registers a page in the index, inserting it at the correct sorted position via binary search instead of re-sorting the entire list. If the page already exists, its old sort position is removed first so re-registration never creates duplicates (and handles title changes correctly).

Source

pub fn load_page(&self, id: &str) -> Result<Page>

Loads and parses a single page by canonical id.

Returns an error if the id is missing from the index or if JSON parsing fails.

Source

pub fn sorted_pages(&self) -> Vec<&PageMeta>

Returns metadata entries in cached title-sorted order.

Source

pub fn filter_page_ids(&self, query: &str) -> Vec<PageId>

Returns page ids filtered by metadata query (title/id/tags), sorted by title.

Source

pub fn filter_page_ids_scored( &self, query: &str, ) -> Vec<(PageId, SearchMatchKind)>

Returns page ids with their match kinds, filtered by metadata query.

Source

pub fn search_hits(&self, query: &str, include_content: bool) -> Vec<SearchHit>

Searches pages by metadata and optionally content, returning hits ranked by relevance (title > tag > content), with ties broken alphabetically by title.

Source

pub fn resolve_page_id_by_title(&self, title: &str) -> TitleResolution

Resolves a page id from title using case-insensitive exact match, then partial match.

Classifies a raw link target for navigation/open behavior.

Builds the reverse link index by loading every page, extracting link targets, classifying them, and recording which pages link to which.

Call this once after KnowledgeBase::open when backlink data is needed.

Incrementally updates the backlinks index for a single page.

Removes any existing outgoing links from page_id, then re-extracts and classifies its current links. Much cheaper than a full Self::build_backlinks call when only one page changed.

Returns the page ids that link to the given page, sorted by title.

Builds the full directed link graph across all pages.

Each edge represents one internal page-to-page link (deduplicated per source/target pair). Self-links are excluded.

Source

pub fn root(&self) -> &Path

Returns the root path used to build this index.

Source

pub fn attachment_resolver(&self) -> AttachmentResolver

Returns an attachment resolver rooted at this knowledge base.

Source

pub fn scan_all_pages(&self) -> LinkAnalysisResult

Scans all pages in a single pass, collecting broken links, linked pages, link graph edges, missing attachments, and load errors.

Source

pub fn analyze_all(&self) -> LinkAnalysisResult

Analyzes all pages, collecting broken links, linked pages, missing attachments, and load errors.

Analyzes all links in the knowledge base, collecting broken links, the set of pages linked to by at least one other page, and any pages that could not be loaded.

Source

pub fn orphan_ids( &self, linked_pages: &HashSet<PageId>, toc_page_id: &str, ) -> Vec<PageId>

Returns page ids that are not linked to by any other page.

The toc_page_id (table-of-contents) is excluded from the result since it serves as the root entry point and is not expected to be linked to.

Source

pub fn find_duplicate_titles(&self) -> Vec<DuplicateTitle>

Finds page titles shared by more than one page (case-insensitive).

Source

pub fn find_missing_attachments(&self) -> Vec<MissingAttachment>

Finds attachment references whose files are missing from disk.

Trait Implementations§

Source§

impl Clone for KnowledgeBaseIndex

Source§

fn clone(&self) -> KnowledgeBaseIndex

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 KnowledgeBaseIndex

Source§

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

Formats the value using the given formatter. 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> 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.