mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
implement list(s) reload api
This commit is contained in:
parent
cda06f0811
commit
96b9646c8c
4 changed files with 68 additions and 4 deletions
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue