1pub use common::entities::CharVerticalAlignment;
4pub use common::entities::InlineContent;
5use common::entities::InlineElement;
6pub use common::entities::UnderlineStyle;
7use common::types::EntityId;
8use serde::{Deserialize, Serialize};
9use std::convert::From;
10
11#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
12pub struct InlineElementDto {
13 pub id: EntityId,
14 pub created_at: chrono::DateTime<chrono::Utc>,
15 pub updated_at: chrono::DateTime<chrono::Utc>,
16 pub content: InlineContent,
17 pub fmt_font_family: Option<String>,
18 pub fmt_font_point_size: Option<i64>,
19 pub fmt_font_weight: Option<i64>,
20 pub fmt_font_bold: Option<bool>,
21 pub fmt_font_italic: Option<bool>,
22 pub fmt_font_underline: Option<bool>,
23 pub fmt_font_overline: Option<bool>,
24 pub fmt_font_strikeout: Option<bool>,
25 pub fmt_letter_spacing: Option<i64>,
26 pub fmt_word_spacing: Option<i64>,
27 pub fmt_anchor_href: Option<String>,
28 pub fmt_anchor_names: Vec<String>,
29 pub fmt_is_anchor: Option<bool>,
30 pub fmt_tooltip: Option<String>,
31 pub fmt_underline_style: Option<UnderlineStyle>,
32 pub fmt_vertical_alignment: Option<CharVerticalAlignment>,
33}
34
35impl From<InlineElementDto> for InlineElement {
36 fn from(dto: InlineElementDto) -> Self {
37 InlineElement {
38 id: dto.id,
39 created_at: dto.created_at,
40 updated_at: dto.updated_at,
41 content: dto.content,
42 fmt_font_family: dto.fmt_font_family,
43 fmt_font_point_size: dto.fmt_font_point_size,
44 fmt_font_weight: dto.fmt_font_weight,
45 fmt_font_bold: dto.fmt_font_bold,
46 fmt_font_italic: dto.fmt_font_italic,
47 fmt_font_underline: dto.fmt_font_underline,
48 fmt_font_overline: dto.fmt_font_overline,
49 fmt_font_strikeout: dto.fmt_font_strikeout,
50 fmt_letter_spacing: dto.fmt_letter_spacing,
51 fmt_word_spacing: dto.fmt_word_spacing,
52 fmt_anchor_href: dto.fmt_anchor_href,
53 fmt_anchor_names: dto.fmt_anchor_names,
54 fmt_is_anchor: dto.fmt_is_anchor,
55 fmt_tooltip: dto.fmt_tooltip,
56 fmt_underline_style: dto.fmt_underline_style,
57 fmt_vertical_alignment: dto.fmt_vertical_alignment,
58 }
59 }
60}
61
62impl From<&InlineElementDto> for InlineElement {
63 fn from(dto: &InlineElementDto) -> Self {
64 InlineElement {
65 id: dto.id,
66 created_at: dto.created_at,
67 updated_at: dto.updated_at,
68 content: dto.content.clone(),
69 fmt_font_family: dto.fmt_font_family.clone(),
70 fmt_font_point_size: dto.fmt_font_point_size,
71 fmt_font_weight: dto.fmt_font_weight,
72 fmt_font_bold: dto.fmt_font_bold,
73 fmt_font_italic: dto.fmt_font_italic,
74 fmt_font_underline: dto.fmt_font_underline,
75 fmt_font_overline: dto.fmt_font_overline,
76 fmt_font_strikeout: dto.fmt_font_strikeout,
77 fmt_letter_spacing: dto.fmt_letter_spacing,
78 fmt_word_spacing: dto.fmt_word_spacing,
79 fmt_anchor_href: dto.fmt_anchor_href.clone(),
80 fmt_anchor_names: dto.fmt_anchor_names.clone(),
81 fmt_is_anchor: dto.fmt_is_anchor,
82 fmt_tooltip: dto.fmt_tooltip.clone(),
83 fmt_underline_style: dto.fmt_underline_style.clone(),
84 fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
85 }
86 }
87}
88
89impl From<InlineElement> for InlineElementDto {
90 fn from(entity: InlineElement) -> Self {
91 InlineElementDto {
92 id: entity.id,
93 created_at: entity.created_at,
94 updated_at: entity.updated_at,
95 content: entity.content,
96 fmt_font_family: entity.fmt_font_family,
97 fmt_font_point_size: entity.fmt_font_point_size,
98 fmt_font_weight: entity.fmt_font_weight,
99 fmt_font_bold: entity.fmt_font_bold,
100 fmt_font_italic: entity.fmt_font_italic,
101 fmt_font_underline: entity.fmt_font_underline,
102 fmt_font_overline: entity.fmt_font_overline,
103 fmt_font_strikeout: entity.fmt_font_strikeout,
104 fmt_letter_spacing: entity.fmt_letter_spacing,
105 fmt_word_spacing: entity.fmt_word_spacing,
106 fmt_anchor_href: entity.fmt_anchor_href,
107 fmt_anchor_names: entity.fmt_anchor_names,
108 fmt_is_anchor: entity.fmt_is_anchor,
109 fmt_tooltip: entity.fmt_tooltip,
110 fmt_underline_style: entity.fmt_underline_style,
111 fmt_vertical_alignment: entity.fmt_vertical_alignment,
112 }
113 }
114}
115
116#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
117pub struct CreateInlineElementDto {
118 pub created_at: chrono::DateTime<chrono::Utc>,
119 pub updated_at: chrono::DateTime<chrono::Utc>,
120 pub content: InlineContent,
121 pub fmt_font_family: Option<String>,
122 pub fmt_font_point_size: Option<i64>,
123 pub fmt_font_weight: Option<i64>,
124 pub fmt_font_bold: Option<bool>,
125 pub fmt_font_italic: Option<bool>,
126 pub fmt_font_underline: Option<bool>,
127 pub fmt_font_overline: Option<bool>,
128 pub fmt_font_strikeout: Option<bool>,
129 pub fmt_letter_spacing: Option<i64>,
130 pub fmt_word_spacing: Option<i64>,
131 pub fmt_anchor_href: Option<String>,
132 pub fmt_anchor_names: Vec<String>,
133 pub fmt_is_anchor: Option<bool>,
134 pub fmt_tooltip: Option<String>,
135 pub fmt_underline_style: Option<UnderlineStyle>,
136 pub fmt_vertical_alignment: Option<CharVerticalAlignment>,
137}
138
139impl From<CreateInlineElementDto> for InlineElement {
140 fn from(dto: CreateInlineElementDto) -> Self {
141 InlineElement {
142 id: 0,
143 created_at: dto.created_at,
144 updated_at: dto.updated_at,
145 content: dto.content,
146 fmt_font_family: dto.fmt_font_family,
147 fmt_font_point_size: dto.fmt_font_point_size,
148 fmt_font_weight: dto.fmt_font_weight,
149 fmt_font_bold: dto.fmt_font_bold,
150 fmt_font_italic: dto.fmt_font_italic,
151 fmt_font_underline: dto.fmt_font_underline,
152 fmt_font_overline: dto.fmt_font_overline,
153 fmt_font_strikeout: dto.fmt_font_strikeout,
154 fmt_letter_spacing: dto.fmt_letter_spacing,
155 fmt_word_spacing: dto.fmt_word_spacing,
156 fmt_anchor_href: dto.fmt_anchor_href,
157 fmt_anchor_names: dto.fmt_anchor_names,
158 fmt_is_anchor: dto.fmt_is_anchor,
159 fmt_tooltip: dto.fmt_tooltip,
160 fmt_underline_style: dto.fmt_underline_style,
161 fmt_vertical_alignment: dto.fmt_vertical_alignment,
162 }
163 }
164}
165
166impl From<&CreateInlineElementDto> for InlineElement {
167 fn from(dto: &CreateInlineElementDto) -> Self {
168 InlineElement {
169 id: 0,
170 created_at: dto.created_at,
171 updated_at: dto.updated_at,
172 content: dto.content.clone(),
173 fmt_font_family: dto.fmt_font_family.clone(),
174 fmt_font_point_size: dto.fmt_font_point_size,
175 fmt_font_weight: dto.fmt_font_weight,
176 fmt_font_bold: dto.fmt_font_bold,
177 fmt_font_italic: dto.fmt_font_italic,
178 fmt_font_underline: dto.fmt_font_underline,
179 fmt_font_overline: dto.fmt_font_overline,
180 fmt_font_strikeout: dto.fmt_font_strikeout,
181 fmt_letter_spacing: dto.fmt_letter_spacing,
182 fmt_word_spacing: dto.fmt_word_spacing,
183 fmt_anchor_href: dto.fmt_anchor_href.clone(),
184 fmt_anchor_names: dto.fmt_anchor_names.clone(),
185 fmt_is_anchor: dto.fmt_is_anchor,
186 fmt_tooltip: dto.fmt_tooltip.clone(),
187 fmt_underline_style: dto.fmt_underline_style.clone(),
188 fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
189 }
190 }
191}
192
193impl From<InlineElement> for CreateInlineElementDto {
194 fn from(entity: InlineElement) -> Self {
195 CreateInlineElementDto {
196 created_at: entity.created_at,
197 updated_at: entity.updated_at,
198 content: entity.content,
199 fmt_font_family: entity.fmt_font_family,
200 fmt_font_point_size: entity.fmt_font_point_size,
201 fmt_font_weight: entity.fmt_font_weight,
202 fmt_font_bold: entity.fmt_font_bold,
203 fmt_font_italic: entity.fmt_font_italic,
204 fmt_font_underline: entity.fmt_font_underline,
205 fmt_font_overline: entity.fmt_font_overline,
206 fmt_font_strikeout: entity.fmt_font_strikeout,
207 fmt_letter_spacing: entity.fmt_letter_spacing,
208 fmt_word_spacing: entity.fmt_word_spacing,
209 fmt_anchor_href: entity.fmt_anchor_href,
210 fmt_anchor_names: entity.fmt_anchor_names,
211 fmt_is_anchor: entity.fmt_is_anchor,
212 fmt_tooltip: entity.fmt_tooltip,
213 fmt_underline_style: entity.fmt_underline_style,
214 fmt_vertical_alignment: entity.fmt_vertical_alignment,
215 }
216 }
217}
218
219#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
220pub struct UpdateInlineElementDto {
221 pub id: EntityId,
222 pub created_at: chrono::DateTime<chrono::Utc>,
223 pub updated_at: chrono::DateTime<chrono::Utc>,
224 pub content: InlineContent,
225 pub fmt_font_family: Option<String>,
226 pub fmt_font_point_size: Option<i64>,
227 pub fmt_font_weight: Option<i64>,
228 pub fmt_font_bold: Option<bool>,
229 pub fmt_font_italic: Option<bool>,
230 pub fmt_font_underline: Option<bool>,
231 pub fmt_font_overline: Option<bool>,
232 pub fmt_font_strikeout: Option<bool>,
233 pub fmt_letter_spacing: Option<i64>,
234 pub fmt_word_spacing: Option<i64>,
235 pub fmt_anchor_href: Option<String>,
236 pub fmt_anchor_names: Vec<String>,
237 pub fmt_is_anchor: Option<bool>,
238 pub fmt_tooltip: Option<String>,
239 pub fmt_underline_style: Option<UnderlineStyle>,
240 pub fmt_vertical_alignment: Option<CharVerticalAlignment>,
241}
242
243impl From<UpdateInlineElementDto> for InlineElement {
244 fn from(dto: UpdateInlineElementDto) -> Self {
245 InlineElement {
246 id: dto.id,
247 created_at: dto.created_at,
248 updated_at: dto.updated_at,
249 content: dto.content,
250 fmt_font_family: dto.fmt_font_family,
251 fmt_font_point_size: dto.fmt_font_point_size,
252 fmt_font_weight: dto.fmt_font_weight,
253 fmt_font_bold: dto.fmt_font_bold,
254 fmt_font_italic: dto.fmt_font_italic,
255 fmt_font_underline: dto.fmt_font_underline,
256 fmt_font_overline: dto.fmt_font_overline,
257 fmt_font_strikeout: dto.fmt_font_strikeout,
258 fmt_letter_spacing: dto.fmt_letter_spacing,
259 fmt_word_spacing: dto.fmt_word_spacing,
260 fmt_anchor_href: dto.fmt_anchor_href,
261 fmt_anchor_names: dto.fmt_anchor_names,
262 fmt_is_anchor: dto.fmt_is_anchor,
263 fmt_tooltip: dto.fmt_tooltip,
264 fmt_underline_style: dto.fmt_underline_style,
265 fmt_vertical_alignment: dto.fmt_vertical_alignment,
266 }
267 }
268}
269
270impl From<&UpdateInlineElementDto> for InlineElement {
271 fn from(dto: &UpdateInlineElementDto) -> Self {
272 InlineElement {
273 id: dto.id,
274 created_at: dto.created_at,
275 updated_at: dto.updated_at,
276 content: dto.content.clone(),
277 fmt_font_family: dto.fmt_font_family.clone(),
278 fmt_font_point_size: dto.fmt_font_point_size,
279 fmt_font_weight: dto.fmt_font_weight,
280 fmt_font_bold: dto.fmt_font_bold,
281 fmt_font_italic: dto.fmt_font_italic,
282 fmt_font_underline: dto.fmt_font_underline,
283 fmt_font_overline: dto.fmt_font_overline,
284 fmt_font_strikeout: dto.fmt_font_strikeout,
285 fmt_letter_spacing: dto.fmt_letter_spacing,
286 fmt_word_spacing: dto.fmt_word_spacing,
287 fmt_anchor_href: dto.fmt_anchor_href.clone(),
288 fmt_anchor_names: dto.fmt_anchor_names.clone(),
289 fmt_is_anchor: dto.fmt_is_anchor,
290 fmt_tooltip: dto.fmt_tooltip.clone(),
291 fmt_underline_style: dto.fmt_underline_style.clone(),
292 fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
293 }
294 }
295}
296
297impl From<InlineElement> for UpdateInlineElementDto {
298 fn from(entity: InlineElement) -> Self {
299 UpdateInlineElementDto {
300 id: entity.id,
301 created_at: entity.created_at,
302 updated_at: entity.updated_at,
303 content: entity.content,
304 fmt_font_family: entity.fmt_font_family,
305 fmt_font_point_size: entity.fmt_font_point_size,
306 fmt_font_weight: entity.fmt_font_weight,
307 fmt_font_bold: entity.fmt_font_bold,
308 fmt_font_italic: entity.fmt_font_italic,
309 fmt_font_underline: entity.fmt_font_underline,
310 fmt_font_overline: entity.fmt_font_overline,
311 fmt_font_strikeout: entity.fmt_font_strikeout,
312 fmt_letter_spacing: entity.fmt_letter_spacing,
313 fmt_word_spacing: entity.fmt_word_spacing,
314 fmt_anchor_href: entity.fmt_anchor_href,
315 fmt_anchor_names: entity.fmt_anchor_names,
316 fmt_is_anchor: entity.fmt_is_anchor,
317 fmt_tooltip: entity.fmt_tooltip,
318 fmt_underline_style: entity.fmt_underline_style,
319 fmt_vertical_alignment: entity.fmt_vertical_alignment,
320 }
321 }
322}
323
324impl From<InlineElementDto> for UpdateInlineElementDto {
325 fn from(dto: InlineElementDto) -> Self {
326 UpdateInlineElementDto {
327 id: dto.id,
328 created_at: dto.created_at,
329 updated_at: dto.updated_at,
330 content: dto.content,
331 fmt_font_family: dto.fmt_font_family,
332 fmt_font_point_size: dto.fmt_font_point_size,
333 fmt_font_weight: dto.fmt_font_weight,
334 fmt_font_bold: dto.fmt_font_bold,
335 fmt_font_italic: dto.fmt_font_italic,
336 fmt_font_underline: dto.fmt_font_underline,
337 fmt_font_overline: dto.fmt_font_overline,
338 fmt_font_strikeout: dto.fmt_font_strikeout,
339 fmt_letter_spacing: dto.fmt_letter_spacing,
340 fmt_word_spacing: dto.fmt_word_spacing,
341 fmt_anchor_href: dto.fmt_anchor_href,
342 fmt_anchor_names: dto.fmt_anchor_names,
343 fmt_is_anchor: dto.fmt_is_anchor,
344 fmt_tooltip: dto.fmt_tooltip,
345 fmt_underline_style: dto.fmt_underline_style,
346 fmt_vertical_alignment: dto.fmt_vertical_alignment,
347 }
348 }
349}