pub struct Form<T, E> { /* private fields */ }
Expand description
A structure that defines the fields expected in form data
§Example
let form = Form::<(), Error>::new()
.field("field-name", Field::text())
.field("second-field", Field::int())
.field("third-field", Field::float())
.field("fifth-field", Field::file(|_, _, _| async move {
Ok(())
}))
.field(
"map-field",
Field::map()
.field("sub-field", Field::text())
.field("sub-field-two", Field::text())
.finalize()
)
.field(
"array-field",
Field::array(Field::text())
);
Implementations§
Source§impl<T, E> Form<T, E>
impl<T, E> Form<T, E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new form
If you wish to provide your own executor, use the with_executor
method.
Default values are as follows
- max_fields: 100
- max_field_size: 10_000 bytes
- max_files: 20
- max_files_size: 10_000_000 bytes
Sourcepub fn transform_error(
self,
f: impl Fn(Error) -> Error + Send + Sync + 'static,
) -> Self
pub fn transform_error( self, f: impl Fn(Error) -> Error + Send + Sync + 'static, ) -> Self
Set the Transform Error method to convert Error types into actix_web::Error by hand
Sourcepub fn max_fields(self, max: u32) -> Self
pub fn max_fields(self, max: u32) -> Self
Set the maximum number of fields allowed in the upload
The upload will error if too many fields are provided.
Sourcepub fn max_field_size(self, max: usize) -> Self
pub fn max_field_size(self, max: usize) -> Self
Set the maximum size of a field (in bytes)
The upload will error if a provided field is too large.
Sourcepub fn max_files(self, max: u32) -> Self
pub fn max_files(self, max: u32) -> Self
Set the maximum number of files allowed in the upload
THe upload will error if too many files are provided.
Sourcepub fn max_file_size(self, max: usize) -> Self
pub fn max_file_size(self, max: usize) -> Self
Set the maximum size for files (in bytes)
The upload will error if a provided file is too large.
pub fn field(self, name: &str, field: Field<T, E>) -> Self
Trait Implementations§
Source§impl<S, T, E> Transform<S, ServiceRequest> for Form<T, E>where
S: Service<ServiceRequest, Error = Error>,
S::Future: 'static,
T: 'static,
E: ResponseError + 'static,
impl<S, T, E> Transform<S, ServiceRequest> for Form<T, E>where
S: Service<ServiceRequest, Error = Error>,
S::Future: 'static,
T: 'static,
E: ResponseError + 'static,
Source§type Transform = MultipartMiddleware<S, T, E>
type Transform = MultipartMiddleware<S, T, E>
The
TransformService
value created by this factorySource§type Future = Ready<Result<<Form<T, E> as Transform<S, ServiceRequest>>::Transform, <Form<T, E> as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<Form<T, E> as Transform<S, ServiceRequest>>::Transform, <Form<T, E> as Transform<S, ServiceRequest>>::InitError>>
The future response value.
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations§
impl<T, E> Freeze for Form<T, E>
impl<T, E> !RefUnwindSafe for Form<T, E>
impl<T, E> Send for Form<T, E>
impl<T, E> Sync for Form<T, E>
impl<T, E> Unpin for Form<T, E>
impl<T, E> !UnwindSafe for Form<T, E>
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