pub struct ValidationConfig {
pub max_file_size: Option<u64>,
pub min_file_size: Option<u64>,
pub allowed_mime_types: Option<HashSet<String>>,
pub blocked_mime_types: Option<HashSet<String>>,
pub allowed_extensions: Option<HashSet<String>>,
pub blocked_extensions: Option<HashSet<String>>,
pub validate_content: bool,
pub max_filename_length: Option<usize>,
pub allow_unicode_filenames: bool,
}Expand description
File validation configuration
Fields§
§max_file_size: Option<u64>Maximum file size in bytes
min_file_size: Option<u64>Minimum file size in bytes
allowed_mime_types: Option<HashSet<String>>Allowed MIME types (prefixes)
blocked_mime_types: Option<HashSet<String>>Blocked MIME types (prefixes)
allowed_extensions: Option<HashSet<String>>Allowed file extensions
blocked_extensions: Option<HashSet<String>>Blocked file extensions
validate_content: boolEnable content validation (magic number checking)
max_filename_length: Option<usize>Maximum filename length
allow_unicode_filenames: boolAllow unicode characters in filenames
Implementations§
Source§impl ValidationConfig
impl ValidationConfig
Sourcepub fn unlimited_size(self) -> Self
pub fn unlimited_size(self) -> Self
Remove maximum file size limit
Sourcepub fn allow_mime_types<I>(self, types: I) -> Selfwhere
I: IntoIterator<Item = String>,
pub fn allow_mime_types<I>(self, types: I) -> Selfwhere
I: IntoIterator<Item = String>,
Allow specific MIME types only
Sourcepub fn block_mime_types<I>(self, types: I) -> Selfwhere
I: IntoIterator<Item = String>,
pub fn block_mime_types<I>(self, types: I) -> Selfwhere
I: IntoIterator<Item = String>,
Block specific MIME types
Sourcepub fn allow_extensions<I>(self, extensions: I) -> Selfwhere
I: IntoIterator<Item = String>,
pub fn allow_extensions<I>(self, extensions: I) -> Selfwhere
I: IntoIterator<Item = String>,
Allow specific file extensions only
Sourcepub fn block_extensions<I>(self, extensions: I) -> Selfwhere
I: IntoIterator<Item = String>,
pub fn block_extensions<I>(self, extensions: I) -> Selfwhere
I: IntoIterator<Item = String>,
Block specific file extensions
Sourcepub fn validate_content(self) -> Self
pub fn validate_content(self) -> Self
Enable content validation
Sourcepub fn skip_content_validation(self) -> Self
pub fn skip_content_validation(self) -> Self
Disable content validation
Sourcepub fn max_filename_length(self, length: usize) -> Self
pub fn max_filename_length(self, length: usize) -> Self
Set maximum filename length
Sourcepub fn allow_unicode_filenames(self) -> Self
pub fn allow_unicode_filenames(self) -> Self
Allow unicode characters in filenames
Sourcepub fn ascii_filenames_only(self) -> Self
pub fn ascii_filenames_only(self) -> Self
Disallow unicode characters in filenames
Trait Implementations§
Source§impl Clone for ValidationConfig
impl Clone for ValidationConfig
Source§fn clone(&self) -> ValidationConfig
fn clone(&self) -> ValidationConfig
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 ValidationConfig
impl Debug for ValidationConfig
Auto Trait Implementations§
impl Freeze for ValidationConfig
impl RefUnwindSafe for ValidationConfig
impl Send for ValidationConfig
impl Sync for ValidationConfig
impl Unpin for ValidationConfig
impl UnwindSafe for ValidationConfig
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