pub struct AiGuardrailRule {
pub name: String,
pub kind: AiGuardrailKind,
pub action: AiGuardrailAction,
pub phase: AiGuardrailPhase,
pub patterns: Vec<String>,
pub schema: Option<Value>,
pub policies: Vec<String>,
}Expand description
One guardrail rule (DW-082 ai.guardrails.rules[]). A rule
declares a kind (what to check), an action (what to do on a
match), a phase (prompt, response, or both), the patterns or
schema to check against, and the policies it attaches to.
Fields§
§name: StringRule name (for logging/metrics attribution). Must be unique within the guardrails block (validation rejects duplicates).
kind: AiGuardrailKindGuardrail kind: what the rule checks.
action: AiGuardrailActionAction on match: block (return an error to the client),
redact (scrub the match and continue — prompt phase only),
or log (observe only, dry-run — the request proceeds).
phase: AiGuardrailPhaseWhen to apply: prompt (before the provider call), response
(after), or both. Default both.
patterns: Vec<String>Patterns for injection/pii/banned kinds (regex strings). Each
is a Rust regex crate pattern; invalid patterns fail
validation at publish time. For pii kind, the built-in PII
patterns (email, phone, API key, credit card) are always
active alongside any custom patterns declared here.
schema: Option<Value>JSON schema for output schema enforcement (schema kind
only). The response content (parsed as JSON) is validated
against this schema; a violation blocks the response. Uses the
unconditional jsonschema dependency; works in every build.
policies: Vec<String>Policy names this rule attaches to. Empty (the default) means the rule applies to ALL consumers. When non-empty, the rule applies only to consumers whose attached policies (the consumer > route > service > listener > global chain) include at least one listed name.
Trait Implementations§
Source§impl Clone for AiGuardrailRule
impl Clone for AiGuardrailRule
Source§fn clone(&self) -> AiGuardrailRule
fn clone(&self) -> AiGuardrailRule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AiGuardrailRule
impl Debug for AiGuardrailRule
Source§impl<'de> Deserialize<'de> for AiGuardrailRule
impl<'de> Deserialize<'de> for AiGuardrailRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for AiGuardrailRule
impl JsonSchema for AiGuardrailRule
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for AiGuardrailRule
impl PartialEq for AiGuardrailRule
Source§impl Serialize for AiGuardrailRule
impl Serialize for AiGuardrailRule
impl StructuralPartialEq for AiGuardrailRule
Auto Trait Implementations§
impl Freeze for AiGuardrailRule
impl RefUnwindSafe for AiGuardrailRule
impl Send for AiGuardrailRule
impl Sync for AiGuardrailRule
impl Unpin for AiGuardrailRule
impl UnwindSafe for AiGuardrailRule
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more