pub struct CompiledGuardrails { /* private fields */ }Expand description
Validated, pre-compiled guardrails ready for evaluation.
Implementations§
Source§impl CompiledGuardrails
impl CompiledGuardrails
pub fn mode(&self) -> GuardrailMode
Sourcepub fn has_stage(&self, stage: GuardrailStage) -> bool
pub fn has_stage(&self, stage: GuardrailStage) -> bool
Whether any check (deterministic, llm_judge, mcp, or moderation)
applies to stage.
Sourcepub fn moderation_checks_for_stage(
&self,
stage: GuardrailStage,
) -> impl Iterator<Item = &CompiledModerationCheck>
pub fn moderation_checks_for_stage( &self, stage: GuardrailStage, ) -> impl Iterator<Item = &CompiledModerationCheck>
Moderation checks that target stage. Empty when no moderation rule
targets stage. Callers run these asynchronously via the utility LLM
on the end-of-message output seam.
Sourcepub fn judge_checks_for_stage(
&self,
stage: GuardrailStage,
) -> impl Iterator<Item = &CompiledJudgeCheck>
pub fn judge_checks_for_stage( &self, stage: GuardrailStage, ) -> impl Iterator<Item = &CompiledJudgeCheck>
LLM-judge checks that target stage. Empty when no llm_judge rule
targets stage. Callers run these asynchronously via the utility LLM.
Sourcepub fn mcp_checks_for_stage(
&self,
stage: GuardrailStage,
) -> impl Iterator<Item = &CompiledMcpCheck>
pub fn mcp_checks_for_stage( &self, stage: GuardrailStage, ) -> impl Iterator<Item = &CompiledMcpCheck>
MCP-served checks that target stage. Empty when no mcp rule targets
stage. Callers run these asynchronously via the scoped-MCP client.
Sourcepub fn async_action(&self, on_fail: GuardrailOnFail) -> GuardrailAction
pub fn async_action(&self, on_fail: GuardrailOnFail) -> GuardrailAction
Effective action for an async check hit (llm_judge / mcp), applying advisory mode.
Sourcepub fn judge_action(&self, on_fail: GuardrailOnFail) -> GuardrailAction
pub fn judge_action(&self, on_fail: GuardrailOnFail) -> GuardrailAction
Effective action for a judge check hit, applying advisory mode.
Retained as a name-stable alias of Self::async_action.
Sourcepub fn evaluate(
&self,
stage: GuardrailStage,
text: &str,
tool_name: Option<&str>,
skip: &dyn Fn(usize) -> bool,
) -> Vec<GuardrailHit>
pub fn evaluate( &self, stage: GuardrailStage, text: &str, tool_name: Option<&str>, skip: &dyn Fn(usize) -> bool, ) -> Vec<GuardrailHit>
Evaluate all checks for stage against text. For the tool_use
stage, tool_name feeds tool_pattern rules and text is the
serialized tool arguments; other stages ignore tool_name.
skip suppresses checks by index (used by the streaming run to
avoid re-reporting an already-logged advisory hit on every delta).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompiledGuardrails
impl RefUnwindSafe for CompiledGuardrails
impl Send for CompiledGuardrails
impl Sync for CompiledGuardrails
impl Unpin for CompiledGuardrails
impl UnsafeUnpin for CompiledGuardrails
impl UnwindSafe for CompiledGuardrails
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request