pub trait AutocorrectableError {
// Required methods
fn suggest_autocorrection(
&self,
decrust_engine: &Decrust,
source_code_context: Option<&str>,
) -> Option<Autocorrection>;
fn get_diagnostic_info(&self) -> Option<&DiagnosticResult>;
}
Expand description
Trait to extend error types with autocorrection capabilities.
This trait should be implemented for the main error type of the application (DecrustError
)
to enable the Decrust engine to provide suggestions.
Required Methods§
Sourcefn suggest_autocorrection(
&self,
decrust_engine: &Decrust,
source_code_context: Option<&str>,
) -> Option<Autocorrection>
fn suggest_autocorrection( &self, decrust_engine: &Decrust, source_code_context: Option<&str>, ) -> Option<Autocorrection>
Suggests a potential autocorrection for this error.
§Arguments
decrust_engine
: An instance of theDecrust
engine to generate suggestions.source_code_context
: Optional string slice containing the source code around where the error might have originated, for more context-aware suggestions.
Sourcefn get_diagnostic_info(&self) -> Option<&DiagnosticResult>
fn get_diagnostic_info(&self) -> Option<&DiagnosticResult>
Retrieves diagnostic information if available within the error structure. This is useful if the error originated from a tool (like a compiler or linter) that provides structured diagnostic output.
Implementors§
impl AutocorrectableError for DecrustError
Implementation of AutocorrectableError for DecrustError
This implementation enables the Decrust error system to provide intelligent autocorrection suggestions for errors that occur during application execution. It integrates with the Decrust engine to analyze errors and suggest potential fixes.
The implementation:
- Delegates autocorrection suggestion to the Decrust engine
- Accesses diagnostic information embedded within rich error contexts
- Supports the Diamond certification requirements for comprehensive error handling