Skip to main content

SemanticQuery

Trait SemanticQuery 

Source
pub trait SemanticQuery {
    type NodeId: Copy + Eq + Hash;

    // Required methods
    fn title(&self) -> Option<&str>;
    fn language(&self) -> Option<&Lang>;
    fn headings<'a>(&'a self) -> Box<dyn Iterator<Item = HeadingInfo> + 'a>;
    fn links<'a>(&'a self) -> Box<dyn Iterator<Item = LinkInfo> + 'a>;
    fn anchors<'a>(&'a self) -> Box<dyn Iterator<Item = AnchorInfo> + 'a>;
    fn nodes_by_role<'a>(
        &'a self,
        role: SemanticRole,
    ) -> Box<dyn Iterator<Item = Self::NodeId> + 'a>;
    fn text_range(&self, node: Self::NodeId) -> Option<&str>;
    fn source_range(&self, node: Self::NodeId) -> Option<SourceRange>;
}
Expand description

Common-minimum semantic queries every lane with a document publishes. The trait is generic over NodeId so consumers that hold a concrete impl can index without boxing; engine-agnostic dispatch (Hekate) reads SourceNodeId via the inferred as_source_id helper each impl defines.

Required Associated Types§

Required Methods§

Source

fn title(&self) -> Option<&str>

Document title (HTML <title>, Atom <title>, RSS channel title, Gemini frontmatter title, Scroll frontmatter, etc.).

Source

fn language(&self) -> Option<&Lang>

Document language (HTML lang attribute, Atom xml:lang, etc.). BCP 47 tag.

Source

fn headings<'a>(&'a self) -> Box<dyn Iterator<Item = HeadingInfo> + 'a>

Heading hierarchy. Lane impls pick their own ordering — most will iterate in document order.

Outbound links.

Source

fn anchors<'a>(&'a self) -> Box<dyn Iterator<Item = AnchorInfo> + 'a>

Named anchors (<a name>, #fragment-target headings, etc.).

Source

fn nodes_by_role<'a>( &'a self, role: SemanticRole, ) -> Box<dyn Iterator<Item = Self::NodeId> + 'a>

Nodes matching a generic semantic role (e.g., Main, Navigation). Useful for reader-mode extraction.

Source

fn text_range(&self, node: Self::NodeId) -> Option<&str>

Text content of a node, if it has any (text leaf, headings, link text).

Source

fn source_range(&self, node: Self::NodeId) -> Option<SourceRange>

Source-byte range a node corresponds to. Lanes that don’t track source spans return None.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§