implement list(s) reload api

This commit is contained in:
yggverse 2026-03-28 06:40:01 +02:00
parent cda06f0811
commit 96b9646c8c
4 changed files with 68 additions and 4 deletions

View file

@ -24,7 +24,7 @@ impl List {
is_enabled,
})
}
/// Change rule set status by list ID
/// Change rule set status
pub async fn set_enabled(&mut self, is_enabled: bool) -> Result<bool> {
let was_enabled = self.is_enabled;
self.is_enabled = is_enabled;
@ -35,7 +35,13 @@ impl List {
}
Ok(was_enabled)
}
/// Check if rule is exist in the items index
/// Reload rule set from it source
pub async fn reload(&mut self) -> Result<()> {
self.rules.clear();
load(&mut self.rules, &self.source).await?;
Ok(())
}
/// Check if rule is exist in the index
pub fn contains(&self, value: &str) -> bool {
self.is_enabled && self.rules.iter().any(|rule| rule.contains(value))
}