pub struct SecurityPolicy {
pub content_types: ContentTypeWhitelist,
pub max_message_size: usize,
pub max_task_name_length: usize,
pub task_name_pattern: Option<String>,
pub strict_validation: bool,
}Expand description
Security policy for message handling
Fields§
§content_types: ContentTypeWhitelistContent type whitelist
max_message_size: usizeMaximum message size in bytes
max_task_name_length: usizeMaximum task name length
task_name_pattern: Option<String>Allowed task name pattern (regex-like)
strict_validation: boolEnable strict validation
Implementations§
Source§impl SecurityPolicy
impl SecurityPolicy
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive security policy
Sourcepub fn is_content_type_allowed(&self, content_type: &str) -> bool
pub fn is_content_type_allowed(&self, content_type: &str) -> bool
Check if a content type is allowed
Sourcepub fn validate_content_type(
&self,
content_type: &str,
) -> Result<(), SecurityError>
pub fn validate_content_type( &self, content_type: &str, ) -> Result<(), SecurityError>
Validate content type
Sourcepub fn validate_message_size(&self, size: usize) -> Result<(), SecurityError>
pub fn validate_message_size(&self, size: usize) -> Result<(), SecurityError>
Validate message size
Sourcepub fn validate_task_name(&self, name: &str) -> Result<(), SecurityError>
pub fn validate_task_name(&self, name: &str) -> Result<(), SecurityError>
Validate task name
Sourcepub fn validate_message(
&self,
content_type: &str,
body_size: usize,
task_name: &str,
) -> Result<(), SecurityError>
pub fn validate_message( &self, content_type: &str, body_size: usize, task_name: &str, ) -> Result<(), SecurityError>
Validate a complete message
Sourcepub fn with_max_message_size(self, size: usize) -> Self
pub fn with_max_message_size(self, size: usize) -> Self
Set maximum message size
Sourcepub fn with_max_task_name_length(self, length: usize) -> Self
pub fn with_max_task_name_length(self, length: usize) -> Self
Set maximum task name length
Sourcepub fn with_strict_validation(self, strict: bool) -> Self
pub fn with_strict_validation(self, strict: bool) -> Self
Enable strict validation
Sourcepub fn with_content_types(self, whitelist: ContentTypeWhitelist) -> Self
pub fn with_content_types(self, whitelist: ContentTypeWhitelist) -> Self
Set content type whitelist
Trait Implementations§
Source§impl Clone for SecurityPolicy
impl Clone for SecurityPolicy
Source§fn clone(&self) -> SecurityPolicy
fn clone(&self) -> SecurityPolicy
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 SecurityPolicy
impl Debug for SecurityPolicy
Auto Trait Implementations§
impl Freeze for SecurityPolicy
impl RefUnwindSafe for SecurityPolicy
impl Send for SecurityPolicy
impl Sync for SecurityPolicy
impl Unpin for SecurityPolicy
impl UnwindSafe for SecurityPolicy
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