Enum actix_form_data::Field[][src]

pub enum Field {
    Array(Array),
    Map(Map),
    File(Arc<dyn Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, Error>>>> + Send + Sync>),
    Bytes,
    Int,
    Float,
    Text,
}

The field type represents a field in the form-data that is allowed to be parsed.

Variants

Array(Array)
Map(Map)
File(Arc<dyn Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Pin<Box<dyn Future<Output = Result<Option<PathBuf>, Error>>>> + Send + Sync>)
Bytes
Int
Float
Text

Implementations

impl Field[src]

pub fn file<F, Fut, E>(f: F) -> Self where
    F: Fn(String, Mime, Pin<Box<dyn Stream<Item = Result<Bytes, Error>>>>) -> Fut + Send + Sync + Clone + 'static,
    Fut: Future<Output = Result<Option<PathBuf>, E>> + 'static,
    E: Into<Error> + 'static, 
[src]

Add a File field with a name generator.

The name generator will be called for each file matching this field’s key. Keep in mind that each key/file pair will have it’s own name-generator, so sharing a name-generator between fields is up to the user.

Example

let (tx, rx) = channel(1);
let form = Form::new().field("file-field", Field::file(move |_, _, mut stream| {
    let mut tx = tx.clone();
    async move {
        while let Some(res) = stream.next().await {
            if let Ok(bytes) = res {
                if let Err(_) = tx.send(bytes).await {
                    break;
                }
            }
        }
        Ok(None) as Result<_, std::convert::Infallible>
    }
}));

pub fn bytes() -> Self[src]

Add a Bytes field to a form

Example

let form = Form::new().field("text-field", Field::bytes());

pub fn text() -> Self[src]

Add a Text field to a form

Example

let form = Form::new().field("text-field", Field::text());

pub fn int() -> Self[src]

Add an Int field to a form

Example

let form = Form::new().field("int-field", Field::int());

pub fn float() -> Self[src]

Add a Float field to a form

Example

let form = Form::new().field("float-field", Field::float());

pub fn array(field: Field) -> Self[src]

Add an Array to a form

Example

let form = Form::new()
    .field(
        "array-field",
        Field::array(Field::text())
    );

pub fn map() -> Map[src]

Add a Map to a form

Example

let form = Form::new()
    .field(
        "map-field",
        Field::map()
            .field("sub-field", Field::text())
            .field("sub-field-two", Field::text())
            .finalize()
    );

Trait Implementations

impl Clone for Field[src]

impl Debug for Field[src]

Auto Trait Implementations

impl !RefUnwindSafe for Field

impl Send for Field

impl Sync for Field

impl Unpin for Field

impl !UnwindSafe for Field

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>,