html_site_generator/html/
mod.rs

1use std::fmt::Debug;
2use std::io::Write;
3
4use anyhow::Result;
5
6pub mod address;
7pub mod body;
8pub mod div;
9pub mod document;
10pub mod footer;
11pub mod head;
12pub mod hyperlink;
13pub mod image;
14pub mod line_break;
15pub mod link;
16pub mod list;
17pub mod meta;
18pub mod paragraph;
19pub mod text;
20pub mod title;
21
22pub trait IntoHtmlNode: Debug {
23    fn transform_into_html_node(&self, buffer: &mut dyn Write) -> Result<()>;
24}
25
26impl<S: AsRef<str> + Debug> IntoHtmlNode for S {
27    fn transform_into_html_node(&self, buffer: &mut dyn Write) -> Result<()> {
28        let s = self.as_ref().to_string();
29
30        // let mut p = Paragraph::new();
31        // p.add_element(s);
32        // p.transform_into_html_node(buffer)?;
33        buffer.write_all(s.as_bytes())?;
34
35        Ok(())
36    }
37}
38
39pub trait IsParagraph: Debug {
40    fn to_raw(&self) -> String;
41}
42
43impl<S: AsRef<str> + Debug> IsParagraph for S {
44    fn to_raw(&self) -> String {
45        self.as_ref().to_string()
46    }
47}