Policy Rule • Rust AI Agent SDK

PolicyRule: A policy rule.

PolicyRule

Defined in the policy module.

Rust AI Agent SDK

A policy rule.

Fields

NameTypeDescription
nameStringRule name
descriptionOption<String>Rule description
patternOption<String>Pattern to match (regex)
keywordsVec<String>Keywords to match
actionPolicyActionAction to take
enabledboolWhether the rule is enabled
priorityi32Priority (higher = checked first)
replacementOption<String>Replacement text for redaction

Methods

new

rust
fn new(name: impl Into<String>) -> Self

Create a new rule.

Parameters:

NameType
nameimpl Into&lt;String&gt;

description

rust
fn description(mut self, desc: impl Into<String>) -> Self

Set description.

Parameters:

NameType
descimpl Into&lt;String&gt;

pattern

rust
fn pattern(mut self, pattern: impl Into<String>) -> Self

Set pattern.

Parameters:

NameType
patternimpl Into&lt;String&gt;

keyword

rust
fn keyword(mut self, keyword: impl Into<String>) -> Self

Add keyword.

Parameters:

NameType
keywordimpl Into&lt;String&gt;

action

rust
fn action(mut self, action: PolicyAction) -> Self

Set action.

Parameters:

NameType
actionPolicyAction

priority

rust
fn priority(mut self, priority: i32) -> Self

Set priority.

Parameters:

NameType
priorityi32

replacement

rust
fn replacement(mut self, replacement: impl Into<String>) -> Self

Set replacement.

Parameters:

NameType
replacementimpl Into&lt;String&gt;

enable

rust
fn enable(&mut self) -> ()

Enable the rule.

disable

rust
fn disable(&mut self) -> ()

Disable the rule.

matches

rust
fn matches(&self, content: &str) -> bool

Check if content matches this rule.

Parameters:

NameType
content&str

apply

rust
fn apply(&self, content: &str) -> PolicyResult

Apply the rule to content.

Parameters:

NameType
content&str

Source

View on GitHub

praisonai/src/policy/mod.rs at line 118


Related Documentation