markdown_builder/builders/
link.rs

1use crate::types::link::Link;
2
3#[derive(Clone, Debug, Default, Eq, PartialEq)]
4pub struct LinkBuilder {
5    text: String,
6    url: String,
7    footer: bool,
8    inlined: bool,
9}
10
11impl LinkBuilder {
12    pub fn new() -> Self {
13        Self::default()
14    }
15
16    pub fn text(mut self, text: impl Into<String>) -> Self {
17        self.text = text.into();
18        self
19    }
20
21    pub fn url(mut self, url: impl Into<String>) -> Self {
22        self.url = url.into();
23        self
24    }
25
26    pub fn footer(mut self, value: bool) -> Self {
27        self.footer = value;
28        self
29    }
30
31    pub fn inlined(mut self) -> Self {
32        self.inlined = true;
33        self
34    }
35
36    pub fn build(self) -> Link {
37        Link::from(self.text, self.url, self.footer, self.inlined)
38    }
39}
40
41impl Link {
42    pub fn builder() -> LinkBuilder {
43        LinkBuilder::new()
44    }
45}