@@ -3,52 +3,10 @@ pub(crate) mod web_page;
33
44pub ( crate )  use  templates:: TemplateData ; 
55
6- use  crate :: f_a:: IconStr ; 
7- use  serde:: ser:: { Serialize ,  SerializeStruct ,  Serializer } ; 
8- 
96#[ derive( Debug ,  Copy ,  Clone ,  PartialEq ,  Eq ) ]  
107pub ( crate )  struct  GlobalAlert  { 
118    pub ( crate )  url :  & ' static  str , 
129    pub ( crate )  text :  & ' static  str , 
1310    pub ( crate )  css_class :  & ' static  str , 
1411    pub ( crate )  fa_icon :  crate :: f_a:: icons:: IconTriangleExclamation , 
1512} 
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