Skip to main content

UploadBody

Struct UploadBody 

Source
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

Source

pub fn new(stream: StreamingBody) -> Self

Source

pub fn with_content_type(self, content_type: impl Into<String>) -> Self

Records the request’s declared media type.

Source

pub fn content_type(&self) -> Option<&str>

The request’s declared media type, when it had one.

Source

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.

Source

pub const fn exact_length(&self) -> Option<u64>

Source

pub const fn bytes_read(&self) -> u64

Source

pub async fn next_chunk(&mut self) -> Option<Result<Vec<u8>, BodyStreamError>>

Pulls the next upload chunk.

Source

pub async fn collect(self, limit: usize) -> Result<Vec<u8>, BodyStreamError>

Deliberately buffers the remaining upload with an explicit limit.

§Errors

Returns a producer error or upload_collect_limit_exceeded.

Trait Implementations§

Source§

impl ApiSchema for UploadBody

Source§

fn type_descriptor() -> TypeDescriptor

Source§

fn validate_input(&self) -> Result<(), ValidationErrors>

Validates a decoded operation argument. Read more
Source§

impl Debug for UploadBody

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromInvocation for UploadBody

Source§

fn from_invocation( input: &InvocationInput<'_>, _name: &str, _required: bool, ) -> Result<Self, InputRejection>

Extracts one handler argument. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> BackgroundExt for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ResponseExt for T

Source§

fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> WithHeaders<Self>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.