1use std::sync::{Arc, LazyLock};
2
3#[derive(Clone, Debug, PartialEq, Eq)]
13pub struct MaterialStrings {
14 pub dismiss: Arc<str>,
16 pub dismiss_message: Arc<str>,
18 pub dismiss_overlay: Arc<str>,
20 pub close: Arc<str>,
22 pub close_actions: Arc<str>,
24 pub close_search: Arc<str>,
26 pub cancel: Arc<str>,
28 pub confirm: Arc<str>,
30 pub clear: Arc<str>,
32 pub show_password: Arc<str>,
34 pub hide_password: Arc<str>,
36 pub open_options: Arc<str>,
38 pub close_options: Arc<str>,
40 pub no_matching_options: Arc<str>,
42 pub more_actions: Arc<str>,
44 pub app_bar_actions: Arc<str>,
46 pub bottom_app_bar: Arc<str>,
48 pub breadcrumb: Arc<str>,
50 pub more_breadcrumbs: Arc<str>,
52 pub navigation: Arc<str>,
54 pub steps: Arc<str>,
56 pub refresh: Arc<str>,
58 pub resize_bottom_sheet: Arc<str>,
60 pub expand: Arc<str>,
62 pub collapse: Arc<str>,
64 pub drop_target: Arc<str>,
66 pub drop_files_here: Arc<str>,
68 pub searching: Arc<str>,
70 pub no_results: Arc<str>,
72 pub search_prompt: Arc<str>,
74 pub minimize: Arc<str>,
76 pub maximize: Arc<str>,
78 pub restore: Arc<str>,
80}
81
82impl MaterialStrings {
83 pub fn dismiss(mut self, value: impl Into<Arc<str>>) -> Self {
85 self.dismiss = value.into();
86 self
87 }
88
89 pub fn dismiss_message(mut self, value: impl Into<Arc<str>>) -> Self {
91 self.dismiss_message = value.into();
92 self
93 }
94
95 pub fn dismiss_overlay(mut self, value: impl Into<Arc<str>>) -> Self {
97 self.dismiss_overlay = value.into();
98 self
99 }
100
101 pub fn close(mut self, value: impl Into<Arc<str>>) -> Self {
103 self.close = value.into();
104 self
105 }
106
107 pub fn close_actions(mut self, value: impl Into<Arc<str>>) -> Self {
109 self.close_actions = value.into();
110 self
111 }
112
113 pub fn close_search(mut self, value: impl Into<Arc<str>>) -> Self {
115 self.close_search = value.into();
116 self
117 }
118
119 pub fn cancel(mut self, value: impl Into<Arc<str>>) -> Self {
121 self.cancel = value.into();
122 self
123 }
124
125 pub fn confirm(mut self, value: impl Into<Arc<str>>) -> Self {
127 self.confirm = value.into();
128 self
129 }
130
131 pub fn clear(mut self, value: impl Into<Arc<str>>) -> Self {
133 self.clear = value.into();
134 self
135 }
136
137 pub fn show_password(mut self, value: impl Into<Arc<str>>) -> Self {
139 self.show_password = value.into();
140 self
141 }
142
143 pub fn hide_password(mut self, value: impl Into<Arc<str>>) -> Self {
145 self.hide_password = value.into();
146 self
147 }
148
149 pub fn open_options(mut self, value: impl Into<Arc<str>>) -> Self {
151 self.open_options = value.into();
152 self
153 }
154
155 pub fn close_options(mut self, value: impl Into<Arc<str>>) -> Self {
157 self.close_options = value.into();
158 self
159 }
160
161 pub fn no_matching_options(mut self, value: impl Into<Arc<str>>) -> Self {
163 self.no_matching_options = value.into();
164 self
165 }
166
167 pub fn more_actions(mut self, value: impl Into<Arc<str>>) -> Self {
169 self.more_actions = value.into();
170 self
171 }
172
173 pub fn app_bar_actions(mut self, value: impl Into<Arc<str>>) -> Self {
175 self.app_bar_actions = value.into();
176 self
177 }
178
179 pub fn bottom_app_bar(mut self, value: impl Into<Arc<str>>) -> Self {
181 self.bottom_app_bar = value.into();
182 self
183 }
184
185 pub fn breadcrumb(mut self, value: impl Into<Arc<str>>) -> Self {
187 self.breadcrumb = value.into();
188 self
189 }
190
191 pub fn more_breadcrumbs(mut self, value: impl Into<Arc<str>>) -> Self {
193 self.more_breadcrumbs = value.into();
194 self
195 }
196
197 pub fn navigation(mut self, value: impl Into<Arc<str>>) -> Self {
199 self.navigation = value.into();
200 self
201 }
202
203 pub fn steps(mut self, value: impl Into<Arc<str>>) -> Self {
205 self.steps = value.into();
206 self
207 }
208
209 pub fn refresh(mut self, value: impl Into<Arc<str>>) -> Self {
211 self.refresh = value.into();
212 self
213 }
214
215 pub fn resize_bottom_sheet(mut self, value: impl Into<Arc<str>>) -> Self {
217 self.resize_bottom_sheet = value.into();
218 self
219 }
220
221 pub fn expand(mut self, value: impl Into<Arc<str>>) -> Self {
223 self.expand = value.into();
224 self
225 }
226
227 pub fn collapse(mut self, value: impl Into<Arc<str>>) -> Self {
229 self.collapse = value.into();
230 self
231 }
232
233 pub fn drop_target(mut self, value: impl Into<Arc<str>>) -> Self {
235 self.drop_target = value.into();
236 self
237 }
238
239 pub fn drop_files_here(mut self, value: impl Into<Arc<str>>) -> Self {
241 self.drop_files_here = value.into();
242 self
243 }
244
245 pub fn searching(mut self, value: impl Into<Arc<str>>) -> Self {
247 self.searching = value.into();
248 self
249 }
250
251 pub fn no_results(mut self, value: impl Into<Arc<str>>) -> Self {
253 self.no_results = value.into();
254 self
255 }
256
257 pub fn search_prompt(mut self, value: impl Into<Arc<str>>) -> Self {
259 self.search_prompt = value.into();
260 self
261 }
262
263 pub fn minimize(mut self, value: impl Into<Arc<str>>) -> Self {
265 self.minimize = value.into();
266 self
267 }
268
269 pub fn maximize(mut self, value: impl Into<Arc<str>>) -> Self {
271 self.maximize = value.into();
272 self
273 }
274
275 pub fn restore(mut self, value: impl Into<Arc<str>>) -> Self {
277 self.restore = value.into();
278 self
279 }
280}
281
282impl Default for MaterialStrings {
283 fn default() -> Self {
284 static DEFAULT: LazyLock<MaterialStrings> = LazyLock::new(|| MaterialStrings {
285 dismiss: Arc::from("Dismiss"),
286 dismiss_message: Arc::from("Dismiss message"),
287 dismiss_overlay: Arc::from("Dismiss overlay"),
288 close: Arc::from("Close"),
289 close_actions: Arc::from("Close actions"),
290 close_search: Arc::from("Close search"),
291 cancel: Arc::from("Cancel"),
292 confirm: Arc::from("OK"),
293 clear: Arc::from("Clear"),
294 show_password: Arc::from("Show password"),
295 hide_password: Arc::from("Hide password"),
296 open_options: Arc::from("Open options"),
297 close_options: Arc::from("Close options"),
298 no_matching_options: Arc::from("No matching options"),
299 more_actions: Arc::from("More actions"),
300 app_bar_actions: Arc::from("App bar actions"),
301 bottom_app_bar: Arc::from("Bottom app bar"),
302 breadcrumb: Arc::from("Breadcrumb"),
303 more_breadcrumbs: Arc::from("More breadcrumbs"),
304 navigation: Arc::from("Navigation"),
305 steps: Arc::from("Steps"),
306 refresh: Arc::from("Refresh"),
307 resize_bottom_sheet: Arc::from("Resize bottom sheet"),
308 expand: Arc::from("Expand"),
309 collapse: Arc::from("Collapse"),
310 drop_target: Arc::from("Drop target"),
311 drop_files_here: Arc::from("Drop files here"),
312 searching: Arc::from("Searching"),
313 no_results: Arc::from("No results"),
314 search_prompt: Arc::from("Enter a search term"),
315 minimize: Arc::from("Minimize"),
316 maximize: Arc::from("Maximize"),
317 restore: Arc::from("Restore"),
318 });
319 DEFAULT.clone()
320 }
321}
322
323#[cfg(feature = "serde")]
324impl serde::Serialize for MaterialStrings {
325 fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
326 #[derive(serde::Serialize)]
327 #[serde(rename = "MaterialStrings")]
328 struct SerializedMaterialStrings<'a> {
329 dismiss: &'a str,
330 dismiss_message: &'a str,
331 dismiss_overlay: &'a str,
332 close: &'a str,
333 close_actions: &'a str,
334 close_search: &'a str,
335 cancel: &'a str,
336 confirm: &'a str,
337 clear: &'a str,
338 show_password: &'a str,
339 hide_password: &'a str,
340 open_options: &'a str,
341 close_options: &'a str,
342 no_matching_options: &'a str,
343 more_actions: &'a str,
344 app_bar_actions: &'a str,
345 bottom_app_bar: &'a str,
346 breadcrumb: &'a str,
347 more_breadcrumbs: &'a str,
348 navigation: &'a str,
349 steps: &'a str,
350 refresh: &'a str,
351 resize_bottom_sheet: &'a str,
352 expand: &'a str,
353 collapse: &'a str,
354 drop_target: &'a str,
355 drop_files_here: &'a str,
356 searching: &'a str,
357 no_results: &'a str,
358 search_prompt: &'a str,
359 minimize: &'a str,
360 maximize: &'a str,
361 restore: &'a str,
362 }
363
364 SerializedMaterialStrings {
365 dismiss: self.dismiss.as_ref(),
366 dismiss_message: self.dismiss_message.as_ref(),
367 dismiss_overlay: self.dismiss_overlay.as_ref(),
368 close: self.close.as_ref(),
369 close_actions: self.close_actions.as_ref(),
370 close_search: self.close_search.as_ref(),
371 cancel: self.cancel.as_ref(),
372 confirm: self.confirm.as_ref(),
373 clear: self.clear.as_ref(),
374 show_password: self.show_password.as_ref(),
375 hide_password: self.hide_password.as_ref(),
376 open_options: self.open_options.as_ref(),
377 close_options: self.close_options.as_ref(),
378 no_matching_options: self.no_matching_options.as_ref(),
379 more_actions: self.more_actions.as_ref(),
380 app_bar_actions: self.app_bar_actions.as_ref(),
381 bottom_app_bar: self.bottom_app_bar.as_ref(),
382 breadcrumb: self.breadcrumb.as_ref(),
383 more_breadcrumbs: self.more_breadcrumbs.as_ref(),
384 navigation: self.navigation.as_ref(),
385 steps: self.steps.as_ref(),
386 refresh: self.refresh.as_ref(),
387 resize_bottom_sheet: self.resize_bottom_sheet.as_ref(),
388 expand: self.expand.as_ref(),
389 collapse: self.collapse.as_ref(),
390 drop_target: self.drop_target.as_ref(),
391 drop_files_here: self.drop_files_here.as_ref(),
392 searching: self.searching.as_ref(),
393 no_results: self.no_results.as_ref(),
394 search_prompt: self.search_prompt.as_ref(),
395 minimize: self.minimize.as_ref(),
396 maximize: self.maximize.as_ref(),
397 restore: self.restore.as_ref(),
398 }
399 .serialize(serializer)
400 }
401}
402
403#[cfg(feature = "serde")]
404impl<'de> serde::Deserialize<'de> for MaterialStrings {
405 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
406 #[derive(Default, serde::Deserialize)]
407 #[serde(rename = "MaterialStrings", default)]
408 struct SerializedMaterialStrings {
409 dismiss: Option<String>,
410 dismiss_message: Option<String>,
411 dismiss_overlay: Option<String>,
412 close: Option<String>,
413 close_actions: Option<String>,
414 close_search: Option<String>,
415 cancel: Option<String>,
416 confirm: Option<String>,
417 clear: Option<String>,
418 show_password: Option<String>,
419 hide_password: Option<String>,
420 open_options: Option<String>,
421 close_options: Option<String>,
422 no_matching_options: Option<String>,
423 more_actions: Option<String>,
424 app_bar_actions: Option<String>,
425 bottom_app_bar: Option<String>,
426 breadcrumb: Option<String>,
427 more_breadcrumbs: Option<String>,
428 navigation: Option<String>,
429 steps: Option<String>,
430 refresh: Option<String>,
431 resize_bottom_sheet: Option<String>,
432 expand: Option<String>,
433 collapse: Option<String>,
434 drop_target: Option<String>,
435 drop_files_here: Option<String>,
436 searching: Option<String>,
437 no_results: Option<String>,
438 search_prompt: Option<String>,
439 minimize: Option<String>,
440 maximize: Option<String>,
441 restore: Option<String>,
442 }
443
444 let raw = SerializedMaterialStrings::deserialize(deserializer)?;
445 let defaults = Self::default();
446 Ok(Self {
447 dismiss: raw.dismiss.map(Into::into).unwrap_or(defaults.dismiss),
448 dismiss_message: raw
449 .dismiss_message
450 .map(Into::into)
451 .unwrap_or(defaults.dismiss_message),
452 dismiss_overlay: raw
453 .dismiss_overlay
454 .map(Into::into)
455 .unwrap_or(defaults.dismiss_overlay),
456 close: raw.close.map(Into::into).unwrap_or(defaults.close),
457 close_actions: raw
458 .close_actions
459 .map(Into::into)
460 .unwrap_or(defaults.close_actions),
461 close_search: raw
462 .close_search
463 .map(Into::into)
464 .unwrap_or(defaults.close_search),
465 cancel: raw.cancel.map(Into::into).unwrap_or(defaults.cancel),
466 confirm: raw.confirm.map(Into::into).unwrap_or(defaults.confirm),
467 clear: raw.clear.map(Into::into).unwrap_or(defaults.clear),
468 show_password: raw
469 .show_password
470 .map(Into::into)
471 .unwrap_or(defaults.show_password),
472 hide_password: raw
473 .hide_password
474 .map(Into::into)
475 .unwrap_or(defaults.hide_password),
476 open_options: raw
477 .open_options
478 .map(Into::into)
479 .unwrap_or(defaults.open_options),
480 close_options: raw
481 .close_options
482 .map(Into::into)
483 .unwrap_or(defaults.close_options),
484 no_matching_options: raw
485 .no_matching_options
486 .map(Into::into)
487 .unwrap_or(defaults.no_matching_options),
488 more_actions: raw
489 .more_actions
490 .map(Into::into)
491 .unwrap_or(defaults.more_actions),
492 app_bar_actions: raw
493 .app_bar_actions
494 .map(Into::into)
495 .unwrap_or(defaults.app_bar_actions),
496 bottom_app_bar: raw
497 .bottom_app_bar
498 .map(Into::into)
499 .unwrap_or(defaults.bottom_app_bar),
500 breadcrumb: raw
501 .breadcrumb
502 .map(Into::into)
503 .unwrap_or(defaults.breadcrumb),
504 more_breadcrumbs: raw
505 .more_breadcrumbs
506 .map(Into::into)
507 .unwrap_or(defaults.more_breadcrumbs),
508 navigation: raw
509 .navigation
510 .map(Into::into)
511 .unwrap_or(defaults.navigation),
512 steps: raw.steps.map(Into::into).unwrap_or(defaults.steps),
513 refresh: raw.refresh.map(Into::into).unwrap_or(defaults.refresh),
514 resize_bottom_sheet: raw
515 .resize_bottom_sheet
516 .map(Into::into)
517 .unwrap_or(defaults.resize_bottom_sheet),
518 expand: raw.expand.map(Into::into).unwrap_or(defaults.expand),
519 collapse: raw.collapse.map(Into::into).unwrap_or(defaults.collapse),
520 drop_target: raw
521 .drop_target
522 .map(Into::into)
523 .unwrap_or(defaults.drop_target),
524 drop_files_here: raw
525 .drop_files_here
526 .map(Into::into)
527 .unwrap_or(defaults.drop_files_here),
528 searching: raw.searching.map(Into::into).unwrap_or(defaults.searching),
529 no_results: raw
530 .no_results
531 .map(Into::into)
532 .unwrap_or(defaults.no_results),
533 search_prompt: raw
534 .search_prompt
535 .map(Into::into)
536 .unwrap_or(defaults.search_prompt),
537 minimize: raw.minimize.map(Into::into).unwrap_or(defaults.minimize),
538 maximize: raw.maximize.map(Into::into).unwrap_or(defaults.maximize),
539 restore: raw.restore.map(Into::into).unwrap_or(defaults.restore),
540 })
541 }
542}