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
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
impl ProcessorContext
Sourcepub fn new(file_format: FileFormat, table_name: String) -> Self
pub fn new(file_format: FileFormat, table_name: String) -> Self
Create a new processor context with minimal required information
Sourcepub fn with_camera_info(
file_format: FileFormat,
table_name: String,
manufacturer: Option<String>,
model: Option<String>,
) -> Self
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
Sourcepub fn with_manufacturer(self, manufacturer: String) -> Self
pub fn with_manufacturer(self, manufacturer: String) -> Self
Set manufacturer information
Sourcepub fn with_model(self, model: String) -> Self
pub fn with_model(self, model: String) -> Self
Set model information
Sourcepub fn with_firmware(self, firmware: String) -> Self
pub fn with_firmware(self, firmware: String) -> Self
Set firmware version
Sourcepub fn with_format_version(self, version: String) -> Self
pub fn with_format_version(self, version: String) -> Self
Set format version
Sourcepub fn with_tag_id(self, tag_id: u16) -> Self
pub fn with_tag_id(self, tag_id: u16) -> Self
Set current tag ID
Sourcepub fn with_directory_path(self, path: Vec<String>) -> Self
pub fn with_directory_path(self, path: Vec<String>) -> Self
Set directory path
Sourcepub fn with_data_offset(self, offset: usize) -> Self
pub fn with_data_offset(self, offset: usize) -> Self
Set data offset
Set parent tags
Sourcepub fn add_parent_tag(&mut self, name: String, value: TagValue)
pub fn add_parent_tag(&mut self, name: String, value: TagValue)
Add a parent tag
Sourcepub fn with_parent_tag(self, name: String, value: TagValue) -> Self
pub fn with_parent_tag(self, name: String, value: TagValue) -> Self
Add a parent tag (builder pattern)
Sourcepub fn with_parameters(self, parameters: HashMap<String, String>) -> Self
pub fn with_parameters(self, parameters: HashMap<String, String>) -> Self
Set processing parameters
Sourcepub fn add_parameter(&mut self, key: String, value: String)
pub fn add_parameter(&mut self, key: String, value: String)
Add a processing parameter
Sourcepub fn with_byte_order(self, byte_order: ByteOrder) -> Self
pub fn with_byte_order(self, byte_order: ByteOrder) -> Self
Set byte order
Sourcepub fn with_base_offset(self, base_offset: usize) -> Self
pub fn with_base_offset(self, base_offset: usize) -> Self
Set base offset
Sourcepub fn with_data_size(self, size: usize) -> Self
pub fn with_data_size(self, size: usize) -> Self
Set data size
Sourcepub fn get_parameter(&self, key: &str) -> Option<&String>
pub fn get_parameter(&self, key: &str) -> Option<&String>
Get a parameter value by key
Sourcepub fn get_parent_tag(&self, name: &str) -> Option<&TagValue>
pub fn get_parent_tag(&self, name: &str) -> Option<&TagValue>
Get a parent tag value by name
Sourcepub fn has_required_field(&self, field: &str) -> bool
pub fn has_required_field(&self, field: &str) -> bool
Check if a required context field is available
Sourcepub fn validate_required_fields(
&self,
required_fields: &[String],
) -> Result<(), Vec<String>>
pub fn validate_required_fields( &self, required_fields: &[String], ) -> Result<(), Vec<String>>
Validate that all required fields are present
Sourcepub fn derive_for_nested(&self, table_name: String, tag_id: Option<u16>) -> Self
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).
Sourcepub fn get_directory_path_string(&self) -> String
pub fn get_directory_path_string(&self) -> String
Get the current directory path as a string
Sourcepub fn is_manufacturer(&self, manufacturer: &str) -> bool
pub fn is_manufacturer(&self, manufacturer: &str) -> bool
Check if this context represents a specific manufacturer
Sourcepub fn model_matches(&self, pattern: &str) -> bool
pub fn model_matches(&self, pattern: &str) -> bool
Check if the model matches a pattern
Sourcepub fn get_nikon_encryption_keys(&self) -> Option<(String, u32)>
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
impl Clone for ProcessorContext
Source§fn clone(&self) -> ProcessorContext
fn clone(&self) -> ProcessorContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more