Policy Rule • Rust AI Agent SDK
PolicyRule: A policy rule.
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>) -> SelfCreate a new rule.
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
description
fn description(mut self, desc: impl Into<String>) -> SelfSet description.
Parameters:
| Name | Type |
|---|---|
desc | impl Into<String> |
pattern
fn pattern(mut self, pattern: impl Into<String>) -> SelfSet pattern.
Parameters:
| Name | Type |
|---|---|
pattern | impl Into<String> |
keyword
fn keyword(mut self, keyword: impl Into<String>) -> SelfAdd keyword.
Parameters:
| Name | Type |
|---|---|
keyword | impl Into<String> |
action
fn action(mut self, action: PolicyAction) -> SelfSet action.
Parameters:
| Name | Type |
|---|---|
action | PolicyAction |
priority
fn priority(mut self, priority: i32) -> SelfSet priority.
Parameters:
| Name | Type |
|---|---|
priority | i32 |
replacement
fn replacement(mut self, replacement: impl Into<String>) -> SelfSet 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) -> boolCheck if content matches this rule.
Parameters:
| Name | Type |
|---|---|
content | &str |
apply
fn apply(&self, content: &str) -> PolicyResultApply the rule to content.
Parameters:
| Name | Type |
|---|---|
content | &str |
Source
View on GitHubpraisonai/src/policy/mod.rs at line 118