pub trait MultipartFormTrait: Sized {
fn limit(field_name: &str) -> Option<usize>;
fn handle_field<'t>(
req: &'t HttpRequest,
field: Field,
limits: &'t mut Limits,
state: &'t mut State
) -> LocalBoxFuture<'t, Result<(), Error>>;
fn from_state(state: State) -> Result<Self, Error>;
}
Expand description
Trait that allows a type to be used in the MultipartForm
extractor. You should use
the MultipartForm
to implement this for your struct.
Required Methods
sourcefn limit(field_name: &str) -> Option<usize>
fn limit(field_name: &str) -> Option<usize>
An optional limit in bytes to be applied a given field name. Note this limit will be shared across all fields sharing the same name.
sourcefn handle_field<'t>(
req: &'t HttpRequest,
field: Field,
limits: &'t mut Limits,
state: &'t mut State
) -> LocalBoxFuture<'t, Result<(), Error>>
fn handle_field<'t>(
req: &'t HttpRequest,
field: Field,
limits: &'t mut Limits,
state: &'t mut State
) -> LocalBoxFuture<'t, Result<(), Error>>
The extractor will call this function for each incoming field, the state can be updated with the processed field data.
sourcefn from_state(state: State) -> Result<Self, Error>
fn from_state(state: State) -> Result<Self, Error>
Once all the fields have been processed and stored in the state, this is called to convert into the struct representation.