[][src]Enum form_data::Field

pub enum Field {
    Array(Array),
    File(Arc<dyn FilenameGenerator>),
    Map(Map),
    Int,
    Float,
    Text,
    Bytes,
}

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

Variants

Array(Array)File(Arc<dyn FilenameGenerator>)Map(Map)IntFloatTextBytes

Methods

impl Field
[src]

pub fn file<T>(gen: T) -> Self where
    T: FilenameGenerator + '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


struct Gen;

impl FilenameGenerator for Gen {
    fn next_filename(&self, _: &mime::Mime) -> Option<PathBuf> {
        Some(AsRef::<Path>::as_ref("path.png").to_owned())
    }
}

fn main() {
    let name_generator = Gen;
    let form = Form::new()
        .field("file-field", Field::file(name_generator));
}

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

Add a Bytes field to a form

Example

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

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]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Field
[src]

Auto Trait Implementations

impl Send for Field

impl Sync for Field

Blanket Implementations

impl<T> From for T
[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Erased for T