إنتقل إلى المحتوى الرئيسي

مرجع FileType API

التوثيق الكامل لنوع FileType الأساسي.

التعريف

pub struct FileType {
pub extension: String,
pub mime_type: String,
pub confidence: f64,
pub entropy_profile: Option<EntropyProfile>,
pub threat_level: ThreatLevel,
pub detected_formats: Vec<String>,
pub embedded_threats: Vec<EmbeddedThreat>,
pub hashes: Option<FileHashes>,
pub binary_metadata: Option<BinaryMetadata>,
}

الحقول

الحقلالنوعالوصف
extensionStringامتداد الملف المكتشف
mime_typeStringنوع MIME
confidencef64درجة الثقة (0.0-1.0)
threat_levelThreatLevelتقييم الخطورة
detected_formatsVec<String>كل الصيغ المكتشفة

الدوال الثابتة

from_bytes

pub async fn from_bytes(
data: &[u8],
config: &DetectionConfig
) -> Result<Self, DetectionError>

from_file_path

pub async fn from_file_path(
path: &str,
config: &DetectionConfig
) -> Result<Self, DetectionError>

مثال الاستخدام

use batin::{FileType, DetectionConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = DetectionConfig::default();
let result = FileType::from_file_path("file.pdf", &config).await?;

println!("النوع: {} ({:?})", result.extension, result.threat_level);
Ok(())
}