Skip to main content

moss_core/resolve/
title_params.rs

1//! In-process typed-params struct for moss embed synthesizers.
2//!
3//! Phase 3 PR4 (2026-05-27): the `moss:` title-attribute channel
4//! retired. Stage 1 no longer encodes typed params into markdown image
5//! titles; Stage 2 wikilink dispatch reads typed params directly from
6//! pulldown-cmark's `LinkType::WikiLink` pothole text (parsed by
7//! [`super::wikilink_dispatch::parse_pothole_params`]).
8//!
9//! What survives in this module:
10//!
11//! - [`TitleParams`] — the typed-param key/value bag. Every per-kind
12//!   synthesizer (`render/iframe.rs`, `audio.rs`, `pdf.rs`, `video.rs`,
13//!   `model.rs`, image via `render/image.rs`) takes `&TitleParams` as
14//!   its first argument. The dispatcher constructs an instance from the
15//!   wikilink pothole and hands it to the synth function.
16//!
17//! What retired:
18//!
19//! - `parse_title` (deserialized `moss:K=V K=V` from a markdown title) —
20//!   no consumer remains. Wikilink potholes are parsed by
21//!   [`super::wikilink_dispatch::parse_pothole_params`] instead.
22//! - `emit_title` — Phase 3 PR4.5 (2026-05-27): retired with no
23//!   surviving caller. PR3 removed `format_img_tag` (the last producer);
24//!   PR4 dropped `parse_title` (the last consumer); PR4.5 routes
25//!   non-image wikilink embeds directly to synth, removing the final
26//!   transitional hold on the `moss:` markdown round-trip.
27
28use std::collections::BTreeMap;
29
30#[derive(Debug, Default, Clone, PartialEq, Eq)]
31pub struct TitleParams {
32    pub params: BTreeMap<String, String>,
33}
34
35impl TitleParams {
36    pub fn get(&self, key: &str) -> Option<&str> {
37        self.params.get(key).map(String::as_str)
38    }
39
40    pub fn is_empty(&self) -> bool {
41        self.params.is_empty()
42    }
43
44    pub fn insert(&mut self, k: impl Into<String>, v: impl Into<String>) {
45        self.params.insert(k.into(), v.into());
46    }
47}