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
|
use crate::primitive::{Variant, VariantMap};
#[derive(Clone, Debug, std::cmp::PartialEq)]
pub struct AliasManager {
pub aliases: Vec<Alias>,
}
#[derive(Clone, Debug, std::cmp::PartialEq)]
pub struct Alias {
name: String,
expansion: String,
}
impl AliasManager {
/// Client to Server
///
/// Replaces all properties of the object with the content of the
/// "properties" parameter. This parameter is in network representation.
///
fn request_update(self: &mut Self, properties: VariantMap) {
self.update(properties);
}
/// Server to Client
fn add_alias(self: &mut Self, name: String, expansion: String) {
self.aliases.push(Alias { name, expansion });
}
/// Server to Client
///
/// Replaces all properties of the object with the content of the
/// "properties" parameter. This parameter is in network representation.
///
fn update(self: &mut Self, properties: VariantMap) {
let mut alias: Vec<Alias> = Vec::new();
// for (i, name) in match_variant!(properties[&"Aliases".to_string()], Variant::String) {
// alias.push(Alias {
// name,
// expansion: match_variant!(properties["Aliases"], Variant::String)["expansions"][i],
// })
// }
self.aliases = alias
}
}
|