11// SPDX-License-Identifier: GPL-3.0-or-later
22
3- use super :: super :: { RecognitionResult , Tool } ;
3+ use super :: super :: { Meaning , Recognition , Tool } ;
44use intercept:: Execution ;
55
66/// Represents a set of tools, where any of them can recognize the semantic.
@@ -17,16 +17,14 @@ impl Any {
1717}
1818
1919impl Tool for Any {
20- fn recognize ( & self , x : & Execution ) -> RecognitionResult {
20+ fn recognize ( & self , x : & Execution ) -> Recognition < Meaning > {
2121 for tool in & self . tools {
2222 match tool. recognize ( x) {
23- RecognitionResult :: Recognized ( result) => {
24- return RecognitionResult :: Recognized ( result)
25- }
26- _ => continue ,
23+ Recognition :: Unknown => continue ,
24+ result => return result,
2725 }
2826 }
29- RecognitionResult :: NotRecognized
27+ Recognition :: Unknown
3028 }
3129}
3230
@@ -51,7 +49,7 @@ mod test {
5149 let input = any_execution ( ) ;
5250
5351 match sut. recognize ( & input) {
54- RecognitionResult :: NotRecognized => assert ! ( true ) ,
52+ Recognition :: Unknown => assert ! ( true ) ,
5553 _ => assert ! ( false ) ,
5654 }
5755 }
@@ -69,7 +67,7 @@ mod test {
6967 let input = any_execution ( ) ;
7068
7169 match sut. recognize ( & input) {
72- RecognitionResult :: Recognized ( Ok ( _ ) ) => assert ! ( true ) ,
70+ Recognition :: Success ( _ ) => assert ! ( true ) ,
7371 _ => assert ! ( false ) ,
7472 }
7573 }
@@ -88,7 +86,7 @@ mod test {
8886 let input = any_execution ( ) ;
8987
9088 match sut. recognize ( & input) {
91- RecognitionResult :: Recognized ( Err ( _ ) ) => assert ! ( true ) ,
89+ Recognition :: Error ( _ ) => assert ! ( true ) ,
9290 _ => assert ! ( false ) ,
9391 }
9492 }
@@ -100,13 +98,11 @@ mod test {
10098 }
10199
102100 impl Tool for MockTool {
103- fn recognize ( & self , _: & Execution ) -> RecognitionResult {
101+ fn recognize ( & self , _: & Execution ) -> Recognition < Meaning > {
104102 match self {
105- MockTool :: Recognize => RecognitionResult :: Recognized ( Ok ( Meaning :: Ignored ) ) ,
106- MockTool :: RecognizeFailed => {
107- RecognitionResult :: Recognized ( Err ( String :: from ( "problem" ) ) )
108- }
109- MockTool :: NotRecognize => RecognitionResult :: NotRecognized ,
103+ MockTool :: Recognize => Recognition :: Success ( Meaning :: Ignored ) ,
104+ MockTool :: RecognizeFailed => Recognition :: Error ( String :: from ( "problem" ) ) ,
105+ MockTool :: NotRecognize => Recognition :: Unknown ,
110106 }
111107 }
112108 }
0 commit comments