Skip to content

Commit 4a5ccfb

Browse files
committed
fix: remove const fn from Windows registry_monitor methods
These methods contain non-const operations (HashMap::insert, ?, clone) inside #[cfg(target_os = "windows")] blocks. On Linux clippy suggests const but on Windows they cannot be const. Use #[allow] to suppress.
1 parent 07fabac commit 4a5ccfb

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exclude = ["gui/src-tauri"]
1818

1919
[workspace.package]
2020
authors = ["g1e2x87"]
21-
version = "0.2.1"
21+
version = "0.2.2"
2222
edition = "2021"
2323
license = "MIT OR Apache-2.0"
2424
description = "Open-source antivirus engine with hash, YARA, and heuristic detection"

crates/realtime/src/registry_monitor.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ impl RegistryMonitor {
6767
}
6868

6969
/// Create a new `RegistryMonitor` watching the specified registry keys.
70-
pub const fn with_keys(watched_keys: Vec<String>) -> Self {
70+
#[allow(clippy::missing_const_for_fn)] // not const on Windows (HashMap::new)
71+
pub fn with_keys(watched_keys: Vec<String>) -> Self {
7172
Self {
7273
watched_keys,
7374
#[cfg(target_os = "windows")]
@@ -84,7 +85,8 @@ impl RegistryMonitor {
8485
///
8586
/// This must be called before `detect_changes` to establish the initial state.
8687
/// On non-Windows platforms this is a no-op.
87-
pub const fn capture_baseline(&mut self) -> Result<(), String> {
88+
#[allow(clippy::missing_const_for_fn)] // not const on Windows (HashMap::insert, ?)
89+
pub fn capture_baseline(&mut self) -> Result<(), String> {
8890
#[cfg(target_os = "windows")]
8991
{
9092
for key in &self.watched_keys {
@@ -101,7 +103,8 @@ impl RegistryMonitor {
101103
/// the internal baseline is updated to the current state.
102104
///
103105
/// On non-Windows platforms this always returns an empty list.
104-
pub const fn detect_changes(&mut self) -> Result<Vec<RegistryEvent>, String> {
106+
#[allow(clippy::missing_const_for_fn)] // not const on Windows (calls detect_changes_windows)
107+
pub fn detect_changes(&mut self) -> Result<Vec<RegistryEvent>, String> {
105108
#[cfg(target_os = "windows")]
106109
{
107110
self.detect_changes_windows()

0 commit comments

Comments
 (0)