pub struct UploadBody { /* private fields */ }Expand description
Pull-based request body with adapter-enforced transport limits.
Each next_chunk call is the backpressure boundary. The native adapter
does not read and queue another network chunk until the handler pulls.
Implementations§
Source§impl UploadBody
impl UploadBody
pub fn new(stream: StreamingBody) -> Self
Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Records the request’s declared media type.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
The request’s declared media type, when it had one.
Sourcepub fn into_multipart(self) -> Result<MultipartStream, MultipartError>
pub fn into_multipart(self) -> Result<MultipartStream, MultipartError>
Reads this body as a multipart/form-data document.
The document is parsed while it arrives, so a handler that consumes each
part chunk by chunk never has the upload resident. This is the streaming
counterpart of the buffered Multipart<T> and File<UploadFile>
extractors, which materialize every part before the handler starts.
§Errors
Returns MultipartError::Malformed when the request did not declare
multipart/form-data with a usable boundary.
pub const fn exact_length(&self) -> Option<u64>
pub const fn bytes_read(&self) -> u64
Sourcepub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>
pub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>
Pulls the next upload chunk.