pub trait ConfigValidator {
// Required methods
fn validate(&self) -> Result<(), ConfigError>;
fn get_defaults() -> Self
where Self: Sized;
// Provided methods
fn validate_batch_size(&self, batch_size: usize) -> Result<(), ConfigError> { ... }
fn validate_batch_size_with_limits(
&self,
batch_size: usize,
max_batch_size: usize,
) -> Result<(), ConfigError> { ... }
fn validate_model_path(&self, path: &Path) -> Result<(), ConfigError> { ... }
fn validate_image_dimensions(
&self,
width: u32,
height: u32,
) -> Result<(), ConfigError> { ... }
fn validate_confidence_threshold(
&self,
threshold: f32,
) -> Result<(), ConfigError> { ... }
fn validate_memory_limit(&self, limit_mb: usize) -> Result<(), ConfigError> { ... }
fn validate_thread_count(
&self,
thread_count: usize,
) -> Result<(), ConfigError> { ... }
fn validate_f32_range(
&self,
value: f32,
min: f32,
max: f32,
field_name: &str,
) -> Result<(), ConfigError> { ... }
fn validate_positive_f32(
&self,
value: f32,
field_name: &str,
) -> Result<(), ConfigError> { ... }
fn validate_positive_usize(
&self,
value: usize,
field_name: &str,
) -> Result<(), ConfigError> { ... }
}Expand description
A trait for validating configuration parameters.
This trait provides methods for validating various configuration parameters used in the OCR pipeline, such as batch sizes, model paths, and image dimensions.
Required Methods§
Sourcefn validate(&self) -> Result<(), ConfigError>
fn validate(&self) -> Result<(), ConfigError>
Validates the configuration.
This method should be implemented by types that need to validate their configuration.
§Returns
A Result indicating success or a ConfigError if validation fails.
Sourcefn get_defaults() -> Selfwhere
Self: Sized,
fn get_defaults() -> Selfwhere
Self: Sized,
Returns the default configuration.
This method should be implemented by types that have default configuration values.
§Returns
The default configuration.
Provided Methods§
Sourcefn validate_batch_size(&self, batch_size: usize) -> Result<(), ConfigError>
fn validate_batch_size(&self, batch_size: usize) -> Result<(), ConfigError>
Sourcefn validate_batch_size_with_limits(
&self,
batch_size: usize,
max_batch_size: usize,
) -> Result<(), ConfigError>
fn validate_batch_size_with_limits( &self, batch_size: usize, max_batch_size: usize, ) -> Result<(), ConfigError>
Validates a batch size against limits.
This method checks that the batch size is greater than 0 and does not exceed the maximum allowed batch size.
§Arguments
batch_size- The batch size to validate.max_batch_size- The maximum allowed batch size.
§Returns
A Result indicating success or a ConfigError if validation fails.
Sourcefn validate_model_path(&self, path: &Path) -> Result<(), ConfigError>
fn validate_model_path(&self, path: &Path) -> Result<(), ConfigError>
Sourcefn validate_image_dimensions(
&self,
width: u32,
height: u32,
) -> Result<(), ConfigError>
fn validate_image_dimensions( &self, width: u32, height: u32, ) -> Result<(), ConfigError>
Sourcefn validate_confidence_threshold(
&self,
threshold: f32,
) -> Result<(), ConfigError>
fn validate_confidence_threshold( &self, threshold: f32, ) -> Result<(), ConfigError>
Sourcefn validate_memory_limit(&self, limit_mb: usize) -> Result<(), ConfigError>
fn validate_memory_limit(&self, limit_mb: usize) -> Result<(), ConfigError>
Sourcefn validate_thread_count(&self, thread_count: usize) -> Result<(), ConfigError>
fn validate_thread_count(&self, thread_count: usize) -> Result<(), ConfigError>
Sourcefn validate_f32_range(
&self,
value: f32,
min: f32,
max: f32,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_f32_range( &self, value: f32, min: f32, max: f32, field_name: &str, ) -> Result<(), ConfigError>
Validates a float value is within a specified range.
§Arguments
value- The value to validate.min- The minimum allowed value (inclusive).max- The maximum allowed value (inclusive).field_name- The name of the field being validated.
§Returns
A Result indicating success or a ConfigError if validation fails.
Sourcefn validate_positive_f32(
&self,
value: f32,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_positive_f32( &self, value: f32, field_name: &str, ) -> Result<(), ConfigError>
Sourcefn validate_positive_usize(
&self,
value: usize,
field_name: &str,
) -> Result<(), ConfigError>
fn validate_positive_usize( &self, value: usize, field_name: &str, ) -> Result<(), ConfigError>
Implementations on Foreign Types§
Source§impl ConfigValidator for Box<dyn ErasedConfig>
impl ConfigValidator for Box<dyn ErasedConfig>
fn validate(&self) -> Result<(), ConfigError>
fn get_defaults() -> Self
Implementors§
impl ConfigValidator for ExtensiblePipelineConfig
Implementation of ConfigValidator trait for ExtensiblePipelineConfig.