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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use crate::;
;
/*
pub struct Serializer {
langs_dictionary: Option<LangsDictionary>,
serialize_form: SerializeForm
}
impl Serializer {
pub fn new() -> Self {
Self{langs_dictionary: None, serialize_form: SerializeForm::Toml}
}
pub fn create(&mut self, string : &str) -> Option<()> {
let new = match self.serialize_form {
SerializeForm::Toml => {toml::from_str(string).ok()?}
SerializeForm::Json => {serde_json::from_str(string).ok()?}
SerializeForm::Another(_) => {None?}
};
self.langs_dictionary = Some(new);
Some(())
}
pub fn create_from_fn(&self, string : &str, f: &dyn Fn(&SerializeForm, &str) -> Option<LangsDictionary>) -> Option<LangsDictionary> {
f(&self.serialize_form, string)
}
pub fn set_serialize_form_from_str(&mut self, a : &str) {
//use Self::*;
self.serialize_form = match a {
"toml" => SerializeForm::Toml,
"json" => SerializeForm::Json,
s => SerializeForm::Another(s.to_string()),
};
}
#[allow(dead_code, unreachable_patterns)]
pub fn get_serialize_form_as_str<'a>(&'a self) -> &'a str {
//use Self::*;
match self.serialize_form {
SerializeForm::Toml => "toml",
SerializeForm::Json => "json",
SerializeForm::Another( ref s ) => s,
//_ => unimplemented!(),
}
}
/*
#[cfg(feature = "std")]
pub fn get(&self, key : &str, current_lang : &Option<String>) -> Option<String> {
match self {
SerializeForm::Toml => {}
SerializeForm::Json => {None}
_ => panic!()
//_ /*| SerializeForm::Json*/ => { unimplemented!() }
}
}
#[cfg(feature = "std")]
pub fn get1(&self, key : &str) -> Vec<String> {
match self {
SerializeForm::Toml => {}
SerializeForm::Json => {}
}
}
*/
}
*/