Enum form_data::Field
[−]
[src]
pub enum Field { Array(Array), File(Arc<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<FilenameGenerator>)
Map(Map)
Int
Float
Text
Bytes
Methods
impl Field
[src]
pub fn file<T>(gen: T) -> Self where
T: FilenameGenerator + 'static,
[src]
T: FilenameGenerator + 'static,
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]
pub fn int() -> Self
[src]
pub fn float() -> Self
[src]
pub fn bytes() -> Self
[src]
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(&self) -> Field
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more