pub struct Payload<S, E>{
pub expected_size: u64,
pub stream: S,
}Expand description
A bundle that ties together a raw byte stream and its declared size.
This newtype exists to avoid “primitive obsession” — passing expected_size
and stream as separate parameters to multiple layers of functions is error-prone.
Bundling them enforces that the two always travel together.
The expected_size is used to pre-allocate disk space via fallocate before
streaming begins, which improves performance on spinning drives and SD cards by
preventing filesystem fragmentation.
Fields§
§expected_size: u64The total number of bytes the client claims it will send. This is trusted for pre-allocation but validated at EOF.
stream: SThe raw async stream of byte chunks from the request body.
Implementations§
Auto Trait Implementations§
impl<S, E> Freeze for Payload<S, E>where
S: Freeze,
impl<S, E> RefUnwindSafe for Payload<S, E>where
S: RefUnwindSafe,
impl<S, E> Send for Payload<S, E>where
S: Send,
impl<S, E> Sync for Payload<S, E>where
S: Sync,
impl<S, E> Unpin for Payload<S, E>
impl<S, E> UnsafeUnpin for Payload<S, E>where
S: UnsafeUnpin,
impl<S, E> UnwindSafe for Payload<S, E>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more