use crate::validation::Validate;
use acorn_core::prelude::alloc::{String, ToString};
use acorn_core::util::{MarkdownSupport, ToProse, Unstructured};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize, Validate)]
#[serde(transparent)]
pub struct Document {
pub content: String,
}
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize, Validate)]
#[serde(transparent)]
pub struct Text {
pub content: String,
}
impl From<&str> for Text {
fn from(content: &str) -> Self {
Self {
content: content.to_string(),
}
}
}
impl From<String> for Text {
fn from(content: String) -> Self {
Self { content }
}
}
impl MarkdownSupport for Document {
fn to_markdown(&self) -> String {
self.content().to_string()
}
}
impl MarkdownSupport for Text {
fn to_markdown(&self) -> String {
self.content().to_string()
}
}
impl ToProse for Document {
fn to_prose(&self) -> String {
self.content().to_string()
}
}
impl ToProse for Text {
fn to_prose(&self) -> String {
self.content().to_string()
}
}
impl Unstructured for Document {
fn content(&self) -> &str {
&self.content
}
}
impl Unstructured for Text {
fn content(&self) -> &str {
&self.content
}
}