pub struct MatchResult {
pub message: String,
pub offset: usize,
pub level: u32,
pub value: Value,
pub confidence: f64,
}Expand description
Result of evaluating a magic rule
Contains information about a successful rule match, including the rule that matched and its associated message.
Fields§
§message: StringThe message associated with the matching rule
offset: usizeThe offset where the match occurred
level: u32The rule level (depth in hierarchy)
value: ValueThe matched value
confidence: f64Confidence score (0.0 to 1.0)
Calculated based on match depth in the rule hierarchy. Deeper matches indicate more specific file type identification and thus higher confidence.
Implementations§
Source§impl MatchResult
impl MatchResult
Sourcepub fn calculate_confidence(level: u32) -> f64
pub fn calculate_confidence(level: u32) -> f64
Calculate confidence score based on rule depth
Formula: min(1.0, 0.3 + (level * 0.2))
- Level 0 (root): 0.3
- Level 1: 0.5
- Level 2: 0.7
- Level 3: 0.9
- Level 4+: 1.0 (capped)
§Examples
use libmagic_rs::evaluator::MatchResult;
assert!((MatchResult::calculate_confidence(0) - 0.3).abs() < 0.001);
assert!((MatchResult::calculate_confidence(3) - 0.9).abs() < 0.001);
assert!((MatchResult::calculate_confidence(10) - 1.0).abs() < 0.001);Trait Implementations§
Source§impl Clone for MatchResult
impl Clone for MatchResult
Source§fn clone(&self) -> MatchResult
fn clone(&self) -> MatchResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MatchResult
impl Debug for MatchResult
Source§impl<'de> Deserialize<'de> for MatchResult
impl<'de> Deserialize<'de> for MatchResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MatchResult
impl PartialEq for MatchResult
Source§impl Serialize for MatchResult
impl Serialize for MatchResult
impl StructuralPartialEq for MatchResult
Auto Trait Implementations§
impl Freeze for MatchResult
impl RefUnwindSafe for MatchResult
impl Send for MatchResult
impl Sync for MatchResult
impl Unpin for MatchResult
impl UnwindSafe for MatchResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more