Struct actix_form_data::Form[][src]

pub struct Form { /* fields omitted */ }

A structure that defines the fields expected in form data

Example

let form = Form::new()
    .field("field-name", Field::text())
    .field("second-field", Field::int())
    .field("third-field", Field::float())
    .field("fifth-field", Field::file(|_, _, _| async move {
        Ok(None) as Result<_, std::convert::Infallible>
    }))
    .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

impl Form[src]

pub fn new() -> Self[src]

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

pub fn transform_error(
    self,
    f: impl Fn(Error) -> Error + Send + Sync + 'static
) -> Self
[src]

Add an optional error handler to transform errors produced by the middleware

pub fn max_fields(self, max: u32) -> Self[src]

Set the maximum number of fields allowed in the upload

The upload will error if too many fields are provided.

pub fn max_field_size(self, max: usize) -> Self[src]

Set the maximum size of a field (in bytes)

The upload will error if a provided field is too large.

pub fn max_files(self, max: u32) -> Self[src]

Set the maximum number of files allowed in the upload

THe upload will error if too many files are provided.

pub fn max_file_size(self, max: usize) -> Self[src]

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) -> Self[src]

Trait Implementations

impl Clone for Form[src]

impl Debug for Form[src]

impl<S> Transform<S, ServiceRequest> for Form where
    S: Service<ServiceRequest, Error = Error>,
    S::Future: 'static, 
[src]

type Response = S::Response

Responses produced by the service.

type Error = S::Error

Errors produced by the service.

type InitError = ()

Errors produced while building a transform service.

type Transform = MultipartMiddleware<S>

The TransformService value created by this factory

type Future = Ready<Result<Self::Transform, Self::InitError>>

The future response value.

Auto Trait Implementations

impl !RefUnwindSafe for Form

impl Send for Form

impl Sync for Form

impl Unpin for Form

impl !UnwindSafe for Form

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,