Skip to main content

mant_protocol/
navigation.rs

1//! Typed local document-opening data for explicitly authorized interactive hosts.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::DocumentAddress;
7
8/// An interactive request to load a local document, not permission to execute it.
9///
10/// An unresolved manual remains explicitly manual-only: a same-named Markdown
11/// document must not shadow it, and the UI must not invent a manual section.
12/// Fragment validation is performed against the loaded document before the
13/// interactive host commits a navigation change. MCP never executes this action.
14#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
15#[serde(
16    tag = "kind",
17    rename_all = "kebab-case",
18    rename_all_fields = "camelCase",
19    deny_unknown_fields
20)]
21pub enum DocumentOpenTarget {
22    /// An exact already-qualified local catalog address.
23    Address {
24        /// Logical address, never an arbitrary filesystem path.
25        address: DocumentAddress,
26    },
27    /// A manual topic resolved with manual-only policy by the embedding host.
28    Manual {
29        /// Original manual name, not its displayed link label.
30        name: String,
31        /// Exact requested manual section, or unresolved when absent.
32        #[serde(default, skip_serializing_if = "Option::is_none")]
33        manual_section: Option<String>,
34    },
35}
36
37impl From<DocumentAddress> for DocumentOpenTarget {
38    fn from(address: DocumentAddress) -> Self {
39        Self::Address { address }
40    }
41}