//! Markdown content value object. use serde::{Deserialize, Serialize}; /// A Markdown document — the content of an agent context (`.md`) or a template. /// /// This is a thin newtype: the domain treats Markdown as opaque text and does /// not parse it. It exists to give the content a meaningful type at API /// boundaries (vs. a bare `String`). #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] #[serde(transparent)] pub struct MarkdownDoc(String); impl MarkdownDoc { /// Wraps raw Markdown content (empty content is permitted). #[must_use] pub fn new(content: impl Into) -> Self { Self(content.into()) } /// Returns the content as a string slice. #[must_use] pub fn as_str(&self) -> &str { &self.0 } /// Consumes the document, returning its content. #[must_use] pub fn into_string(self) -> String { self.0 } /// Returns `true` if the document is empty. #[must_use] pub fn is_empty(&self) -> bool { self.0.is_empty() } } impl From for MarkdownDoc { fn from(s: String) -> Self { Self(s) } }