1#[derive(Clone, Debug, Default, Eq, PartialEq)]
5pub struct Body {
6 text: Option<String>,
7 html: Option<String>,
8}
9
10impl Body {
11 #[must_use]
13 pub const fn empty() -> Self {
14 Self {
15 text: None,
16 html: None,
17 }
18 }
19
20 #[must_use]
22 pub fn text(body: impl Into<String>) -> Self {
23 Self {
24 text: Some(body.into()),
25 html: None,
26 }
27 }
28
29 #[must_use]
31 pub fn html(body: impl Into<String>) -> Self {
32 Self {
33 text: None,
34 html: Some(body.into()),
35 }
36 }
37
38 #[must_use]
40 pub fn both(text: impl Into<String>, html: impl Into<String>) -> Self {
41 Self {
42 text: Some(text.into()),
43 html: Some(html.into()),
44 }
45 }
46
47 #[must_use]
49 pub fn text_part(&self) -> Option<&str> {
50 self.text.as_deref()
51 }
52
53 #[must_use]
55 pub fn html_part(&self) -> Option<&str> {
56 self.html.as_deref()
57 }
58
59 #[must_use]
61 pub const fn is_empty(&self) -> bool {
62 self.text.is_none() && self.html.is_none()
63 }
64}