Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
PolicyRule
Defined in the policy module.
Rust AI Agent SDK
A policy rule.
Fields
| Name | Type | Description |
|---|
name | String | Rule name |
description | Option<String> | Rule description |
pattern | Option<String> | Pattern to match (regex) |
keywords | Vec<String> | Keywords to match |
action | PolicyAction | Action to take |
enabled | bool | Whether the rule is enabled |
priority | i32 | Priority (higher = checked first) |
replacement | Option<String> | Replacement text for redaction |
Methods
new
fn new(name: impl Into<String>) -> Self
Create a new rule.
Parameters:
| Name | Type |
|---|
name | impl Into<String> |
description
fn description(mut self, desc: impl Into<String>) -> Self
Set description.
Parameters:
| Name | Type |
|---|
desc | impl Into<String> |
pattern
fn pattern(mut self, pattern: impl Into<String>) -> Self
Set pattern.
Parameters:
| Name | Type |
|---|
pattern | impl Into<String> |
keyword
fn keyword(mut self, keyword: impl Into<String>) -> Self
Add keyword.
Parameters:
| Name | Type |
|---|
keyword | impl Into<String> |
action
fn action(mut self, action: PolicyAction) -> Self
Set action.
Parameters:
| Name | Type |
|---|
action | PolicyAction |
priority
fn priority(mut self, priority: i32) -> Self
Set priority.
Parameters:
replacement
fn replacement(mut self, replacement: impl Into<String>) -> Self
Set replacement.
Parameters:
| Name | Type |
|---|
replacement | impl Into<String> |
enable
fn enable(&mut self) -> ()
Enable the rule.
disable
fn disable(&mut self) -> ()
Disable the rule.
matches
fn matches(&self, content: &str) -> bool
Check if content matches this rule.
Parameters:
apply
fn apply(&self, content: &str) -> PolicyResult
Apply the rule to content.
Parameters:
Source
View on GitHub
praisonai/src/policy/mod.rs at line 118