pub struct SafetyLayer { /* private fields */ }Expand description
Unified security defense layer
Implementations§
Source§impl SafetyLayer
impl SafetyLayer
Sourcepub fn new(config: SafetyConfig) -> Self
pub fn new(config: SafetyConfig) -> Self
Create a new safety layer with configuration
Sourcepub fn validate_message(&self, content: &str) -> Result<DefenseResult>
pub fn validate_message(&self, content: &str) -> Result<DefenseResult>
Validate a user message (checks input, prompt injection, and leaks)
Sourcepub fn validate_url(&self, url: &str) -> Result<DefenseResult>
pub fn validate_url(&self, url: &str) -> Result<DefenseResult>
Validate a URL (checks SSRF)
Sourcepub fn validate_http_request(
&self,
url: &str,
headers: &[(String, String)],
body: Option<&[u8]>,
) -> Result<DefenseResult>
pub fn validate_http_request( &self, url: &str, headers: &[(String, String)], body: Option<&[u8]>, ) -> Result<DefenseResult>
Validate an HTTP request (checks for credential exfiltration)
This should be called before executing any outbound HTTP request.
Sourcepub fn validate_output(&self, content: &str) -> Result<DefenseResult>
pub fn validate_output(&self, content: &str) -> Result<DefenseResult>
Validate output content (checks for credential leaks)
Sourcepub fn check_all(&self, content: &str) -> Vec<DefenseResult>
pub fn check_all(&self, content: &str) -> Vec<DefenseResult>
Run all security checks on content
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SafetyLayer
impl RefUnwindSafe for SafetyLayer
impl Send for SafetyLayer
impl Sync for SafetyLayer
impl Unpin for SafetyLayer
impl UnsafeUnpin for SafetyLayer
impl UnwindSafe for SafetyLayer
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