#[non_exhaustive]pub struct Policy {
pub percent: PercentPolicy,
pub extended_filename: ExtendedFilenamePolicy,
pub unknown_headers: HeaderPolicy,
pub empty_files: EmptyFilePolicy,
pub token_field: Option<TokenField>,
}Expand description
The behaviours a route may choose. The defaults are the strict ones; every alternative is named after what it allows.
§Examples
use form_net::{EmptyFilePolicy, HeaderPolicy, Policy, TokenField};
const UPLOADS: Policy = Policy::DEFAULT
.with_token_field(TokenField::new("csrf_token"))
.with_empty_files(EmptyFilePolicy::Skip)
.with_unknown_headers(HeaderPolicy::Refuse);
assert_eq!(UPLOADS.token_field.map(|t| t.name()), Some("csrf_token"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.percent: PercentPolicyA malformed % in urlencoded input. Default Refuse.
extended_filename: ExtendedFilenamePolicyfilename* in a part. Default Refuse.
unknown_headers: HeaderPolicyPart headers other than the three known ones. Default Ignore.
empty_files: EmptyFilePolicyA file input left empty. Default Report.
token_field: Option<TokenField>The anti-forgery token field to capture. Default none.
Implementations§
Source§impl Policy
impl Policy
Sourcepub const fn with_percent(self, policy: PercentPolicy) -> Self
pub const fn with_percent(self, policy: PercentPolicy) -> Self
Sets percent.
Sourcepub const fn with_extended_filename(
self,
policy: ExtendedFilenamePolicy,
) -> Self
pub const fn with_extended_filename( self, policy: ExtendedFilenamePolicy, ) -> Self
Sets extended_filename.
Sourcepub const fn with_unknown_headers(self, policy: HeaderPolicy) -> Self
pub const fn with_unknown_headers(self, policy: HeaderPolicy) -> Self
Sets unknown_headers.
Sourcepub const fn with_empty_files(self, policy: EmptyFilePolicy) -> Self
pub const fn with_empty_files(self, policy: EmptyFilePolicy) -> Self
Sets empty_files.
Sourcepub const fn with_token_field(self, field: TokenField) -> Self
pub const fn with_token_field(self, field: TokenField) -> Self
Sets the token field to capture.
Trait Implementations§
impl Copy for Policy
impl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
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