Struct ProcessorContext

Source
pub struct ProcessorContext {
Show 14 fields pub file_format: FileFormat, pub manufacturer: Option<String>, pub model: Option<String>, pub firmware: Option<String>, pub format_version: Option<String>, pub table_name: String, pub tag_id: Option<u16>, pub directory_path: Vec<String>, pub data_offset: usize, pub parent_tags: HashMap<String, TagValue>, pub parameters: HashMap<String, String>, pub byte_order: Option<ByteOrder>, pub base_offset: usize, pub data_size: Option<usize>,
}
Expand description

Rich context passed to processors for capability assessment and processing

This structure provides all the information a processor needs to determine if it can handle the current data and to perform sophisticated processing. It mirrors ExifTool’s combination of $self (ExifTool object state) and $dirInfo (directory information).

§ExifTool Reference

ExifTool processors receive context through multiple mechanisms:

  • $self - ExifTool object with extracted tags and state
  • $dirInfo - Directory information hash with processing parameters
  • Global state like current file type, byte order, etc.

Fields§

§file_format: FileFormat

File format being processed Used for processor selection (e.g., JPEG vs TIFF vs RAW)

§manufacturer: Option<String>

Camera manufacturer extracted from Make tag Primary factor in processor selection

§model: Option<String>

Camera model extracted from Model tag Used for model-specific processor variants

§firmware: Option<String>

Firmware version if available Some processors need firmware-specific handling

§format_version: Option<String>

Format version for format-specific processing Used by processors that handle multiple format generations

§table_name: String

Current table name being processed Helps processors understand their context (e.g., “Canon::AFInfo”)

§tag_id: Option<u16>

Current tag ID being processed (if applicable) Used for tag-specific processor selection

§directory_path: Vec<String>

IFD hierarchy path for nested processing Tracks the path through nested IFDs (e.g., [“IFD0”, “ExifIFD”, “MakerNotes”])

§data_offset: usize

Current data offset in the file Important for offset-based processors and validation

§parent_tags: HashMap<String, TagValue>

Previously extracted tags available as context Processors can use these for conditional logic and cross-references

§parameters: HashMap<String, String>

Additional parameters from SubDirectory configuration ExifTool: SubDirectory parameters like DecryptStart, ByteOrder, etc.

§byte_order: Option<ByteOrder>

Byte order for current data processing Some processors need explicit byte order information

§base_offset: usize

Base offset for relative address calculations Critical for processors that handle offset-based data

§data_size: Option<usize>

Size of data being processed (if known) Used for bounds checking and validation

Implementations§

Source§

impl ProcessorContext

Source

pub fn new(file_format: FileFormat, table_name: String) -> Self

Create a new processor context with minimal required information

Source

pub fn with_camera_info( file_format: FileFormat, table_name: String, manufacturer: Option<String>, model: Option<String>, ) -> Self

Create context with manufacturer and model information

Source

pub fn with_manufacturer(self, manufacturer: String) -> Self

Set manufacturer information

Source

pub fn with_model(self, model: String) -> Self

Set model information

Source

pub fn with_firmware(self, firmware: String) -> Self

Set firmware version

Source

pub fn with_format_version(self, version: String) -> Self

Set format version

Source

pub fn with_tag_id(self, tag_id: u16) -> Self

Set current tag ID

Source

pub fn with_directory_path(self, path: Vec<String>) -> Self

Set directory path

Source

pub fn with_data_offset(self, offset: usize) -> Self

Set data offset

Source

pub fn with_parent_tags(self, tags: HashMap<String, TagValue>) -> Self

Set parent tags

Source

pub fn add_parent_tag(&mut self, name: String, value: TagValue)

Add a parent tag

Source

pub fn with_parent_tag(self, name: String, value: TagValue) -> Self

Add a parent tag (builder pattern)

Source

pub fn with_parameters(self, parameters: HashMap<String, String>) -> Self

Set processing parameters

Source

pub fn add_parameter(&mut self, key: String, value: String)

Add a processing parameter

Source

pub fn with_byte_order(self, byte_order: ByteOrder) -> Self

Set byte order

Source

pub fn with_base_offset(self, base_offset: usize) -> Self

Set base offset

Source

pub fn with_data_size(self, size: usize) -> Self

Set data size

Source

pub fn get_parameter(&self, key: &str) -> Option<&String>

Get a parameter value by key

Source

pub fn get_parent_tag(&self, name: &str) -> Option<&TagValue>

Get a parent tag value by name

Source

pub fn has_required_field(&self, field: &str) -> bool

Check if a required context field is available

Source

pub fn validate_required_fields( &self, required_fields: &[String], ) -> Result<(), Vec<String>>

Validate that all required fields are present

Source

pub fn derive_for_nested(&self, table_name: String, tag_id: Option<u16>) -> Self

Create a derived context for nested processing

This creates a new context based on the current one but updated for processing a nested structure (like a SubDirectory).

Source

pub fn get_directory_path_string(&self) -> String

Get the current directory path as a string

Source

pub fn is_manufacturer(&self, manufacturer: &str) -> bool

Check if this context represents a specific manufacturer

Source

pub fn model_matches(&self, pattern: &str) -> bool

Check if the model matches a pattern

Source

pub fn get_nikon_encryption_keys(&self) -> Option<(String, u32)>

Get encryption key information for Nikon processors

This is a specialized method for Nikon’s encrypted data processing that extracts the serial number and shutter count for decryption.

Trait Implementations§

Source§

impl Clone for ProcessorContext

Source§

fn clone(&self) -> ProcessorContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProcessorContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProcessorContext

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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