pub struct MultipartField<S, E>where
S: Stream<Item = Result<Bytes, E>> + Unpin,
E: Into<Box<dyn StdError + Send + Sync + 'static>>,{ /* private fields */ }
Expand description
A single field of a MultipartStream
which itself is a stream
This represents either an uploaded file, or a simple text value
Each field will have some headers and then a body.
There are no assumptions made when parsing about what headers are present, but some of the helper methods here (such as content_type()
& filename()
) will return an error if they aren’t present.
The body will be returned as an inner stream of bytes from the request, but up to the end of the field.
Fields are not concurrent against their parent multipart request. This is because multipart submissions are a single http request and we don’t support going backwards or skipping bytes. In other words you can’t read from multiple fields from the same request at the same time: you must wait for one field to finish being read before moving on.
Implementations§
Source§impl<S, E> MultipartField<S, E>
impl<S, E> MultipartField<S, E>
Sourcepub fn headers(&self) -> &HeaderMap<HeaderValue>
pub fn headers(&self) -> &HeaderMap<HeaderValue>
Return the headers for the field
You can use self.headers.get("my-header").and_then(|val| val.to_str().ok())
to get out the header if present
Sourcepub fn content_type(&self) -> Result<&str, MultipartError>
pub fn content_type(&self) -> Result<&str, MultipartError>
Return the content type of the field (if present or error)