pub struct Verdict<'a> {
pub text: Cow<'a, str>,
pub valid: bool,
pub risk: f32,
}Expand description
One scanner’s outcome. Mirrors LLM Guard’s (sanitized, valid, risk).
text is a Cow so a pure detector (the common case) returns the input
borrowed with zero allocation, while a transform returns the rewrite owned.
Fields§
§text: Cow<'a, str>Possibly-rewritten text. For a pure detector, borrows the input.
valid: boolfalse ⇒ the stack should reject (honoured for Block scanners).
risk: f320.0 safe … 1.0 high. Verdict::NOT_A_RISK (-1.0) means “not a
risk judgment” — a transformer that does not score.
Implementations§
Source§impl<'a> Verdict<'a>
impl<'a> Verdict<'a>
Sourcepub const NOT_A_RISK: f32 = -1.0
pub const NOT_A_RISK: f32 = -1.0
The sentinel risk a pure transformer returns: “not a risk judgment”, so stack-level risk aggregation can skip it honestly.
Sourcepub fn transformed(text: Cow<'a, str>) -> Self
pub fn transformed(text: Cow<'a, str>) -> Self
A transformer verdict: text rewritten (or borrowed unchanged), always
valid, Verdict::NOT_A_RISK.
Sourcepub fn is_risk_judgment(&self) -> bool
pub fn is_risk_judgment(&self) -> bool
Whether this verdict carries a risk judgment (a detector) rather than
being a pure transform (Verdict::NOT_A_RISK).
Trait Implementations§
Source§impl<'a> PartialEq for Verdict<'a>
impl<'a> PartialEq for Verdict<'a>
impl<'a> StructuralPartialEq for Verdict<'a>
Auto Trait Implementations§
impl<'a> Freeze for Verdict<'a>
impl<'a> RefUnwindSafe for Verdict<'a>
impl<'a> Send for Verdict<'a>
impl<'a> Sync for Verdict<'a>
impl<'a> Unpin for Verdict<'a>
impl<'a> UnsafeUnpin for Verdict<'a>
impl<'a> UnwindSafe for Verdict<'a>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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