@@ -62,10 +62,11 @@ impl Compare {
6262 /// Check `self` against RPSL policy `query` and generate reports.
6363 /// Depending on which [`Verbosity`] `self.verbosity` is set to,
6464 /// the reports have different levels of details.
65- /// If `verbosity.stop_at_first`, stops at the first report.
65+ /// - If `verbosity.stop_at_first`, stops at the first report.
66+ /// - Skip generating reports if the AS Path has only one entry.
6667 pub fn check ( & self , query : & QueryIr ) -> Vec < Report > {
67- if self . as_path . len ( ) = = 1 {
68- return self . check_last_export ( query ) . into_iter ( ) . collect ( ) ;
68+ if self . as_path . len ( ) < = 1 {
69+ return vec ! [ ] ;
6970 }
7071
7172 let mut reports = Vec :: with_capacity ( self . as_path . len ( ) << 1 ) ;
@@ -91,22 +92,6 @@ impl Compare {
9192 reports
9293 }
9394
94- pub fn check_last_export ( & self , query : & QueryIr ) -> Option < Report > {
95- match self . as_path . last ( ) ? {
96- Seq ( from) => match query. aut_nums . get ( from) {
97- Some ( from_an) => self . check_export ( query, from_an, * from, None , & [ ] ) ,
98- None => self . verbosity . show_unrec . then ( || {
99- let items = aut_num_unrecorded_items ( * from) ;
100- UnrecSingleExport { from : * from, items }
101- } ) ,
102- } ,
103- Set ( from) => self
104- . verbosity
105- . record_set
106- . then ( || SetSingleExport { from : from. clone ( ) } ) ,
107- }
108- }
109-
11095 /// `prev_path` is previous path for `to`.
11196 pub fn check_pair (
11297 & self ,
@@ -116,7 +101,7 @@ impl Compare {
116101 prev_path : & [ AsPathEntry ] ,
117102 ) -> Vec < Report > {
118103 let from_report = match query. aut_nums . get ( & from) {
119- Some ( from_an) => self . check_export ( query, from_an, from, Some ( to ) , prev_path) ,
104+ Some ( from_an) => self . check_export ( query, from_an, from, to , prev_path) ,
120105 None => self . verbosity . show_unrec . then ( || {
121106 let items = aut_num_unrecorded_items ( from) ;
122107 UnrecExport { from, to, items }
@@ -141,16 +126,13 @@ impl Compare {
141126 query : & QueryIr ,
142127 from_an : & AutNum ,
143128 from : u32 ,
144- to : Option < u32 > ,
129+ to : u32 ,
145130 prev_path : & [ AsPathEntry ] ,
146131 ) -> Option < Report > {
147132 if from_an. exports . is_default ( ) {
148133 return self . verbosity . show_unrec . then ( || {
149134 let items = vec ! [ UnrecExportEmpty ] ;
150- match to {
151- Some ( to) => UnrecExport { from, to, items } ,
152- None => UnrecSingleExport { from, items } ,
153- }
135+ UnrecExport { from, to, items }
154136 } ) ;
155137 }
156138 let mut report = match ( Compliance {
@@ -163,32 +145,26 @@ impl Compare {
163145 } )
164146 . check ( & from_an. exports )
165147 {
166- None => {
167- return self . verbosity . show_success . then_some ( match to {
168- Some ( to) => OkExport { from, to } ,
169- None => OkSingleExport { from } ,
170- } )
171- }
148+ None => return self . verbosity . show_success . then_some ( OkExport { from, to } ) ,
172149 Some ( report) => report,
173150 } ;
174151 report. shrink_to_fit ( ) ;
175152 match report {
176- SkipAnyReport ( items) => self . verbosity . show_skips . then_some ( match to {
177- Some ( to) => SkipExport { from, to, items } ,
178- None => SkipSingleExport { from, items } ,
179- } ) ,
180- UnrecAnyReport ( items) => self . verbosity . show_unrec . then_some ( match to {
181- Some ( to) => UnrecExport { from, to, items } ,
182- None => UnrecSingleExport { from, items } ,
183- } ) ,
184- MehAnyReport ( items) => self . verbosity . show_meh . then_some ( match to {
185- Some ( to) => MehExport { from, to, items } ,
186- None => MehSingleExport { from, items } ,
187- } ) ,
188- BadAnyReport ( items) => Some ( match to {
189- Some ( to) => BadExport { from, to, items } ,
190- None => BadSingleExport { from, items } ,
191- } ) ,
153+ SkipAnyReport ( items) => {
154+ self . verbosity
155+ . show_skips
156+ . then_some ( SkipExport { from, to, items } )
157+ }
158+ UnrecAnyReport ( items) => {
159+ self . verbosity
160+ . show_unrec
161+ . then_some ( UnrecExport { from, to, items } )
162+ }
163+ MehAnyReport ( items) => self
164+ . verbosity
165+ . show_meh
166+ . then_some ( MehExport { from, to, items } ) ,
167+ BadAnyReport ( items) => Some ( BadExport { from, to, items } ) ,
192168 }
193169 }
194170
@@ -210,7 +186,7 @@ impl Compare {
210186 let mut report = match ( Compliance {
211187 cmp : self ,
212188 query,
213- accept_num : Some ( from) ,
189+ accept_num : from,
214190 self_num : to,
215191 export : false ,
216192 prev_path,
0 commit comments