1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::state::{
attribute::Attribute,
language::Language,
oca::{OCATranslation, Overlay},
};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetaOverlay {
capture_base: String,
#[serde(rename = "type")]
overlay_type: String,
language: Language,
name: String,
description: String,
}
impl Overlay for MetaOverlay {
fn capture_base(&mut self) -> &mut String {
&mut self.capture_base
}
fn overlay_type(&self) -> &String {
&self.overlay_type
}
fn language(&self) -> Option<&Language> {
Some(&self.language)
}
fn attributes(&self) -> Vec<&String> {
vec![]
}
fn add(&mut self, _attribute: &Attribute) {}
}
impl MetaOverlay {
pub fn new(lang: Language, oca_tr: &OCATranslation) -> Box<MetaOverlay> {
Box::new(MetaOverlay {
capture_base: String::new(),
overlay_type: "spec/overlays/meta/1.0".to_string(),
language: lang,
name: oca_tr.name.as_ref().unwrap_or(&"".to_string()).clone(),
description: oca_tr
.description
.as_ref()
.unwrap_or(&"".to_string())
.clone(),
})
}
}