pub trait ConfigValidatorExt: ConfigValidator {
// Provided methods
fn validate_and_wrap_ocr_error(self) -> Result<Self, OCRError>
where Self: Sized { ... }
fn validate_and_wrap_generic(
self,
) -> Result<Self, Box<dyn Error + Send + Sync>>
where Self: Sized { ... }
}Expand description
Extension trait for ConfigValidator that provides error wrapping utilities.
This trait extends ConfigValidator to provide convenient methods for wrapping validation errors into OCRError types, reducing duplication across the codebase.
Provided Methods§
Sourcefn validate_and_wrap_ocr_error(self) -> Result<Self, OCRError>where
Self: Sized,
fn validate_and_wrap_ocr_error(self) -> Result<Self, OCRError>where
Self: Sized,
Validates configuration and wraps any errors into OCRError::ConfigError.
This method provides a convenient way to validate configuration and
automatically wrap any validation errors into the appropriate OCRError type.
This eliminates the repeated config.validate().map_err(|e| OCRError::ConfigError { message: e.to_string() })
pattern found throughout the codebase.
§Returns
A Result indicating success or an OCRError if validation fails.
Sourcefn validate_and_wrap_generic(self) -> Result<Self, Box<dyn Error + Send + Sync>>where
Self: Sized,
fn validate_and_wrap_generic(self) -> Result<Self, Box<dyn Error + Send + Sync>>where
Self: Sized,
Validates configuration and wraps any errors into a generic error.
This method provides a convenient way to validate configuration when working with generic error types.
§Returns
A Result indicating success or a wrapped error if validation fails.