1use serde::{Deserialize, Serialize};
4
5use crate::extras::button::Button;
6use crate::extras::icon::Icon;
7use crate::node::{Common, IntoNode, Node};
8
9#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub struct Empty {
14 #[serde(flatten)]
16 pub common: Common,
17 #[serde(default, skip_serializing_if = "Option::is_none")]
19 pub title: Option<String>,
20 #[serde(default, skip_serializing_if = "Option::is_none")]
22 pub message: Option<String>,
23 #[serde(default, skip_serializing_if = "Option::is_none")]
25 pub icon: Option<Icon>,
26 #[serde(default, skip_serializing_if = "Option::is_none")]
29 pub action: Option<Box<Node>>,
30}
31
32impl Empty {
33 #[must_use]
35 pub fn new() -> Self {
36 Self {
37 common: Common::new(),
38 title: None,
39 message: None,
40 icon: None,
41 action: None,
42 }
43 }
44
45 #[must_use]
47 pub fn title(mut self, title: impl Into<String>) -> Self {
48 self.title = Some(title.into());
49 self
50 }
51
52 #[must_use]
54 pub fn message(mut self, message: impl Into<String>) -> Self {
55 self.message = Some(message.into());
56 self
57 }
58
59 #[must_use]
61 pub fn icon(mut self, icon: Icon) -> Self {
62 self.icon = Some(icon);
63 self
64 }
65
66 #[must_use]
68 pub fn action(mut self, action: Button) -> Self {
69 self.action = Some(Box::new(Node::Button(action)));
70 self
71 }
72}
73
74impl Default for Empty {
75 fn default() -> Self {
76 Self::new()
77 }
78}
79
80impl IntoNode for Empty {}
81impl From<Empty> for Node {
82 fn from(e: Empty) -> Self {
83 Node::Empty(e)
84 }
85}