Trait AutocorrectableError

Source
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§

Source

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 the Decrust 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.
Source

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§

Source§

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:

  1. Delegates autocorrection suggestion to the Decrust engine
  2. Accesses diagnostic information embedded within rich error contexts
  3. Supports the Diamond certification requirements for comprehensive error handling