//! Fully resolved content shared by engines and in-memory frontends.
use crate::{Document, DocumentAddress, DocumentIndex, SemanticIndex, TldrDocument};
/// One materialized document query before any versioned process projection.
///
/// This is the in-memory handoff between the document engine and trusted
/// frontends such as `mant-ui`. External consumers receive a versioned
/// `mant-protocol` representation instead.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ResolvedContent {
/// Human-readable label suitable for terminal presentation.
pub label: String,
/// Catalog identity, absent for direct file input.
pub address: Option<DocumentAddress>,
/// Parsed authoritative document, when one was found.
pub document: Option<Document>,
/// Optional quick reference resolved alongside the document.
pub tldr: Option<TldrDocument>,
}
impl ResolvedContent {
/// Build the immutable node index used by navigation-oriented consumers.
#[must_use]
pub fn document_index(&self) -> Option<DocumentIndex> {
self.document.as_ref().map(DocumentIndex::build)
}
/// Build the source-neutral semantic entry index used by outlines and UI navigation.
#[must_use]
pub fn semantic_index(&self) -> Option<SemanticIndex> {
self.document.as_ref().map(SemanticIndex::build)
}
}