Guardrail Result • Rust AI Agent SDK
GuardrailResult: Result of a guardrail validation.
GuardrailResult
Defined in the guardrails module.
Rust AI Agent SDK
Result of a guardrail validation.
Fields
| Name | Type | Description |
|---|---|---|
success | bool | Whether the guardrail check passed |
result | Option<String> | The result if modified, or original if unchanged |
error | String | Error message if validation failed |
metadata | HashMap<String | Additional metadata |
Methods
success
fn success(result: impl Into<String>) -> SelfCreate a successful result
Parameters:
| Name | Type |
|---|---|
result | impl Into<String> |
pass
fn pass() -> SelfCreate a successful result without modification
failure
fn failure(error: impl Into<String>) -> SelfCreate a failed result
Parameters:
| Name | Type |
|---|---|
error | impl Into<String> |
from_tuple
fn from_tuple(success: bool, data: impl Into<String>) -> SelfCreate from a tuple (success, result_or_error)
Parameters:
| Name | Type |
|---|---|
success | bool |
data | impl Into<String> |
with_metadata
fn with_metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> SelfAdd metadata
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
value | impl Into<String> |
is_success
fn is_success(&self) -> boolCheck if passed
is_failure
fn is_failure(&self) -> boolCheck if failed
get_result_or
fn get_result_or(&self, original: &str) -> StringGet the result or original content
Parameters:
| Name | Type |
|---|---|
original | &str |
Source
View on GitHubpraisonai/src/guardrails/mod.rs at line 38