use serde::{Deserialize, Serialize};
pub type Uri = String;
pub const ROOT_RESOURCE_URI: &str = "ahp-root://";
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StringOrMarkdown {
Plain(String),
Markdown {
markdown: String,
},
}
impl Default for StringOrMarkdown {
fn default() -> Self {
Self::Plain(String::new())
}
}
impl StringOrMarkdown {
pub fn as_text(&self) -> &str {
match self {
Self::Plain(s) => s,
Self::Markdown { markdown } => markdown,
}
}
pub fn push_str(&mut self, more: &str) {
match self {
Self::Plain(s) => s.push_str(more),
Self::Markdown { markdown } => markdown.push_str(more),
}
}
}
impl From<String> for StringOrMarkdown {
fn from(s: String) -> Self {
Self::Plain(s)
}
}
impl From<&str> for StringOrMarkdown {
fn from(s: &str) -> Self {
Self::Plain(s.to_owned())
}
}
pub type JsonObject = serde_json::Map<String, serde_json::Value>;
pub type AnyValue = serde_json::Value;