logo
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 ValueFields or DataFields. 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

Shift the name of self and return self with the shifted name.

This is identical to ValueField::shift() but for DataFields. See NameView::shift() for the details on name “shifting”.

Example
use rocket::form::DataField;

fn push_data(field: DataField<'_, '_>) {
    let shifted = field.shift();
}

Creates a complete unexpected data field Error from self.

The error will have the following properties:

Example
use rocket::form::DataField;

fn push_data(field: DataField<'_, '_>) {
    let error = field.unexpected();
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts self into a collection.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more