@@ -206,10 +206,18 @@ pub struct CodeDefinition {
206206}
207207
208208#[ derive( Deserialize , Debug ) ]
209- pub struct SubmissionResult {
209+ pub struct SubmissionResponse {
210+ pub state : Option < String > ,
211+ pub input : Option < Either > ,
212+ pub input_formatted : Option < Either > ,
210213 pub code_output : Option < Either > ,
214+ pub std_output : Option < Either > ,
215+ pub last_test_case : Option < Either > ,
216+ pub correct_answer : Option < bool > ,
211217 pub code_answer : Option < Either > ,
218+ pub expected_output : Option < Either > ,
212219 pub expected_code_output : Option < Either > ,
220+ pub expected_answer : Option < Either > ,
213221 pub expected_code_answer : Option < Either > ,
214222 pub compare_result : Option < String > ,
215223 pub compile_error : Option < String > ,
@@ -218,7 +226,6 @@ pub struct SubmissionResult {
218226 pub memory : Option < u32 > ,
219227 pub memory_percentile : Option < f32 > ,
220228 pub pretty_lang : String ,
221- pub question_id : Option < u32 > ,
222229 pub run_success : bool ,
223230 pub runtime_percentile : Option < f32 > ,
224231 pub expected_status_code : Option < u32 > ,
@@ -230,16 +237,31 @@ pub struct SubmissionResult {
230237 pub total_testcases : Option < u32 > ,
231238}
232239
233- impl SubmissionResult {
234- pub fn has_compile_error ( & self ) -> bool {
240+ pub trait ExecutionErrorResponse {
241+ fn has_compile_error ( & self ) -> bool ;
242+
243+ fn has_runtime_error ( & self ) -> bool ;
244+
245+ fn has_error ( & self ) -> bool ;
246+
247+ fn is_error ( & self ) -> bool {
248+ self . has_compile_error ( ) || self . has_runtime_error ( ) || self . has_error ( )
249+ }
250+ }
251+
252+ impl ExecutionErrorResponse for SubmissionResponse {
253+ fn has_compile_error ( & self ) -> bool {
235254 self . compile_error . is_some ( ) || self . full_compile_error . is_some ( )
236255 }
237256
238- pub fn has_runtime_error ( & self ) -> bool {
239- self . status_msg . to_lowercase ( ) . contains ( "error" )
257+ fn has_runtime_error ( & self ) -> bool {
258+ let tle = "time limit exceeded" ;
259+ let msg = self . status_msg . to_lowercase ( ) ;
260+
261+ msg. eq ( tle) || msg. contains ( "error" )
240262 }
241263
242- pub fn has_error ( & self ) -> bool {
264+ fn has_error ( & self ) -> bool {
243265 self . total_correct . lt ( & self . total_testcases )
244266 }
245267}
0 commit comments