pub struct DataField<'r, 'i> {
pub name: NameView<'r>,
pub file_name: Option<&'r FileName>,
pub content_type: ContentType,
pub request: &'r Request<'i>,
pub data: Data<'r>,
}
Expand description
A multipart form field with an underlying data stream.
Rocket preprocesses all form fields into either ValueField
s or
DataField
s. Multipart form fields with a Content-Type
are preprocessed
as a DataField
. The underlying data is not read into memory, but
instead, streamable from the contained Data
structure.
Fields§
§name: NameView<'r>
The (decoded) name of the form field.
file_name: Option<&'r FileName>
The form fields’s file name.
content_type: ContentType
The form field’s Content-Type, as submitted, which may or may not
reflect on data
.
request: &'r Request<'i>
The request in which the form field was submitted.
data: Data<'r>
The raw data stream.
Implementations§
source§impl<'v> DataField<'v, '_>
impl<'v> DataField<'v, '_>
sourcepub fn shift(self) -> Self
pub fn shift(self) -> Self
Shift the name
of self
and return self
with the shifted name
.
This is identical to ValueField::shift()
but for DataField
s. See
NameView::shift()
for the details on name “shifting”.
Example
use rocket::form::DataField;
fn push_data(field: DataField<'_, '_>) {
let shifted = field.shift();
}
sourcepub fn unexpected(&self) -> Error<'v>
pub fn unexpected(&self) -> Error<'v>
Creates a complete unexpected data field Error
from self
.
The error will have the following properties:
kind
:ErrorKind::Unexpected
name
:self.name.source()
value
:None
entity
:Entity::DataField
Example
use rocket::form::DataField;
fn push_data(field: DataField<'_, '_>) {
let error = field.unexpected();
}