pub struct RulesStore {
pub rules: Vec<Rule>,
pub last_decay_run: Option<String>,
}Expand description
The rules store: manages rules.json persistence and lifecycle.
Fields§
§rules: Vec<Rule>§last_decay_run: Option<String>Implementations§
Source§impl RulesStore
impl RulesStore
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Load rules store from disk. Returns default if file doesn’t exist.
Sourcepub fn project_rules_path(project_id: &str) -> PathBuf
pub fn project_rules_path(project_id: &str) -> PathBuf
Resolve the rules.json path for a project.
Sourcepub fn global_rules_path() -> PathBuf
pub fn global_rules_path() -> PathBuf
Resolve the global rules.json path (~/.edda/rules.json).
Sourcepub fn load_project(project_id: &str) -> Self
pub fn load_project(project_id: &str) -> Self
Load project-scoped rules.
Sourcepub fn save_project(&self, project_id: &str) -> Result<()>
pub fn save_project(&self, project_id: &str) -> Result<()>
Save project-scoped rules.
Sourcepub fn active_rules(&self) -> Vec<&Rule>
pub fn active_rules(&self) -> Vec<&Rule>
Get all active (enforceable) rules.
Sourcepub fn alive_rules(&self) -> Vec<&Rule>
pub fn alive_rules(&self) -> Vec<&Rule>
Get all alive rules (not dead/superseded).
Sourcepub fn propose_rule(
&mut self,
trigger: String,
action: String,
anchor_file: Option<String>,
category: RuleCategory,
source_session: String,
source_event: Option<String>,
) -> String
pub fn propose_rule( &mut self, trigger: String, action: String, anchor_file: Option<String>, category: RuleCategory, source_session: String, source_event: Option<String>, ) -> String
Add a new rule proposal. If a rule with the same trigger already exists and is alive, increment its hits instead (confirmation).
Sourcepub fn run_decay_cycle(&mut self)
pub fn run_decay_cycle(&mut self)
Run the full decay cycle on all rules.
- Time decay: check TTL against last_hit
- Anchor decay: check if anchored file changed
- Enforce active window cap (~15)
Sourcepub fn gc_dead_rules(&mut self) -> usize
pub fn gc_dead_rules(&mut self) -> usize
Garbage-collect dead rules (remove from store entirely).
Sourcepub fn find_by_trigger(&self, trigger_pattern: &str) -> Vec<&Rule>
pub fn find_by_trigger(&self, trigger_pattern: &str) -> Vec<&Rule>
Find rules matching a given trigger pattern (substring match).
Sourcepub fn stats(&self) -> StoreStats
pub fn stats(&self) -> StoreStats
Summary statistics.
Trait Implementations§
Source§impl Clone for RulesStore
impl Clone for RulesStore
Source§fn clone(&self) -> RulesStore
fn clone(&self) -> RulesStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RulesStore
impl Debug for RulesStore
Source§impl Default for RulesStore
impl Default for RulesStore
Source§fn default() -> RulesStore
fn default() -> RulesStore
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for RulesStore
impl<'de> Deserialize<'de> for RulesStore
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 RulesStore
impl RefUnwindSafe for RulesStore
impl Send for RulesStore
impl Sync for RulesStore
impl Unpin for RulesStore
impl UnsafeUnpin for RulesStore
impl UnwindSafe for RulesStore
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