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
use webcore::value::Reference;
use webcore::try_from::TryInto;
use private::TODO;
#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)]
#[reference(instance_of = "DOMStringMap")]
pub struct StringMap( Reference );
impl StringMap {
pub fn get( &self, key: &str ) -> Option< String > {
js!( return @{self}[ @{key} ]; ).try_into().ok()
}
pub fn insert( &self, key: &str, value: &str ) -> Result< (), TODO > {
js!( @(no_return)
@{self}[ @{key} ] = @{value};
);
Ok(())
}
pub fn remove( &self, key: &str ) {
js!( @(no_return)
delete @{self}[ @{key} ];
);
}
pub fn contains_key( &self, key: &str ) -> bool {
js!( return @{key} in @{self}; ).try_into().unwrap()
}
}