Trait DispatchRule

Source
pub trait DispatchRule: Send + Sync {
    // Required methods
    fn applies_to(&self, context: &ProcessorContext) -> bool;
    fn select_processor(
        &self,
        candidates: &[(ProcessorKey, Arc<dyn BinaryDataProcessor>, ProcessorCapability)],
        context: &ProcessorContext,
    ) -> Option<(ProcessorKey, Arc<dyn BinaryDataProcessor>)>;
    fn description(&self) -> &str;

    // Provided method
    fn priority(&self) -> u8 { ... }
}
Expand description

Trait for dispatch rules that influence processor selection

Dispatch rules provide sophisticated logic for processor selection that goes beyond simple capability assessment. They implement ExifTool’s conditional dispatch patterns found in manufacturer modules.

§ExifTool Reference

ExifTool uses various conditional dispatch patterns:

# Canon.pm conditional dispatch
{
    Condition => '$$self{Model} =~ /EOS R5/',
    SubDirectory => { ProcessProc => \&ProcessCanonSerialDataMkII }
},
{
    Condition => '$$self{Model} =~ /EOS.*Mark/',
    SubDirectory => { ProcessProc => \&ProcessCanonSerialData }
}

This trait system captures these patterns in a structured way.

Required Methods§

Source

fn applies_to(&self, context: &ProcessorContext) -> bool

Check if this rule applies to the given context

Returns true if this rule should be considered for processor selection in the current context. This allows rules to scope themselves to specific manufacturers, file types, or other conditions.

Source

fn select_processor( &self, candidates: &[(ProcessorKey, Arc<dyn BinaryDataProcessor>, ProcessorCapability)], context: &ProcessorContext, ) -> Option<(ProcessorKey, Arc<dyn BinaryDataProcessor>)>

Select a processor from the available candidates

Given a list of compatible processors, this rule can select the most appropriate one based on its specific logic. Returns None if the rule doesn’t want to make a selection.

The candidates are provided as (key, processor, capability) tuples.

Source

fn description(&self) -> &str

Get a human-readable description of this rule

Provided Methods§

Source

fn priority(&self) -> u8

Get the priority of this rule (higher priority rules are evaluated first)

Implementors§