[]Struct paperclip::actix::web::Form

pub struct Form<T>(pub T);

Form data helper (application/x-www-form-urlencoded)

Can be use to extract url-encoded data from the request body, or send url-encoded data as the response.

Extract

To extract typed information from request's body, the type T must implement the Deserialize trait from serde.

FormConfig allows to configure extraction process.

Example

use actix_web::web;
use serde_derive::Deserialize;

#[derive(Deserialize)]
struct FormData {
    username: String,
}

/// Extract form data using serde.
/// This handler get called only if content type is *x-www-form-urlencoded*
/// and content of the request could be deserialized to a `FormData` struct
fn index(form: web::Form<FormData>) -> String {
    format!("Welcome {}!", form.username)
}

Respond

The Form type also allows you to respond with well-formed url-encoded data: simply return a value of type Form where T is the type to be url-encoded. The type must implement serde::Serialize;

Example

use actix_web::*;
use serde_derive::Serialize;

#[derive(Serialize)]
struct SomeForm {
    name: String,
    age: u8
}

// Will return a 200 response with header
// `Content-Type: application/x-www-form-urlencoded`
// and body "name=actix&age=123"
fn index() -> web::Form<SomeForm> {
    web::Form(SomeForm {
        name: "actix".into(),
        age: 123
    })
}

Methods

impl<T> Form<T>

pub fn into_inner(self) -> T

Deconstruct to an inner value

Trait Implementations

impl<T> Apiv2Schema for Form<T> where
    T: Apiv2Schema
[src]

impl<T> Debug for Form<T> where
    T: Debug

impl<T> Deref for Form<T>

type Target = T

The resulting type after dereferencing.

impl<T> DerefMut for Form<T>

impl<T> Display for Form<T> where
    T: Display

impl<T> Eq for Form<T> where
    T: Eq

impl<T> FromRequest for Form<T> where
    T: DeserializeOwned + 'static, 

type Config = FormConfig

Configuration for this extractor

type Error = Error

The associated error which can be returned.

type Future = Pin<Box<dyn Future<Output = Result<Form<T>, Error>> + 'static>>

Future that resolves to a Self

impl<T> OperationModifier for Form<T> where
    T: Apiv2Schema
[src]

impl<T> Ord for Form<T> where
    T: Ord

impl<T> PartialEq<Form<T>> for Form<T> where
    T: PartialEq<T>, 

impl<T> PartialOrd<Form<T>> for Form<T> where
    T: PartialOrd<T>, 

impl<T> Responder for Form<T> where
    T: Serialize

type Error = Error

The associated error which can be returned.

type Future = Ready<Result<Response<Body>, Error>>

The future response value.

impl<T> StructuralEq for Form<T>

impl<T> StructuralPartialEq for Form<T>

Auto Trait Implementations

impl<T> RefUnwindSafe for Form<T> where
    T: RefUnwindSafe

impl<T> Send for Form<T> where
    T: Send

impl<T> Sync for Form<T> where
    T: Sync

impl<T> Unpin for Form<T> where
    T: Unpin

impl<T> UnwindSafe for Form<T> where
    T: UnwindSafe

Blanket Implementations

impl<T, A, P> Access<T> for P where
    A: Access<T>,
    P: Deref<Target = A>, 
[src]

type Guard = <A as Access<T>>::Guard

A guard object containing the value and keeping it alive. Read more

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

impl<T> Apiv2Schema for T where
    T: TypedData
[src]

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

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

impl<T, A> DynAccess<T> for A where
    A: Access<T>,
    <A as Access<T>>::Guard: 'static, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

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