pub struct MLConfig {
pub enabled: bool,
pub model_variant: ModelVariant,
pub threshold: f32,
pub fallback_to_heuristic: bool,
pub cache_enabled: bool,
pub cache_config: CacheSettings,
pub extra: HashMap<String, Value>,
}Expand description
ML detection configuration for scanners
§Fields
enabled: Whether ML detection is enabledmodel_variant: Model precision (FP32, FP16, INT8)threshold: Detection threshold (0.0 to 1.0)fallback_to_heuristic: Use heuristic if ML failscache_enabled: Enable result cachingcache_config: Cache configuration
§Recommended Configurations
Production (balanced):
ⓘ
MLConfig {
enabled: true,
model_variant: ModelVariant::FP16,
threshold: 0.5,
fallback_to_heuristic: true,
cache_enabled: true,
cache_config: CacheSettings::default(),
}High accuracy:
ⓘ
MLConfig {
enabled: true,
model_variant: ModelVariant::FP32,
threshold: 0.3, // Lower threshold = more sensitive
fallback_to_heuristic: false, // Require ML
cache_enabled: true,
cache_config: CacheSettings::default(),
}Edge/Mobile:
ⓘ
MLConfig {
enabled: true,
model_variant: ModelVariant::INT8,
threshold: 0.6,
fallback_to_heuristic: true,
cache_enabled: true,
cache_config: CacheSettings {
max_size: 100, // Smaller cache
ttl: Duration::from_secs(600),
},
}Fields§
§enabled: boolWhether ML detection is enabled
model_variant: ModelVariantModel variant to use (FP32, FP16, INT8)
threshold: f32Detection threshold (0.0 to 1.0)
- Higher = fewer false positives, more false negatives
- Lower = fewer false negatives, more false positives
- Recommended: 0.5 for balanced results
fallback_to_heuristic: boolUse heuristic detection if ML fails or is unavailable
cache_enabled: boolEnable result caching for repeated inputs
cache_config: CacheSettingsCache settings
extra: HashMap<String, Value>Additional model-specific configuration
Implementations§
Source§impl MLConfig
impl MLConfig
Sourcepub fn new(model_variant: ModelVariant, threshold: f32) -> Self
pub fn new(model_variant: ModelVariant, threshold: f32) -> Self
Create a new ML configuration
Sourcepub fn production() -> Self
pub fn production() -> Self
Create ML configuration for production use
- FP16 model (balanced speed/accuracy)
- 0.5 threshold (balanced sensitivity)
- Heuristic fallback enabled
- Caching enabled with 1000 entries, 1 hour TTL
Sourcepub fn edge() -> Self
pub fn edge() -> Self
Create ML configuration for edge/mobile deployment
- INT8 model (smallest size)
- 0.6 threshold (fewer false positives)
- Heuristic fallback enabled
- Smaller cache (100 entries, 10 minutes TTL)
Sourcepub fn high_accuracy() -> Self
pub fn high_accuracy() -> Self
Create ML configuration for high accuracy
- FP32 model (highest accuracy)
- 0.3 threshold (very sensitive)
- No heuristic fallback
- Aggressive caching
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MLConfig
impl<'de> Deserialize<'de> for MLConfig
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
Auto Trait Implementations§
impl Freeze for MLConfig
impl RefUnwindSafe for MLConfig
impl Send for MLConfig
impl Sync for MLConfig
impl Unpin for MLConfig
impl UnwindSafe for MLConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more