@@ -3,52 +3,10 @@ pub(crate) mod web_page;
3
3
4
4
pub ( crate ) use templates:: TemplateData ;
5
5
6
- use crate :: f_a:: IconStr ;
7
- use serde:: ser:: { Serialize , SerializeStruct , Serializer } ;
8
-
9
6
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
10
7
pub ( crate ) struct GlobalAlert {
11
8
pub ( crate ) url : & ' static str ,
12
9
pub ( crate ) text : & ' static str ,
13
10
pub ( crate ) css_class : & ' static str ,
14
11
pub ( crate ) fa_icon : crate :: f_a:: icons:: IconTriangleExclamation ,
15
12
}
16
-
17
- impl Serialize for GlobalAlert {
18
- fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
19
- where
20
- S : Serializer ,
21
- {
22
- let mut s = serializer. serialize_struct ( "GlobalAlert" , 4 ) ?;
23
- s. serialize_field ( "url" , & self . url ) ?;
24
- s. serialize_field ( "text" , & self . text ) ?;
25
- s. serialize_field ( "css_class" , & self . css_class ) ?;
26
- s. serialize_field ( "fa_icon" , & self . fa_icon . icon_name ( ) ) ?;
27
- s. end ( )
28
- }
29
- }
30
-
31
- #[ cfg( test) ]
32
- mod tera_tests {
33
- use super :: * ;
34
- use serde_json:: json;
35
-
36
- #[ test]
37
- fn serialize_global_alert ( ) {
38
- let alert = GlobalAlert {
39
- url : "http://www.hasthelargehadroncolliderdestroyedtheworldyet.com/" ,
40
- text : "THE WORLD WILL SOON END" ,
41
- css_class : "THE END IS NEAR" ,
42
- fa_icon : crate :: f_a:: icons:: IconTriangleExclamation ,
43
- } ;
44
-
45
- let correct_json = json ! ( {
46
- "url" : "http://www.hasthelargehadroncolliderdestroyedtheworldyet.com/" ,
47
- "text" : "THE WORLD WILL SOON END" ,
48
- "css_class" : "THE END IS NEAR" ,
49
- "fa_icon" : "triangle-exclamation"
50
- } ) ;
51
-
52
- assert_eq ! ( correct_json, serde_json:: to_value( alert) . unwrap( ) ) ;
53
- }
54
- }
0 commit comments