1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
4pub struct Text {
5 #[serde(default, skip_serializing_if = "String::is_empty")]
6 pub id: String,
7 #[serde(default)]
8 pub text: String,
9}
10impl Text {
11 #[must_use]
12 pub fn with_id(mut self, id: impl AsRef<str>) -> Self {
13 self.id = id.as_ref().to_string();
14 self
15 }
16}
17
18pub fn text(s: impl Into<String>) -> Text {
19 Text {
20 id: String::new(),
21 text: s.into(),
22 }
23}