Struct actix_form_data::Form
source · [−]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
sourceimpl<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
sourceimpl<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,
type Response = S::Response
type Response = S::Response
Responses produced by the service.
type Error = S::Error
type Error = S::Error
Errors produced by the service.
type Transform = MultipartMiddleware<S, T, E>
type Transform = MultipartMiddleware<S, T, E>
The TransformService
value created by this factory
sourcefn 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> !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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more