Struct ProcessorRegistry

Source
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

Source

pub fn new() -> Self

Create a new processor registry

Source

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.

Source

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.

Source

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.

Source

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
  1. Evaluate all processors for capability
  2. Filter out incompatible processors
  3. Apply dispatch rules for tie-breaking and preference
  4. Sort by capability and rule preferences
  5. Return the best candidate
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_stats(&self) -> &RegistryStats

Get registry statistics

Source

pub fn reset_stats(&mut self)

Reset registry statistics

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for ProcessorRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more