pub struct ScanResult {
pub sanitized_text: String,
pub is_valid: bool,
pub risk_score: f32,
pub entities: Vec<Entity>,
pub risk_factors: Vec<RiskFactor>,
pub metadata: HashMap<String, Value>,
}Expand description
Result of a security scan
§Enterprise Design
- Immutable: Once created, cannot be modified
- Serializable: Can be sent over network or stored
- Rich Metadata: Includes detailed information for debugging
- Composable: Multiple results can be combined
Fields§
§sanitized_text: StringThe sanitized/modified text (if applicable)
is_valid: boolWhether the input passed validation
risk_score: f32Risk score from 0.0 (no risk) to 1.0 (maximum risk)
entities: Vec<Entity>Detected entities (PII, secrets, banned content, etc.)
risk_factors: Vec<RiskFactor>Risk factors that contributed to the score
metadata: HashMap<String, Value>Additional scanner-specific metadata
Implementations§
Source§impl ScanResult
impl ScanResult
Sourcepub fn new(sanitized_text: String, is_valid: bool, risk_score: f32) -> Self
pub fn new(sanitized_text: String, is_valid: bool, risk_score: f32) -> Self
Create a new scan result
Sourcepub fn fail(text: String, risk_score: f32) -> Self
pub fn fail(text: String, risk_score: f32) -> Self
Create a failing scan result with risk score
Sourcepub fn with_entity(self, entity: Entity) -> Self
pub fn with_entity(self, entity: Entity) -> Self
Add an entity to the result
Sourcepub fn with_risk_factor(self, factor: RiskFactor) -> Self
pub fn with_risk_factor(self, factor: RiskFactor) -> Self
Add a risk factor to the result
Sourcepub fn with_metadata<K: Into<String>, V: Serialize>(
self,
key: K,
value: V,
) -> Self
pub fn with_metadata<K: Into<String>, V: Serialize>( self, key: K, value: V, ) -> Self
Add metadata to the result
Sourcepub fn combine(results: Vec<ScanResult>) -> Self
pub fn combine(results: Vec<ScanResult>) -> Self
Combine multiple scan results
Takes the maximum risk score and merges entities
Trait Implementations§
Source§impl Clone for ScanResult
impl Clone for ScanResult
Source§fn clone(&self) -> ScanResult
fn clone(&self) -> ScanResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScanResult
impl Debug for ScanResult
Source§impl<'de> Deserialize<'de> for ScanResult
impl<'de> Deserialize<'de> for ScanResult
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ScanResult
impl PartialEq for ScanResult
Source§impl Serialize for ScanResult
impl Serialize for ScanResult
impl StructuralPartialEq for ScanResult
Auto Trait Implementations§
impl Freeze for ScanResult
impl RefUnwindSafe for ScanResult
impl Send for ScanResult
impl Sync for ScanResult
impl Unpin for ScanResult
impl UnwindSafe for ScanResult
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