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

NameTypeDescription
successboolWhether the guardrail check passed
resultOption<String>The result if modified, or original if unchanged
errorStringError message if validation failed
metadataHashMap<StringAdditional metadata

Methods

success

rust
fn success(result: impl Into<String>) -> Self

Create a successful result

Parameters:

NameType
resultimpl Into&lt;String&gt;

pass

rust
fn pass() -> Self

Create a successful result without modification

failure

rust
fn failure(error: impl Into<String>) -> Self

Create a failed result

Parameters:

NameType
errorimpl Into&lt;String&gt;

from_tuple

rust
fn from_tuple(success: bool, data: impl Into<String>) -> Self

Create from a tuple (success, result_or_error)

Parameters:

NameType
successbool
dataimpl Into&lt;String&gt;

with_metadata

rust
fn with_metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self

Add metadata

Parameters:

NameType
keyimpl Into&lt;String&gt;
valueimpl Into&lt;String&gt;

is_success

rust
fn is_success(&self) -> bool

Check if passed

is_failure

rust
fn is_failure(&self) -> bool

Check if failed

get_result_or

rust
fn get_result_or(&self, original: &str) -> String

Get the result or original content

Parameters:

NameType
original&str

Source

View on GitHub

praisonai/src/guardrails/mod.rs at line 38


Related Documentation