pub struct ProcessorRegistry { /* private fields */ }
Expand description
Central registry for processor management and dispatch
The ProcessorRegistry manages all available processors and provides sophisticated selection logic based on processor capabilities and dispatch rules. It implements ExifTool’s processor dispatch system with enhanced type safety and performance.
§ExifTool Reference
This registry implements the logic from ExifTool’s processor dispatch:
my $proc = $$subdir{ProcessProc} || $$tagTablePtr{PROCESS_PROC} || \&ProcessExif;
Combined with conditional evaluation and capability assessment.
Implementations§
Source§impl ProcessorRegistry
impl ProcessorRegistry
Sourcepub fn register_processor<P: BinaryDataProcessor + 'static>(
&mut self,
key: ProcessorKey,
processor: P,
)
pub fn register_processor<P: BinaryDataProcessor + 'static>( &mut self, key: ProcessorKey, processor: P, )
Register a processor in the registry
This adds a processor implementation to the registry, making it available for selection during processing.
Sourcepub fn add_dispatch_rule<R: DispatchRule + 'static>(&mut self, rule: R)
pub fn add_dispatch_rule<R: DispatchRule + 'static>(&mut self, rule: R)
Add a dispatch rule to the registry
Dispatch rules provide sophisticated logic for processor selection that goes beyond simple capability assessment.
Sourcepub fn set_fallback_chain(&mut self, chain: Vec<ProcessorKey>)
pub fn set_fallback_chain(&mut self, chain: Vec<ProcessorKey>)
Set the fallback processor chain
This defines the order of processors to try when no specific processor is found through normal selection.
Sourcepub fn find_best_processor(
&self,
context: &ProcessorContext,
) -> Option<(ProcessorKey, SharedProcessor)>
pub fn find_best_processor( &self, context: &ProcessorContext, ) -> Option<(ProcessorKey, SharedProcessor)>
Find the best processor for the given context
This is the main selection method that evaluates all registered processors and returns the most appropriate one based on capabilities and dispatch rules.
§Selection Algorithm
- Evaluate all processors for capability
- Filter out incompatible processors
- Apply dispatch rules for tie-breaking and preference
- Sort by capability and rule preferences
- Return the best candidate
Sourcepub fn find_processor(
&self,
key: &ProcessorKey,
) -> Option<(ProcessorKey, SharedProcessor)>
pub fn find_processor( &self, key: &ProcessorKey, ) -> Option<(ProcessorKey, SharedProcessor)>
Find a specific processor by key
This method allows direct lookup of processors by their key, useful for nested processing where a specific processor is requested.
Sourcepub fn process_data(
&self,
data: &[u8],
context: &ProcessorContext,
) -> Result<ProcessorResult>
pub fn process_data( &self, data: &[u8], context: &ProcessorContext, ) -> Result<ProcessorResult>
Process data using the best available processor
This is a convenience method that combines processor selection and processing in a single call.
Sourcepub fn list_processors(&self) -> Vec<(ProcessorKey, ProcessorMetadata)>
pub fn list_processors(&self) -> Vec<(ProcessorKey, ProcessorMetadata)>
Get all registered processors
Returns a list of all processor keys and their metadata for debugging and introspection.
Sourcepub fn get_compatible_processors(
&self,
context: &ProcessorContext,
) -> Vec<(ProcessorKey, ProcessorCapability)>
pub fn get_compatible_processors( &self, context: &ProcessorContext, ) -> Vec<(ProcessorKey, ProcessorCapability)>
Get processors that can handle a specific context
Returns all compatible processors with their capability assessments for analysis and debugging.
Sourcepub fn get_stats(&self) -> &RegistryStats
pub fn get_stats(&self) -> &RegistryStats
Get registry statistics
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset registry statistics
Sourcepub fn processor_count(&self) -> usize
pub fn processor_count(&self) -> usize
Get the number of registered processors
This method returns the total count of registered processors, useful for debugging and initialization verification.
Sourcepub fn register_standard_processors(&mut self)
pub fn register_standard_processors(&mut self)
Setup standard processors that are always available
This method registers the core processors that handle basic EXIF processing and provide fallback functionality.