mant_ir/resolved.rs
1//! Fully resolved content shared by engines and in-memory frontends.
2
3use crate::{Document, DocumentAddress, DocumentIndex, SemanticIndex, TldrDocument};
4
5/// One materialized document query before any versioned process projection.
6///
7/// This is the in-memory handoff between the document engine and trusted
8/// frontends such as `mant-ui`. External consumers receive a versioned
9/// `mant-protocol` representation instead.
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct ResolvedContent {
12 /// Human-readable label suitable for terminal presentation.
13 pub label: String,
14 /// Catalog identity, absent for direct file input.
15 pub address: Option<DocumentAddress>,
16 /// Parsed authoritative document, when one was found.
17 pub document: Option<Document>,
18 /// Optional quick reference resolved alongside the document.
19 pub tldr: Option<TldrDocument>,
20}
21
22impl ResolvedContent {
23 /// Build the immutable node index used by navigation-oriented consumers.
24 #[must_use]
25 pub fn document_index(&self) -> Option<DocumentIndex> {
26 self.document.as_ref().map(DocumentIndex::build)
27 }
28
29 /// Build the source-neutral semantic entry index used by outlines and UI navigation.
30 #[must_use]
31 pub fn semantic_index(&self) -> Option<SemanticIndex> {
32 self.document.as_ref().map(SemanticIndex::build)
33 }
34}