pub struct EvaluationContext { /* private fields */ }Expand description
Context for maintaining evaluation state during rule processing
The EvaluationContext tracks the current state of rule evaluation,
including the current offset position, recursion depth for nested rules,
and configuration settings that control evaluation behavior.
§Examples
use libmagic_rs::evaluator::EvaluationContext;
use libmagic_rs::EvaluationConfig;
let config = EvaluationConfig::default();
let context = EvaluationContext::new(config);
assert_eq!(context.current_offset(), 0);
assert_eq!(context.recursion_depth(), 0);Implementations§
Source§impl EvaluationContext
impl EvaluationContext
Sourcepub const fn new(config: EvaluationConfig) -> Self
pub const fn new(config: EvaluationConfig) -> Self
Create a new evaluation context with the given configuration
§Arguments
config- Configuration settings for evaluation behavior
§Examples
use libmagic_rs::evaluator::EvaluationContext;
use libmagic_rs::EvaluationConfig;
let config = EvaluationConfig::default();
let context = EvaluationContext::new(config);Sourcepub const fn current_offset(&self) -> usize
pub const fn current_offset(&self) -> usize
Sourcepub fn set_current_offset(&mut self, offset: usize)
pub fn set_current_offset(&mut self, offset: usize)
Sourcepub const fn recursion_depth(&self) -> u32
pub const fn recursion_depth(&self) -> u32
Sourcepub fn increment_recursion_depth(&mut self) -> Result<(), LibmagicError>
pub fn increment_recursion_depth(&mut self) -> Result<(), LibmagicError>
Sourcepub fn decrement_recursion_depth(&mut self) -> Result<(), LibmagicError>
pub fn decrement_recursion_depth(&mut self) -> Result<(), LibmagicError>
Decrement the recursion depth
§Errors
Returns an error if the recursion depth is already 0, as this indicates a programming error in the evaluation logic (mismatched increment/decrement calls).
Sourcepub const fn config(&self) -> &EvaluationConfig
pub const fn config(&self) -> &EvaluationConfig
Get a reference to the evaluation configuration
§Returns
A reference to the EvaluationConfig used by this context
Sourcepub const fn should_stop_at_first_match(&self) -> bool
pub const fn should_stop_at_first_match(&self) -> bool
Check if evaluation should stop at the first match
§Returns
true if evaluation should stop at the first match, false otherwise
Sourcepub const fn max_string_length(&self) -> usize
pub const fn max_string_length(&self) -> usize
Get the maximum string length allowed
§Returns
The maximum string length that should be read during evaluation
Sourcepub const fn enable_mime_types(&self) -> bool
pub const fn enable_mime_types(&self) -> bool
Check if MIME type mapping is enabled
§Returns
true if MIME type mapping should be performed, false otherwise
Sourcepub const fn timeout_ms(&self) -> Option<u64>
pub const fn timeout_ms(&self) -> Option<u64>
Get the evaluation timeout in milliseconds
§Returns
The timeout duration in milliseconds, or None if no timeout is set
Trait Implementations§
Source§impl Clone for EvaluationContext
impl Clone for EvaluationContext
Source§fn clone(&self) -> EvaluationContext
fn clone(&self) -> EvaluationContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more