@@ -67,6 +67,14 @@ impl fmt::Display for SGroupType {
6767}
6868
6969impl SGroupType {
70+ pub fn fetch_eq ( & self , other : & Self ) -> bool {
71+ let uid = self . fetch_id ( ) ;
72+ let ouid = other. fetch_id ( ) ;
73+ match ( uid, ouid) {
74+ ( Some ( uid) , Some ( ouid) ) => uid == ouid,
75+ _ => false ,
76+ }
77+ }
7078 pub ( super ) fn fetch_id ( & self ) -> Option < u32 > {
7179 match & self . 0 {
7280 SGenericActorType :: Id ( id) => Some ( * id) ,
@@ -110,6 +118,16 @@ impl SGroups {
110118 pub fn is_empty ( & self ) -> bool {
111119 self . len ( ) == 0
112120 }
121+
122+ pub fn fetch_eq ( & self , other : & Self ) -> bool {
123+ match ( self , other) {
124+ ( SGroups :: Single ( group) , SGroups :: Single ( ogroup) ) => group. fetch_eq ( ogroup) ,
125+ ( SGroups :: Multiple ( groups) , SGroups :: Multiple ( ogroups) ) => groups
126+ . iter ( )
127+ . all ( |group| ogroups. iter ( ) . any ( |ogroup| group. fetch_eq ( ogroup) ) ) ,
128+ _ => false ,
129+ }
130+ }
113131}
114132
115133impl < ' de > Deserialize < ' de > for SGenericActorType {
@@ -481,4 +499,12 @@ mod tests {
481499 let groups = SGroups :: Multiple ( vec ! [ ] ) ;
482500 assert ! ( groups. is_empty( ) ) ;
483501 }
502+
503+ #[ test]
504+ fn test_fetch_eq_sgroupstype_false ( ) {
505+ let group1 = SGroupType :: from ( "unkown" ) ;
506+ let group2 = SGroupType :: from ( "unkown2" ) ;
507+
508+ assert ! ( !group1. fetch_eq( & group2) ) ;
509+ }
484510}
0 commit comments