pub struct G;Expand description
The G namespace — static factory methods for guards.
Implementations§
Source§impl G
impl G
Sourcepub fn regex(pattern: &str) -> GGuard
pub fn regex(pattern: &str) -> GGuard
Regex guard — output must match (or not match) a pattern.
Sourcepub fn budget(max_tokens: usize) -> GGuard
pub fn budget(max_tokens: usize) -> GGuard
Budget guard — output must not exceed a token estimate.
Sourcepub fn topic(deny: &[&str]) -> GGuard
pub fn topic(deny: &[&str]) -> GGuard
Topic restriction guard — output must not mention denied topics.
Sourcepub fn custom(
f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static,
) -> GGuard
pub fn custom( f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static, ) -> GGuard
Custom guard from a validation function.
Sourcepub fn output(
f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static,
) -> GGuard
pub fn output( f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static, ) -> GGuard
Output guard — validates model output content via a predicate function.
Sourcepub fn input(
f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static,
) -> GGuard
pub fn input( f: impl Fn(&str) -> Result<(), String> + Send + Sync + 'static, ) -> GGuard
Input guard — validates user input content via a predicate function.
Sourcepub fn rate_limit(max_per_minute: u32) -> GGuard
pub fn rate_limit(max_per_minute: u32) -> GGuard
Rate limiting guard — enforces a maximum number of checks per minute.
Sourcepub fn toxicity() -> GGuard
pub fn toxicity() -> GGuard
Toxicity detection guard — placeholder for toxicity classification.
Sourcepub fn hallucination() -> GGuard
pub fn hallucination() -> GGuard
Hallucination detection guard — placeholder for hallucination detection.
Sourcepub fn when(
predicate: impl Fn(&str) -> bool + Send + Sync + 'static,
inner: GGuard,
) -> GGuard
pub fn when( predicate: impl Fn(&str) -> bool + Send + Sync + 'static, inner: GGuard, ) -> GGuard
Conditional guard — only applies inner when predicate returns true.
Auto Trait Implementations§
impl Freeze for G
impl RefUnwindSafe for G
impl Send for G
impl Sync for G
impl Unpin for G
impl UnwindSafe for G
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
Mutably borrows from an owned value. Read more